API keys
Scoped tvkey_ keys and scoped agents for the CLI, CI and automation, with least-privilege scopes and no-escalation delegation.
Scripts and CI need their own identity with only the permissions they need. Create one under Settings > API keys (/settings/keys, "Scoped keys for the CLI and automation"). Up to 25 keys per account.
| Principal | Credential | Powers |
|---|---|---|
| You | Web sign-in, or tvault login (a CLI session, tvcli_) | Every scope, plus the human-only actions below |
| API key | tvkey_... | Exactly the scopes you pick. Reads values only |
| Classic agent | tvagent_... | credentials:read and mcp:use, bounded by its grants |
| Scoped agent | tvagent_... | A chosen scope list on top of its grants |
Values never pass through Token Vault
Scopes govern the control plane. When a key writes a credential (tokens:create), the value goes from the CLI to your webhook on a signed store ticket.
Create a key
In the web app: Settings > API keys > Create. Fields: Name (for example "CI deploy, provisioning script"), Expires, Scopes. The key page (/settings/keys/[id]) has tabs Overview, Access, Policies, Activity.
$ tvault keys create --name ci --scopes tokens:create-read,agents:create --expires 90d
tvkey_... # printed once, on stdoutExpiry: 30d, 90d (default), 365d, a date, or never. Prefer short for CI.
Shown once
The tvkey_ value is returned a single time. Lost it? Rotate: tvault keys rotate <id> as a signed-in human. A working key can rotate itself with tvault keys rotate --self.
tvault keys ls # id, name, status, scopes, expires, last_used
tvault keys show ci # + created_by and grants
tvault keys revoke ci # needs keys:revoke
tvault whoami # principal, kind, scopes, expiryGive a key access to a credential
Keys get Value access only (no MCP). Give it in the Grant dialog, the Access tab, or:
tvault keys grant ci github --expires-in-hours 24
tvault keys ungrant ci githubThen the key reads the value with the same 307 flow as an agent. Send the key in Authorization: Bearer only (not X-Agent-Key, not ?key=):
curl -i 'https://api.tokenvault.uk/api/agents/credentials?service=github' \
-H "Authorization: Bearer $TVKEY"Reading also needs credentials:read. Labels and policies can be attached to a key (tvault policy attach <id> --key ci).
Scoped agents
An agent is classic until you give it scopes.
tvault agents create --name hub-minter --kind scoped --scopes tokens:createFull list of the 18 scopes: scope reference.
Rules that keep keys independent
- No escalation. A child gets a subset of the creator's scopes. A child key expires no later than its creator.
- Human-only scopes.
keys:manage,keys:revoke,agents:manage,agents:delete,policies:write,grants:write,tokens:update,tokens:deleteandproxies:writecan only be put on a key or agent by a signed-in human. A key that tries gets403 SCOPE_NOT_DELEGABLE, even if it holds the scope. - Independent after creation. Revoking, suspending or narrowing one key never touches another, including keys it created. If a key is compromised, revoke it, then check the "Created by" column and revoke what it made.
- Account-wide scopes.
agents:manageworks on any agent,tokens:deleteon any credential. "Created by" is information only. - No self-loosening. A key can't change its own scopes, resume itself, or edit, detach or delete policies attached to itself (
403 SELF_CHANGE_FORBIDDEN). It can rotate itself, suspend itself and add a policy to itself. - Grants can't widen.
grants:writealso needscredentials:read. A key can only hand out access it holds itself. - Dry runs are free.
POST /api/policies/evaluateconsumes no counters and writes no events. - Other principals' keys. Rotating or revealing them is human-only (
403 HUMAN_ONLY).
Human-only actions
| Action | Why |
|---|---|
| Resume access after a stop | A person decides when automation may run |
| Bind or rebind the webhook | Moves the data plane |
| Add MCP redirect hosts | Changes where OAuth tokens can be sent |
| Delete or export the account | Account-level |
| Rotate or reveal another principal's key | A key may only rotate itself |
| Put the human-only scopes on a key or agent | A person decides who gets destructive powers |
A key that tries gets 403 HUMAN_ONLY (CLI exit 9). Putting a human-only scope on a key or agent returns 403 SCOPE_NOT_DELEGABLE instead (CLI exit 1).
Stop all access freezes every key and scoped agent until you resume.
Worked example: store a token from a script
A script mints a Cloudflare service token and saves it. It needs tokens:create and nothing else, so it can write but never read back.
# once, as you
tvault agents create --name cf-minter --kind scoped --scopes tokens:create
# tvagent_... <- shown once; store in the script host's secret store
# in the script
printf %s "$CF_MINTER_KEY" | tvault login --key-stdin --as cf-minter
./mint-cloudflare-service-token.sh | tvault add cloudflare-ztThe value goes from the CLI to your webhook on a signed store ticket. To let the script read it back, add tokens:create-read (read grant on what it creates) and credentials:read.
Pipe keys in with --key-stdin. --key lands in shell history and process listings.
Errors
Gate errors return {"detail":{"code","message","missingScope"}}. Exit codes: 8 SCOPE_DENIED, 9 HUMAN_ONLY, 10 key expired, 11 key suspended, 12 invalid key. See errors.