# Machine Templates API

Create, list, inspect, update, and delete machine templates.

## List machine templates

`GET /api/v0/machines/templates` (Deprecated)

Deprecated: use Environments (`/api/v0/environments`) instead. Returns every machine template the caller can access in the authenticated organization, in one response: pagination.hasMore is always false and pagination.nextCursor is always null.

```bash
curl 'https://api.factory.ai/api/v0/machines/templates' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "templates": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "templateId": {
            "type": "string",
            "description": "Template ID"
          },
          "repoUrl": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri"
              },
              {
                "type": "string",
                "enum": [
                  ""
                ]
              }
            ],
            "description": "Repository URL"
          },
          "templateName": {
            "type": "string",
            "description": "Human-readable template name"
          },
          "defaultBranch": {
            "type": "string",
            "description": "Default branch name"
          },
          "createdBy": {
            "type": "string",
            "description": "User ID of creator"
          },
          "createdAt": {
            "type": "integer",
            "description": "Creation timestamp (ms)"
          },
          "buildStatus": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "building",
                  "success",
                  "failed"
                ],
                "description": "Current build status"
              },
              "failureReason": {
                "type": "string",
                "enum": [
                  "setup_script_error",
                  "system_error"
                ],
                "description": "Reason for build failure (only present when status is failed)"
              },
              "buildStartedAt": {
                "type": "integer",
                "description": "Build start timestamp (ms)"
              },
              "builtAt": {
                "type": "integer",
                "description": "Build completion timestamp (ms)"
              },
              "logs": {
                "type": "string",
                "description": "Build logs"
              }
            },
            "required": [
              "status"
            ],
            "description": "Build status"
          },
          "lastUpdatedAt": {
            "type": "integer",
            "nullable": true,
            "description": "Last update timestamp (ms)"
          },
          "environmentVariables": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "description": "Environment variable name"
                },
                "value": {
                  "type": "string",
                  "description": "Environment variable value"
                }
              },
              "required": [
                "key",
                "value"
              ]
            },
            "description": "Shared environment variables"
          },
          "userEnvironmentVariablesByUser": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "description": "Environment variable name"
                },
                "value": {
                  "type": "string",
                  "description": "Environment variable value"
                }
              },
              "required": [
                "key",
                "value"
              ]
            },
            "description": "User-specific environment variables"
          },
          "setupScript": {
            "type": "string",
            "description": "Setup script to run after cloning"
          }
        },
        "required": [
          "templateId",
          "repoUrl",
          "templateName",
          "defaultBranch",
          "createdBy"
        ]
      }
    },
    "pagination": {
      "type": "object",
      "properties": {
        "hasMore": {
          "type": "boolean",
          "description": "Whether there are more items after this page"
        },
        "nextCursor": {
          "type": "string",
          "nullable": true,
          "description": "Cursor to use for the next page, null if no more pages"
        }
      },
      "required": [
        "hasMore",
        "nextCursor"
      ]
    }
  },
  "required": [
    "templates",
    "pagination"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Create a machine template

`POST /api/v0/machines/templates` (Deprecated)

Deprecated: use Environments (`/api/v0/environments`) instead. Creates a machine template from a repository enabled in the organization integrations and starts its build asynchronously. The 201 response reports buildStatus.status `building`; poll GET until it becomes `success` or `failed`. Returns 403 when Cloud Machines are not enabled for the organization, and 400 when the template name is taken, the repository is not found or not enabled, or the GitHub App installation for the repository is disconnected. Returns 409 when the organization requires personal GitLab Self-Hosted connections and the GitLab project behind the template was renamed or moved since repositories were last synced; an admin must sync repositories before the request can succeed.

```bash
curl -X POST 'https://api.factory.ai/api/v0/machines/templates' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
```

**Parameters**

- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Request body** (required)

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "repoUrl": {
      "type": "string",
      "format": "uri",
      "description": "Repository URL to clone"
    },
    "templateName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "description": "Human-readable template name"
    },
    "environmentVariables": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "pattern": "^[A-Z_][A-Z0-9_]*$",
            "description": "Uppercase POSIX environment variable name. A name the managed computer runtime reserves is rejected with 400."
          },
          "value": {
            "type": "string",
            "description": "Environment variable value"
          }
        },
        "required": [
          "key",
          "value"
        ],
        "additionalProperties": false
      },
      "description": "Environment variables to set in the machine"
    },
    "setupScript": {
      "type": "string",
      "maxLength": 10000,
      "description": "Setup script to run after cloning"
    }
  },
  "required": [
    "repoUrl",
    "templateName"
  ],
  "additionalProperties": false
}
```

