Workspace tokens

A workspace token is a bearer credential that acts inside one workspace, within its scopes, for the resource API and the Terraform provider. It is issued through the resource API, which the web app's API access page calls. It has no Terraform resource and is not part of an export.

KindEndpointTerraformAddress
workspace-token/api/v1/resources/workspaces/{workspaceId}/tokensnone<name>

See Resource API for the operations, headers and errors every kind shares.

Example

{
  "name": "ci",
  "description": "Plans the platform repository on every pull request",
  "scopes": ["plan"],
  "expiresAt": "2026-12-31T23:59:59Z"
}

Endpoints

OperationEndpointDescription
issue (create)POST /api/v1/resources/workspaces/{workspaceId}/tokensNeeds Idempotency-Key. Returns 201 and the token's value in the Spotlight-Workspace-Token response header.
readGET /api/v1/resources/tokens/{id}Never returns the value.
updatePUT /api/v1/resources/tokens/{id}Changes description only. Needs If-Match.
revoke (delete)DELETE /api/v1/resources/tokens/{id}Spotlight does not accept the token from this moment. Needs If-Match.
importGET /api/v1/resources/workspaces/{workspaceId}/tokens/import?address=<name>
listGET /api/v1/resources/workspaces/{workspaceId}/tokensEvery token issued by a person. Tokens issued by an OIDC trust, or for a run, are not listed.

Issuing, updating and revoking need the administer permission, which only a workspace owner or admin has, signed in as a person. No token can issue, update or revoke a token. Reading, importing and listing need read.

Fields

FieldTypeDefaultDescription
namestringrequiredLowercase words joined by dashes, at most 64 characters. Immutable: an update that changes it is rejected.
scopesarray of stringsrequiredAt least one, each once. See scopes. Immutable: an update that changes it is rejected.
descriptionstring""At most 255 characters. The only field an update changes.
expiresAtstring or nullnullAn RFC 3339 time. After this time, Spotlight does not accept the token. Must be in the future. Null never expires. Immutable: an update that changes it is rejected.
workspaceIdstringread-onlyThe workspace the token acts in, and the only one.
issuedBystringread-onlyThe person who issued it.
issuedAtstringread-onlyWhen it was issued, as an RFC 3339 time.

Scopes

A token carries one or more of the scopes read, plan, configure, secrets, runners and trusts. See Token scopes for what each grants.

MessageCause
must include read, plan or configure. Secrets, runners and trusts need one of themNone of read, plan or configure is named.
must name each scope onceA scope is named twice.

Each is returned at the path scopes.

What no token can do

  • Administer: issue, update or revoke tokens, change members or roles, or read the configuration changes.
  • Create a workspace. A workspace token acts only inside its own workspace.

A request a token's scopes do not allow gets 403 and a problem naming the missing permission. A resource the token cannot see returns 404.

Value

PropertyValue
Format32 random bytes, base64url, with no prefix.
ReturnedOnce, in the Spotlight-Workspace-Token header of the issuing response. Never again, not even to a retry with the same Idempotency-Key.
StoredAs a SHA-256 hash only.
Sent asAuthorization: Bearer <token>

A token that is revoked, or past expiresAt, gets 401.

On this page