Admin Workspaces API
Terraform Enterprise Only: The admin API is exclusive to Terraform Enterprise, and can only be used by the admins and operators who install and maintain their organization's Terraform Enterprise instance.
The Workspaces Admin API contains endpoints to help site administrators manage workspaces.
List all workspaces
GET /api/v2/admin/workspaces
This endpoint lists all workspaces in the Terraform Enterprise installation.
Status | Response | Reason |
---|---|---|
200 | JSON API document (type: "workspaces" ) | Successfully listed workspaces |
404 | JSON API error object | Client is not an administrator. |
Query Parameters
These are standard URL query parameters. Remember to percent-encode [
as %5B
and ]
as %5D
if your tooling doesn't automatically encode URLs.
Parameter | Description |
---|---|
q | Optional. A search query string. Workspaces are searchable by name and organization name. |
filter[current_run][status] | Optional. A comma-separated list of Run statuses to restrict results to, which can include any of the following: "pending" , "plan_queued" , "planning" , "planned" , "confirmed" , "apply_queued" , "applying" , "applied" , "discarded" , "errored" , "canceled" , "cost_estimating" , "cost_estimated" , "policy_checking" , "policy_override" , "policy_soft_failed" , "policy_checked" , and "planned_and_finished" . |
sort | Optional. Allows sorting the organization's workspaces by a provided value. You can sort by "name" , "current-run.created-at" (the time of the current run), and "latest-change-at" (the creation time of the latest state version or the workspace itself if no state version exists). Prepending a hyphen to the sort parameter reverses the order. For example, "-name" sorts by name in reverse alphabetical order. If omitted, the default sort order is arbitrary but stable. |
page[number] | Optional. If omitted, the endpoint will return the first page. |
page[size] | Optional. If omitted, the endpoint will return 20 workspaces per page. |
Available Related Resources
This GET endpoint can optionally return related resources, if requested with the include
query parameter. The following resource types are available:
Resource Name | Description |
---|---|
organization | The organization for each returned workspace. |
organization.owners | A list of owners for each workspace's associated organization. |
current_run | The current run for each returned workspace. |
Sample Request
Sample Response
Show a workspace
GET /api/v2/admin/workspaces/:id
This endpoint returns the workspace with the specified workspace_id
.
Status | Response | Reason |
---|---|---|
200 | JSON API document (type: "workspaces" ) | Successfully listed workspaces |
404 | JSON API error object | Client is not an administrator. |
Query Parameters
Parameter | Description |
---|---|
:workspace_id | The workspace ID |
Available Related Resources
This GET endpoint can optionally return related resources, if requested with the include
query parameter. The following resource types are available:
Resource Name | Description |
---|---|
organization | The organization for each returned workspace. |
organization.owners | A list of owners for each workspace's associated organization. |
current_run | The current run for each returned workspace. |
Sample Request
Sample Response
Destroy a workspace
DELETE /admin/workspaces/:id
Parameter | Description |
---|---|
:workspace_id | The workspace ID |
Status | Response | Reason |
---|---|---|
204 | The workspace was successfully destroyed | |
404 | JSON API error object | Workspace not found or user unauthorized to perform action |
Sample Request
Sample Response
The response body will be empty if successful.