- Terraform Enterprise
- 2.1.x (latest)
- 2.0.x
- 1.2.x
- 1.1.x
- 1.0.x
- v202507-1
- v202506-1
- v202505-1
- v202504-1
- v202503-1
- v202502-2
- v202502-1
- v202501-1
- v202411-2
- v202411-1
- v202410-1
- v202409-3
- v202409-2
- v202409-1
- v202408-1
- No versions of this document exist before v202408-1. Click below to redirect to the version homepage.
- v202407-1
- v202406-1
- v202405-1
- v202404-2
- v202404-1
- v202402-2
- v202402-1
- v202401-2
- v202401-1
- v202312-1
- v202311-1
- v202310-1
- v202309-1
- v202308-1
- v202307-1
- v202306-1
- v202305-2
- v202305-1
- v202304-1
- v202303-1
- v202302-1
- v202301-2
- v202301-1
- v202212-2
- v202212-1
- v202211-1
- v202210-1
- v202209-2
- v202209-1
- v202208-3
- v202208-2
- v202208-1
- v202207-2
- v202207-1
- v202206-1
Admin user tokens API
The admin/user-tokens API lets site administrators list and delete user API tokens across all users in a Terraform Enterprise installation.
Only admins and operators who install and maintain their organization's Terraform Enterprise instance can use admin API endpoints.
List all user tokens
GET /api/v2/admin/user-tokens
This endpoint lists all user API tokens across all users in the Terraform Enterprise installation.
| Status | Response | Reason |
|---|---|---|
| 200 | JSON API document (type: "authentication-tokens") | Successfully listed user tokens |
| 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 |
|---|---|
filter[expiry_status] | Optional. Comma-separated list of expiry statuses to filter by. Accepted values are active, expiring_in_7_days, expiring_in_30_days, expired, no_expiration. |
sort | Optional. Sort results by a token attribute. Accepted values are expired-at, -expired-at, last-used-at, -last-used-at. Prefix with - for descending order. |
page[number] | Optional. If omitted, the endpoint returns the first page. |
page[size] | Optional. If omitted, the endpoint returns 20 tokens per page. |
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
"https://<TFE_HOSTNAME>/api/v2/admin/user-tokens"
Sample Request with Filters
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
"https://<TFE_HOSTNAME>/api/v2/admin/user-tokens?filter%5Bexpiry_status%5D=expired,expiring_in_7_days&sort=-expired-at"
Sample Response
{
"data": [
{
"id": "at-QoKZi25LmA1RDfzR",
"type": "authentication-tokens",
"attributes": {
"created-at": "2024-01-15T12:00:00.000Z",
"last-used-at": "2024-06-01T08:30:00.000Z",
"description": "CI pipeline token",
"expired-at": "2025-01-15T12:00:00.000Z",
"expiry-status": "expired"
},
"relationships": {
"created-by": {
"data": {
"id": "user-ZL4MsEKnd6iTigTb",
"type": "users"
}
}
}
}
],
"links": {
"self": "https://<TFE_HOSTNAME>/api/v2/admin/user-tokens?page%5Bnumber%5D=1&page%5Bsize%5D=20",
"first": "https://<TFE_HOSTNAME>/api/v2/admin/user-tokens?page%5Bnumber%5D=1&page%5Bsize%5D=20",
"prev": null,
"next": null,
"last": "https://<TFE_HOSTNAME>/api/v2/admin/user-tokens?page%5Bnumber%5D=1&page%5Bsize%5D=20"
},
"meta": {
"pagination": {
"current-page": 1,
"prev-page": null,
"next-page": null,
"total-pages": 1,
"total-count": 1
}
}
}
Delete a user token
DELETE /api/v2/admin/user-tokens/:token_id
This endpoint deletes a single user API token.
Administrators cannot delete their own token using this endpoint. Self-deletion is blocked. Use the user tokens API to manage your own tokens.
| Parameter | Description |
|---|---|
:token_id | The ID of the token to delete. |
| Status | Response | Reason |
|---|---|---|
| 204 | Empty body | Successfully deleted the token. |
| 403 | JSON API error object | The requesting admin cannot delete their own token. |
| 404 | JSON API error object | Token not found or client is not an administrator. |
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request DELETE \
"https://<TFE_HOSTNAME>/api/v2/admin/user-tokens/at-QoKZi25LmA1RDfzR"
Bulk-delete user tokens
DELETE /api/v2/admin/user-tokens
This endpoint deletes up to 100 user API tokens in a single atomic operation. If the call fails to delete all tokens in the request, Terraform Enterprise doesn't delete any of the tokens. Instead, it aborts the operation so that the system doesn't enter an inconsistent state.
The maximum number of tokens you can delete in a single request is 100. Terraform Enterprise rejects requests that specify more than 100 token IDs. Self-deletion is blocked, so administrators cannot include their own token in a bulk delete request. Instead, use the user tokens API to manage your own tokens.
| Status | Response | Reason |
|---|---|---|
| 204 | Empty body | Successfully deleted all specified tokens. |
| 400 | JSON API error object | Request exceeds the 100-token limit, or the request body is invalid. |
| 403 | JSON API error object | The request includes the requesting admin's own token. |
| 404 | JSON API error object | One or more token IDs not found, or client is not an administrator. |
| 422 | JSON API error object | Validation errors. |
Request Body
To send a DELETE request, you must include a JSON object with the following properties as a request payload.
| Key path | Type | Default | Description |
|---|---|---|---|
data | array of objects | An array of token resource identifier objects. | |
data[].type | string | Must be "authentication-tokens". | |
data[].id | string | The ID of the token to delete. |
Sample Payload
{
"data": [
{
"type": "authentication-tokens",
"id": "at-QoKZi25LmA1RDfzR"
},
{
"type": "authentication-tokens",
"id": "at-Ry7nKpL3bXwTmJ9Q"
}
]
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request DELETE \
--data @payload.json \
"https://<TFE_HOSTNAME>/api/v2/admin/user-tokens"