| title | Tokens |
|---|---|
| category | Organizations and access |
| order | 50 |
| description | API tokens, fine-grained scopes, and run tokens. |
Tokens authenticate every API request. The token is sent as Authorization: Bearer <token>.
| Type | Scope | Uses |
|---|---|---|
| User token | The user's access | CLI, API, automation |
| Organization token | One organization | Team automation |
| Team token | One team | Team automation |
| Run token | One run | Terraform CLI inside a run |
| Session token | One browser session | Web interface |
A user creates tokens in the account page or through the API. Each token has a description and an expiry. Installation-keyed token hashes are stored, never the plaintext. Set TERRENCE_TOKEN_HASH_SECRET consistently across replicas; single-node installs persist a generated secret in STORAGE_DIR/.token-hash-secret.
Revoking a token invalidates it immediately.
Organization owners create organization tokens. Team owners create team tokens. A team token acts with the team's permissions. These tokens are full-permission tokens for their scope.
A user token can carry scopes. Scopes restrict the token to:
- Specific organizations.
- Specific projects.
- Specific workspaces.
- Specific tags.
- A set of permission grants.
A scoped token cannot mint new tokens. Requests outside the scope are rejected.
Every executed run receives a short-lived credential:
- The worker mints a token before execution.
- The token is written into a private CLI configuration file in the run directory.
- Terraform uses it for state and registry access during the run.
- The token is revoked when the run reaches a terminal state.
Run tokens expire at most 24 hours after minting. A run that dies with the process has its token revoked at startup reconciliation.
Browser sessions use a refreshable session token. The access token lives in memory. The refresh token lives in an HttpOnly cookie. Sessions refresh transparently.
Token revocation is immediate. User suspension, user deletion, and admin demotion close live event streams at once. The web interface reconnects and re-resolves permissions.
POST /api/v2/users/:id/authentication-tokensDELETE /api/v2/authentication-tokens/:idPOST /api/v2/organizations/:org_name/authentication-tokenDELETE /api/v2/organizations/:org_name/authentication-tokenPOST /api/v2/teams/:id/authentication-tokenDELETE /api/v2/teams/:id/authentication-token