**Response:** `201` - Response for status 201

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "templateId": {
      "type": "string",
      "description": "Template ID"
    },
    "repoUrl": {
      "anyOf": [
        {
          "type": "string",
          "format": "uri"
        },
        {
          "type": "string",
          "enum": [
            ""
          ]
        }
      ],
      "description": "Repository URL"
    },
    "templateName": {
      "type": "string",
      "description": "Human-readable template name"
    },
    "defaultBranch": {
      "type": "string",
      "description": "Default branch name"
    },
    "createdBy": {
      "type": "string",
      "description": "User ID of creator"
    },
    "createdAt": {
      "type": "integer",
      "description": "Creation timestamp (ms)"
    },
    "buildStatus": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "building",
            "success",
            "failed"
          ],
          "description": "Current build status"
        },
        "failureReason": {
          "type": "string",
          "enum": [
            "setup_script_error",
            "system_error"
          ],
          "description": "Reason for build failure (only present when status is failed)"
        },
        "buildStartedAt": {
          "type": "integer",
          "description": "Build start timestamp (ms)"
        },
        "builtAt": {
          "type": "integer",
          "description": "Build completion timestamp (ms)"
        },
        "logs": {
          "type": "string",
          "description": "Build logs"
        }
      },
      "required": [
        "status"
      ],
      "description": "Build status"
    },
    "lastUpdatedAt": {
      "type": "integer",
      "nullable": true,
      "description": "Last update timestamp (ms)"
    },
    "environmentVariables": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Environment variable name"
          },
          "value": {
            "type": "string",
            "description": "Environment variable value"
          }
        },
        "required": [
          "key",
          "value"
        ]
      },
      "description": "Shared environment variables"
    },
    "userEnvironmentVariablesByUser": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Environment variable name"
          },
          "value": {
            "type": "string",
            "description": "Environment variable value"
          }
        },
        "required": [
          "key",
          "value"
        ]
      },
      "description": "User-specific environment variables"
    },
    "setupScript": {
      "type": "string",
      "description": "Setup script to run after cloning"
    }
  },
  "required": [
    "templateId",
    "repoUrl",
    "templateName",
    "defaultBranch",
    "createdBy"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `409` - Response for status 409

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `413` - Response for status 413

Content type: `application/json`

```json
{
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "description": "The platform edge refused a body over its own size limit before the route ran, and answered in JSON because the request accepts JSON, for example `{\"error\":{\"code\":\"413\",\"message\":\"Request Entity Too Large\"}}`.",
      "required": [
        "error"
      ],
      "properties": {
        "error": {
          "type": "object",
          "required": [
            "code",
            "message"
          ],
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            }
          }
        }
      },
      "not": {
        "required": [
          "detail"
        ]
      }
    }
  ]
}
```

Content type: `text/plain`

```json
{
  "type": "string",
  "description": "The platform edge refused a body over its own size limit before the route ran, for example `Request Entity Too Large` followed by an error code such as `FUNCTION_PAYLOAD_TOO_LARGE`."
}
```

**Response:** `415` - Response for status 415

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "Request validation error"
    },
    "errors": {
      "type": "array",
      "items": {},
      "description": "Framework validation issues, when available"
    }
  },
  "required": [
    "message"
  ]
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Get a machine template

`GET /api/v0/machines/templates/{templateId}` (Deprecated)

Deprecated: use Environments (`/api/v0/environments`) instead. Returns details of a specific machine template. Returns 409 when the organization requires personal GitLab Self-Hosted connections and the GitLab project behind the template was renamed or moved since repositories were last synced; an admin must sync repositories before the request can succeed.

```bash
curl 'https://api.factory.ai/api/v0/machines/templates/{templateId}' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `templateId` (`string`, required) - Path parameter. Template ID
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "templateId": {
      "type": "string",
      "description": "Template ID"
    },
    "repoUrl": {
      "anyOf": [
        {
          "type": "string",
          "format": "uri"
        },
        {
          "type": "string",
          "enum": [
            ""
          ]
        }
      ],
      "description": "Repository URL"
    },
    "templateName": {
      "type": "string",
      "description": "Human-readable template name"
    },
    "defaultBranch": {
      "type": "string",
      "description": "Default branch name"
    },
    "createdBy": {
      "type": "string",
      "description": "User ID of creator"
    },
    "createdAt": {
      "type": "integer",
      "description": "Creation timestamp (ms)"
    },
    "buildStatus": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "building",
            "success",
            "failed"
          ],
          "description": "Current build status"
        },
        "failureReason": {
          "type": "string",
          "enum": [
            "setup_script_error",
            "system_error"
          ],
          "description": "Reason for build failure (only present when status is failed)"
        },
        "buildStartedAt": {
          "type": "integer",
          "description": "Build start timestamp (ms)"
        },
        "builtAt": {
          "type": "integer",
          "description": "Build completion timestamp (ms)"
        },
        "logs": {
          "type": "string",
          "description": "Build logs"
        }
      },
      "required": [
        "status"
      ],
      "description": "Build status"
    },
    "lastUpdatedAt": {
      "type": "integer",
      "nullable": true,
      "description": "Last update timestamp (ms)"
    },
    "environmentVariables": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Environment variable name"
          },
          "value": {
            "type": "string",
            "description": "Environment variable value"
          }
        },
        "required": [
          "key",
          "value"
        ]
      },
      "description": "Shared environment variables"
    },
    "userEnvironmentVariablesByUser": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Environment variable name"
          },
          "value": {
            "type": "string",
            "description": "Environment variable value"
          }
        },
        "required": [
          "key",
          "value"
        ]
      },
      "description": "User-specific environment variables"
    },
    "setupScript": {
      "type": "string",
      "description": "Setup script to run after cloning"
    }
  },
  "required": [
    "templateId",
    "repoUrl",
    "templateName",
    "defaultBranch",
    "createdBy"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `409` - Response for status 409

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Update a machine template

`PATCH /api/v0/machines/templates/{templateId}` (Deprecated)

Deprecated: use Environments (`/api/v0/environments`) instead. Updates the configuration of a machine template. Each supplied array replaces the stored list: environmentVariables for every user of the template, userEnvironmentVariables for the caller only. Changing setupScript or environmentVariables requires the Manager or Owner role or being the template creator; any member can set their own userEnvironmentVariables. Supplying setupScript, or sending an empty JSON object (`{}`), starts an asynchronous rebuild: the response reports buildStatus.status `building`, and GET reports the result. The built-in empty template cannot be modified. Returns 409 when the organization requires personal GitLab Self-Hosted connections and the GitLab project behind the template was renamed or moved since repositories were last synced; an admin must sync repositories before the request can succeed.

```bash
curl -X PATCH 'https://api.factory.ai/api/v0/machines/templates/{templateId}' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
```

**Parameters**

- `templateId` (`string`, required) - Path parameter. Template ID
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Request body** (required)

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "environmentVariables": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "pattern": "^[A-Z_][A-Z0-9_]*$",
            "description": "Uppercase POSIX environment variable name. A name the managed computer runtime reserves is rejected with 400."
          },
          "value": {
            "type": "string",
            "description": "Environment variable value"
          }
        },
        "required": [
          "key",
          "value"
        ],
        "additionalProperties": false
      },
      "description": "Shared environment variables for all machine users"
    },
    "userEnvironmentVariables": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "pattern": "^[A-Z_][A-Z0-9_]*$",
            "description": "Uppercase POSIX environment variable name. A name the managed computer runtime reserves is rejected with 400."
          },
          "value": {
            "type": "string",
            "description": "Environment variable value"
          }
        },
        "required": [
          "key",
          "value"
        ],
        "additionalProperties": false
      },
      "description": "User-specific environment variables"
    },
    "setupScript": {
      "type": "string",
      "maxLength": 10000,
      "description": "Setup script to run after cloning"
    }
  },
  "additionalProperties": false
}
```

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "templateId": {
      "type": "string",
      "description": "Template ID"
    },
    "repoUrl": {
      "anyOf": [
        {
          "type": "string",
          "format": "uri"
        },
        {
          "type": "string",
          "enum": [
            ""
          ]
        }
      ],
      "description": "Repository URL"
    },
    "templateName": {
      "type": "string",
      "description": "Human-readable template name"
    },
    "defaultBranch": {
      "type": "string",
      "description": "Default branch name"
    },
    "createdBy": {
      "type": "string",
      "description": "User ID of creator"
    },
    "createdAt": {
      "type": "integer",
      "description": "Creation timestamp (ms)"
    },
    "buildStatus": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "building",
            "success",
            "failed"
          ],
          "description": "Current build status"
        },
        "failureReason": {
          "type": "string",
          "enum": [
            "setup_script_error",
            "system_error"
          ],
          "description": "Reason for build failure (only present when status is failed)"
        },
        "buildStartedAt": {
          "type": "integer",
          "description": "Build start timestamp (ms)"
        },
        "builtAt": {
          "type": "integer",
          "description": "Build completion timestamp (ms)"
        },
        "logs": {
          "type": "string",
          "description": "Build logs"
        }
      },
      "required": [
        "status"
      ],
      "description": "Build status"
    },
    "lastUpdatedAt": {
      "type": "integer",
      "nullable": true,
      "description": "Last update timestamp (ms)"
    },
    "environmentVariables": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Environment variable name"
          },
          "value": {
            "type": "string",
            "description": "Environment variable value"
          }
        },
        "required": [
          "key",
          "value"
        ]
      },
      "description": "Shared environment variables"
    },
    "userEnvironmentVariablesByUser": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Environment variable name"
          },
          "value": {
            "type": "string",
            "description": "Environment variable value"
          }
        },
        "required": [
          "key",
          "value"
        ]
      },
      "description": "User-specific environment variables"
    },
    "setupScript": {
      "type": "string",
      "description": "Setup script to run after cloning"
    }
  },
  "required": [
    "templateId",
    "repoUrl",
    "templateName",
    "defaultBranch",
    "createdBy"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `409` - Response for status 409

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `413` - Response for status 413

Content type: `application/json`

```json
{
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "description": "The platform edge refused a body over its own size limit before the route ran, and answered in JSON because the request accepts JSON, for example `{\"error\":{\"code\":\"413\",\"message\":\"Request Entity Too Large\"}}`.",
      "required": [
        "error"
      ],
      "properties": {
        "error": {
          "type": "object",
          "required": [
            "code",
            "message"
          ],
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            }
          }
        }
      },
      "not": {
        "required": [
          "detail"
        ]
      }
    }
  ]
}
```

Content type: `text/plain`

```json
{
  "type": "string",
  "description": "The platform edge refused a body over its own size limit before the route ran, for example `Request Entity Too Large` followed by an error code such as `FUNCTION_PAYLOAD_TOO_LARGE`."
}
```

**Response:** `415` - Response for status 415

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "Request validation error"
    },
    "errors": {
      "type": "array",
      "items": {},
      "description": "Framework validation issues, when available"
    }
  },
  "required": [
    "message"
  ]
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Delete a machine template

`DELETE /api/v0/machines/templates/{templateId}` (Deprecated)

Deprecated: use Environments (`/api/v0/environments`) instead. Deletes a machine template: revokes its API keys and marks the template deleted, after which GET and PATCH return 400. Requires the Manager or Owner role or being the template creator. The built-in empty template cannot be deleted.

```bash
curl -X DELETE 'https://api.factory.ai/api/v0/machines/templates/{templateId}' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `templateId` (`string`, required) - Path parameter. Template ID
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `204` - Response for status 204

No response body.

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```
