API tokens
Endpoint: /api/auth/tokens/
Manage your personal API tokens. A personal token acts as you, within its scopes and your current roles. Token management shows only your own tokens. For automation that runs commands or transfers files, use a service token.
Authentication
Token management and token history require a signed-in session, through the web console or the CLI after alpacon login. Personal API tokens and service tokens receive 403 permission_denied on those routes. The scope and preset catalogs require authentication but do not require a signed-in session. All examples below use a signed-in session.
Use alpacon token to manage tokens from the CLI, or follow the console steps. The examples below require alpacon-cli 1.14.2 or later. Sign in to your workspace with alpacon login, then run alpacon api with your signed-in session. It prints the response body and prompts for MFA when needed.
Creating, duplicating and rotating personal tokens require a paid plan. Otherwise, the API returns 402 workspace_plan_update_required.
List
List API tokens
GET /api/auth/tokens/Query parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Exact token name |
enabled | boolean | Enabled status |
search | string | Search by name |
ordering | string | added_at, updated_at, last_used_at; prefix - for descending. Default -updated_at |
page | integer | Page number |
page_size | integer | Results per page (default 15, maximum 100) |
Response
{
"count": 1,
"current": 1,
"next": null,
"previous": null,
"last": 1,
"results": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Inventory sync",
"enabled": true,
"scopes": [
"server:read",
"metric:read"
],
"unreachable_scopes": [],
"added_at": "2026-10-20T09:00:00Z",
"updated_at": "2026-10-20T09:00:00Z",
"expires_at": "2026-12-31T23:59:59Z",
"last_used_at": null,
"usage_count": 0
}
]
}Page links are integer page numbers. unreachable_scopes lists claimed scopes your current roles do not allow. Other scopes continue to work.
Example
alpacon api -X GET "/api/auth/tokens/?enabled=true"Rotate API token
POST /api/auth/tokens/{token_id}/rotate/Replace the key on the same token. No request fields are needed. The old key stops authenticating immediately, and connections opened with it close. Update the stored secret as part of the same operation. usage_count resets to 0 and last_used_at to null.
Scopes stay unchanged and are not checked again for issuance. An existing expiry stays unchanged; a token without one receives the workspace maximum lifetime from now. An expired token cannot be rotated.
200 OK returns the token with its new key, using the same fields as creation.
alpacon api -X POST "/api/auth/tokens/550e8400-e29b-41d4-a716-446655440000/rotate/"Duplicate API token
POST /api/auth/tokens/{token_id}/duplicate/Create a separate token while leaving the source key valid. The optional name is at most 128 characters. When omitted, the name is based on the source name with (copy) or a numbered copy suffix.
The copy keeps enabled and stored scopes except scopes personal tokens cannot be issued. If filtering removes every scope from a nonempty list, duplication fails with api_token_scopes_required. The copied expiry is limited to the workspace maximum. Server and file ACLs are copied; command ACLs are copied where command ACL writes are available. An expired source cannot be duplicated.
201 Created returns the new token and its one-time key, using the creation response fields.
alpacon api -X POST \
-f 'name=Inventory sync backup' \
"/api/auth/tokens/550e8400-e29b-41d4-a716-446655440000/duplicate/"Scope and preset catalogs
GET /api/auth/tokens/scopes/
GET /api/auth/tokens/presets/Both return 200 OK without pagination. The scope response contains resources entries with name, actions and acl, limited to scopes your roles allow and the workspace offers for personal tokens. wildcards is an empty array, including for Superusers.
The preset response is an object keyed by preset ID. Each entry has name and description objects with en and ko, plus a permissions array. It filters out unavailable extensions and scopes personal tokens cannot carry. It does not filter by your roles; creation still checks your permission ceiling.
alpacon api -X GET "/api/auth/tokens/scopes/"alpacon api -X GET "/api/auth/tokens/presets/"Token history
GET /api/auth/token-history/
GET /api/auth/token-history/{history_id}/Read changes to a token’s effective scopes after its owner’s roles change. Members see their own token history; admins see the workspace history. History remains readable after token deletion, with api_token: null and the saved api_token_name.
Query parameters
| Parameter | Description |
|---|---|
api_token | Existing token ID; for a deleted token, filter by name or owner instead |
api_token_name, token_user | Exact token name or owner ID |
change_type, change_type__in | Exact change type or comma-separated types |
added_at__gte, added_at__lte | Time bounds |
ordering | added_at or -added_at (default) |
page, page_size | Integer pagination; default 15 entries, maximum 100 |
List responses use count, current, next, previous, last, results. Each result, or the detail response, contains id, api_token, api_token_name, token_user, change_type, changes and added_at. A scope reduction is recorded in changes.effective_scopes.lost.
alpacon api -X GET "/api/auth/token-history/?api_token_name=Inventory%20sync"Error responses
| Status | Error code | Description |
|---|---|---|
| 400 | api_token_exists | A token already has this name |
| 400 | api_token_scope_invalid | Malformed or unknown scope |
| 400 | api_token_scope_exceeds_rbac | Scope exceeds your global role permissions |
| 400 | api_token_scope_not_mintable | Scope or covering wildcard cannot be issued on a personal token |
| 400 | api_token_scopes_required | Default, preset or duplicate processing produced no usable scopes |
| 400 | api_token_invalid_preset | Unknown preset or its extension is off |
| 400 | api_token_presets_not_allowed_on_update | Use scopes, not presets, on update |
| 400 | api_token_invalid_expiration | Expiry is in the past |
| 400 | api_token_expires_exceeds_max_ttl | Expiry exceeds the workspace maximum lifetime |
| 400 | api_token_already_expired | Expired tokens cannot be revived, widened, duplicated or rotated |
| 400 | api_token_scope_expansion_pending | A scope expansion already awaits approval |
| 401 | auth_token_missing | Not authenticated, or credential is invalid or expired |
| 402 | workspace_plan_update_required | Create, duplicate and rotate require a paid plan |
| 403 | permission_denied | Management or history requested with a personal or service token |
| 403 | workspace_suspended | Writes refused while the workspace is suspended |
| 404 | api_not_found | Token or history entry is not accessible or does not exist |