Personal access tokens
Create, scope, rotate, and revoke the personal access tokens that authenticate Management API calls.
A personal access token is the only credential the Management API
accepts. It is a bearer credential that belongs to one person in one
organization, carries an explicit list of scopes,
and expires (unless your organization's token policy allows tokens that never expire). Personal access tokens authenticate the Management API only; they are
rejected on the portal's own API (a plain 401) and on the Inference API
(401 credential_type_mismatch).
| Property | How it works |
|---|---|
| Format | tf-pat_ followed by 43 URL-safe characters (256 bits of randomness). The fixed prefix lets secret scanners recognise a Token Factory management credential on sight. |
| Shown once | The full secret is displayed exactly once, when you create it. Afterwards the portal shows tf-pat_…a91f and the API returns a masked prefix such as tf-pat_AbCdE...a91f, plus its name, scopes, expiry and last use. |
| Hashed at rest | Token Factory stores a hash of the token, never the token itself. Nobody — including support — can show it to you again. |
| Attributable | Every token names its creator, and every call made with it is recorded in the audit log as that person using that token. A token is never anonymous and never a shared "service" identity. |
| One org | A token acts only in the organization it was created in. |
| Portal-bound | A token works only on the portal where it was created; a token from any other Token Factory portal is unknown here (401 invalid_credential). |
A token carries: id · name · prefix · scopes · created_by ·
created_at · expires_at · last_used_at · status (active ·
revoked · expired) · owner_role_at_creation (admin or member) ·
revoked_at and revoked_reason (set only on a revoked token). It carries
no project, no region and no key material.
Warning
Treat a personal access token like a password. Store it in a secret manager or your CI system's secret store, never in source control, never in a URL, and never in a log line. A personal access token can reshape your organization; a project API key can only spend.
Mint policy
| Rule | Value |
|---|---|
| Who can mint | Admins and Members, each for themselves, in the portal only. There is no API endpoint that creates a token. |
| Which scopes | An Admin can choose any of the 13 scopes. A Member can choose only org:read, projects:read, keys:read, keys:write, usage:read and catalog:read (403 scope_not_allowed_for_role otherwise, in the portal and the API alike). Select all picks exactly the scopes you may choose. |
| Re-authentication | Minting is a sensitive action. If your last sign-in is not recent, the portal asks you to re-authenticate before the token is created. |
| Note | Required, up to 64 characters, unique case-insensitively among your active tokens. A revoked token's note is free again — ci-deploy and CI-Deploy cannot both be active at once, but you can reuse a note once the token that held it is revoked. |
| Scopes | At least one, from the scope vocabulary. No wildcard; an unknown scope is refused. |
| Expiry | Default 90 days (or the organization maximum if that is shorter). The portal offers 30, 60, 90, 180 or 365 days up to the organization maximum, a custom date up to that maximum, and No expiry only if the organization allows it. Maximum 365 days. A longer expiry is refused with expiry_exceeds_org_policy; "no expiry" where it is not allowed with never_expiry_not_allowed. |
| Sensitive scopes | Refused with sensitive_scopes_disabled while the organization has switched them off (see Organization token policy). |
| Active-token cap | 20 active tokens per user. Minting a 21st is refused (token_limit_reached) — revoke one you no longer use. |
These are portal rules: minting is not a Management API call, so a refused
mint is reported in the portal's token dialog (invalid_name,
invalid_scopes, invalid_expiry, token_name_taken,
token_limit_reached, scope_not_allowed_for_role,
sensitive_scopes_disabled, expiry_exceeds_org_policy,
never_expiry_not_allowed), not in the Management API error envelope.
Why mandatory expiry: a standing credential with no review point is how organizations fail their own access reviews. Renewal is "mint the successor, revoke the predecessor", which also gives every integration a rehearsed rotation procedure.
Lifecycle
| Stage | How | Notes |
|---|---|---|
| Mint | Portal → Settings → API Tokens → Create token opens a dialog: Note, Expiration, Select scopes (a scope tree) → Generate token. Admins and Members, with re-authentication. | The one credential action a token can never perform itself. Sensitive scopes are flagged at selection. |
| Use | Authorization: Bearer tf-pat_… on every call. | Never a query parameter, never a cookie. last_used_at updates as you use it. |
| Expire | Automatic at expires_at. | The next call fails with 401 token_expired. |
| Revoke | Portal → Revoke, or DELETE /me/tokens/{id} for your own tokens. An Admin can revoke anyone's token, or every token in the organization at once, in the portal. Automatic when the owner is disabled, removed or moved to another organization. | Immediate — the next call fails with 401 token_revoked (401 invalid_credential once the owner is disabled or removed). There is no grace window. The token keeps a revoked_reason: owner, admin, org_revoke_all, member_removed, member_disabled or member_moved. |
| Audit | Mint (pat_create), revoke (pat_revoke, with the reason), revoke-all (pat_revoke_all, with the count) and policy changes (pat_policy_update) are audited; every write made with the token records its id, name and the scope used. | See Audit log. |
A token's scopes are fixed at mint. Nothing widens a token: to grant more, mint a new token. Role changes can only narrow what a token can do (the intersection rule).
When a member is disabled or removed, every personal access token they created stops working
immediately and irreversibly. Project API keys they created are not
touched — keys are project assets; a personal access token represents a person still acting.
(Removing a member with "delete_keys": true is the explicit exception —
see Members.)
Organization token policy
An organization Admin sets the token policy in the portal under Settings → API Tokens → Organisation token policy (saving asks you to re-authenticate if your last sign-in is not recent):
| Setting | Default | Effect |
|---|---|---|
| Maximum expiry (days) | 365 | New tokens cannot last longer. Existing tokens keep their expiry. |
| Allow tokens that never expire | On | When off, every new token needs an expiry date. |
| Switch off sensitive permissions | Off | When on, org:write, members:write and projects:write cannot be chosen, and tokens that already carry them get 403 insufficient_scope on the calls that need them (within 60 seconds). Switching it back off restores them. |
Every token in the organization (Admins)
Admins also see All tokens in the organisation on the same tab: every
token with its owner, the owner's role when it was created, scopes, last
use and status (with the revoked reason). An Admin can Revoke any
active token, or Revoke all tokens — this asks you to type
REVOKE ALL and to re-authenticate, then revokes every token in the
organization (your own included) and records one pat_revoke_all audit
entry with the count. Members see only their own tokens. These are portal
actions only: a personal access token never manages other tokens.
Create a token in the portal
-
Sign in to the portal (Admin or Member) and open Settings → API Tokens. The card is titled Your Management API tokens:
Personal access tokens authenticate the Management API — provisioning keys, projects, and members programmatically. They can't make inference calls, and project API keys can't call the Management API.
-
Click Create token. This opens the Create Management API token dialog — nothing is created yet.
-
Enter a Note that says what the token is for and who runs it — for example
CI · payments-deploy. It must be unique (case-insensitively) among your active tokens. -
Choose an Expiration: 30, 60, 90, 180 or 365 days up to your organization's maximum (default 90), a Custom date… (the date picker stops at the maximum), or No expiry if your organization allows it. Each option shows the calendar date the token would expire on.
-
Choose scopes under Select scopes — a two-column tree, one row per resource group in scope order.
org,members,projectsandkeyseach show a parent row: ticking it grants both the group's:readand:writescopes, and the two child rows then show ticked and greyed out (still one scope each on the wire — read and write stay independent). The remaining groups (usage:read,billing:read,audit:read,catalog:read) are single rows. Every row shows that scope's description. The three Sensitive writes —org:write,members:write,projects:write— carry a badge, and selecting any of them shows a one-line warning below the list. Nothing is preselected; Select all picks every scope you may choose. A Member sees only the six Member scopes. A summary strip below the list tracks how many scopes are selected and when the token would expire. -
Click Generate token. If your last sign-in is not recent, the portal asks you to confirm your identity: choose Sign in again, sign in, and you return to the dialog with your note, expiration and scopes kept — click Generate token once more to create the token.
-
The dialog switches to Token created, showing the secret with a Copy button and the token's name, expiry and scopes. Copy the secret now and store it in your secret manager — it is shown once, and the dialog ignores Escape and outside clicks so you can't lose it to a stray click. Click Done to close.
Each token then appears as a row with its name, masked prefix, creation
date, expiry and last use (tf-pat_…a91f · created Mar 20, 2026 · expires Jun 18, 2026 · last used never), its scopes, and (for active
tokens) a red Revoke button that asks you to confirm.
Tip
Every call is attributed to the token's creator. Mint automation tokens under a person who will stay responsible for that automation, and name the token after the job, not the person.
Verify a new token
The cheapest authenticated call is reading your own token list — it needs no scope:
curl https://portal.<domain>/api/v1/mgmt/me/tokens \
-H "Authorization: Bearer $TF_PAT"Rotate a token
Tokens have no grace window: mint the successor first; both work side by side until you revoke the old one. Rotation is three steps:
- Mint the successor in the portal with the same scopes and a fresh expiry.
- Deploy it — replace the secret in your CI system or secret manager and confirm one call succeeds.
- Revoke the predecessor — in the portal, or with
DELETE /me/tokens/{id}using the new token.
Put a reminder on the calendar a week before expires_at. An expired token
fails with 401 token_expired and an action telling you to mint a new one.
If a token leaks
Revoke it immediately (portal, or DELETE /me/tokens/{id}); revocation is
effective on the next call. Then read the audit log
filtered to the token owner (actor) and look for entries whose
metadata.pat_id is that token's id to see what it did. See
Incident response.