Errors and Exit Codes
Every HTTP status and error code the Token Vault API returns, the five body shapes they arrive in, and the tvault CLI exit codes.
Body shapes
Branch on detail.code (or code), not on message.
| Shape | Used for | Example |
|---|---|---|
| Detail envelope | Almost every refusal | {"detail": {"code": "NO_GRANT", "message": "..."}} |
| Bare detail | Plain 4xx without a code | {"detail": "Agent not found"} |
| Rate limit | Floor, penalty box, no-grant misses, ceiling | {"error": "Rate limit exceeded", "code": "RATE_LIMITED", "retryAfter": 41} plus Retry-After |
| Policy denial | A policy refused | {"error": "Access denied by policy", "policy": "...", "rule": "...", "reason": "...", "code": "POLICY_DENIED"} |
| JSON-RPC | MCP routes | {"jsonrpc": "2.0", "id": 1, "error": {"code": -32029, ...}} or a tool result with isError: true |
Scope refusals add missingScope and missingScopes to the detail:
{"detail": {"code": "SCOPE_DENIED", "message": "Missing required scope: tokens:create", "missingScope": "tokens:create", "missingScopes": ["tokens:create"]}}Request validation failures are 422 with code: "VALIDATION_ERROR" and a single readable message. An unexpected server error is 500 with code: "INTERNAL" and a generic message. Details of the shapes that carry policy and rate-limit data: Denials.
HTTP status codes
| Status | Meaning here |
|---|---|
| 200, 201 | Success |
| 307 | Credential redirect to your webhook (agent credentials) |
| 400 | Bad input, or a NO_FIELDS / INVALID_EXPIRY style validation error |
| 401 | No or bad identity, expired key, or REAUTH_REQUIRED |
| 403 | Authenticated but refused: scope, grant, policy, suspended, human-only |
| 404 | Unknown object, or NO_GRANT |
| 409 | Conflict: name taken, rotation race, refresh needs reconnect |
| 410 | Feature turned off (OAUTH_CONNECT_DISABLED) |
| 412 | Precondition: webhook not bound, agent suspended, no refresh token |
| 422 | Validation error with a code |
| 423 | VAULT_LOCKED: you stopped all access |
| 424 | Your webhook answered but could not do it (REFRESH_FAILED_AT_WEBHOOK) |
| 429 | Rate limited. Always read Retry-After |
| 502 | Webhook unreachable or misconfigured |
| 503 | Webhook circuit open, or a check could not be completed. Retry |
Error codes
Identity and scopes
| Code | HTTP | CLI exit | Meaning |
|---|---|---|---|
MISSING_KEY | 401 | 2 | No key sent |
INVALID_KEY | 401 (403 on GET /api/agents/credentials for classic agent keys) | 12 | Unknown, revoked, rotated-out or malformed key |
KEY_EXPIRED | 401 | 10 | Past its expiry. Rotate it or create a new one |
KEY_SUSPENDED | 403 | 11 | The key is suspended |
AGENT_INACTIVE | 403 | 11 | The agent is suspended or deleted |
WRONG_RESOURCE | 401 | A tvsess_ issued for a different MCP URL | |
IDENTITY_ONLY_SESSION | 403 | The session proves identity only | |
REAUTH_REQUIRED | 401 | 2 | A sign-in within the last 5 minutes is needed |
SCOPE_DENIED | 403 | 8 | The key lacks the scope in missingScope |
HUMAN_ONLY | 403 | 9 | Only a signed-in human can do this |
SCOPE_NOT_DELEGABLE | 403 | 1 | A key or agent tried to give a human-grant-only scope to another. scopes lists them |
UNKNOWN_SCOPE | 400 | 1 | Scope name not in Scopes |
SELF_CHANGE_FORBIDDEN | 403 | 1 | A key or agent tried to loosen its own controls (scopes, resume, policies, grants). Suspending, renaming and rotating itself are allowed |
SELF_GRANT_FORBIDDEN | 403 | 1 | A key or agent tried to add or remove its own grants |
ROTATION_CONFLICT | 409 | 1 | Two rotations of the same key raced. No new key was issued |
KEY_NOT_ACTIVE | 409 | 1 | Only an active key can be rotated |
INVALID_EXPIRY | 400 | 1 | Expiry in the past or beyond 10 years, or both expiresInHours and expiresAt named. A later expiry than the creator's is silently clamped |
Grants and access
| Code | HTTP | Meaning |
|---|---|---|
NO_GRANT | 404 (403 on the MCP server endpoint) | No live grant. Same answer whether the credential exists or not |
GRANT_EXPIRED | 403 | The grant lapsed |
GRANT_TOOLS_ONLY | 403 | The grant lacks value. "This grant does not allow reading the credential value; it can only be used through MCP access." |
GRANT_NOT_FOR_TOOLS | 403 | The grant lacks tools (MCP server endpoint) |
SERVER_NOT_GRANTED | 403 | The MCP grant does not cover the MCP server |
SERVER_NOT_FOUND | 404 | The credential has no MCP server of that name |
GRANT_REQUIRED | 403 | You need a live grant of your own to pass it on. Also when the stored value is no longer the creation the access was made for |
GRANT_USES_EXCEEDED | 403 | A key or agent asked for uses with no overlap with the grant it copies from. A partial overlap is cut down silently. An MCP-only grant cannot be passed to a key |
GRANT_SERVERS_EXCEEDED | 403 | Same, for servers |
QUOTA_EXCEEDED | 403 | You reached the cap for that kind of object (credentials, agents, keys, policies). Adds entityType and limit. Not retryable: delete one first |
RESERVED_SERVICE_NAME | 400 | The credential name is reserved |
INVALID_GRANT_USES | 422 | uses empty, unknown, or tools without an MCP server on the credential; or uses sent on a key grant |
INVALID_GRANT_SERVERS | 422 | servers without tools, empty, or naming an MCP server the credential lacks |
NO_FIELDS | 400 | A PATCH named no field to change |
GRANT_ENTRIES_DIFFER | 409 | One expiry for the whole grant would shorten a part that ends later. Send entries to change each part |
ENTRY_NOT_HELD | 422 | entries named a part the grant does not hold |
ENTRIES_OR_FIELDS | 422 | A PATCH sent entries and uses, servers or an expiry together |
REQUESTED_ITEM_MISSING | 422 | A request named a credential, agent, API key, MCP server or policy that does not exist. The message lists them |
AMBIGUOUS_POLICY_NAME | 409 | Two policies share the name a request used. Rename one in the web app |
POLICY_NAME_TAKEN | 409 | A request asked to create a policy with a name that exists |
RESERVED_NAME | 422 | An agent or API key can't be named self: requests use it to mean the sender |
TARGET_CHANGED / POLICY_CHANGED | 409 (in an approve result) | The agent, API key or policy behind a name changed after the request was made. That action did nothing |
MANUAL_GRANT_IN_PLACE / AUTO_GRANT_IN_PLACE | 409 | A key or agent tried to replace one grant kind with the other. A human can |
WEB_CONSOLE_REQUIRED | 403 | A Who can read policy makes this change web-app only |
POLICY_DENIED | 403 / 429 | A policy refused. See Denials. On your own read (reveal with POST /api/vault/credential-ticket, GET /api/tokens/{service}, the TOTP code) the same fields sit under detail, with a message |
VAULT_LOCKED | 423 | You stopped all access |
Grant endpoints: Grants API.
Credentials, labels, MCP servers
| Code | HTTP | Meaning |
|---|---|---|
INVALID_SERVICE | 400 | Credential name has / or characters not allowed |
INVALID_LABELS | 422 | Label not 1-32 of a-z, 0-9, -; not a list; or more than 10 |
INVALID_ENTITY_TYPE | 400 | entityType is not credential, agent or api_key |
INVALID_ENTITY_ID | 400 | entityId empty or over 128 characters |
MCP_SERVERS_CAP | 422 | More than 5 MCP servers on a credential |
MCP_SERVER_NAME_INVALID | 422 | Name not ^[a-z0-9][a-z0-9_-]{0,31}$ |
MCP_SERVER_NAME_DUPLICATE | 422 | Two MCP servers share a name |
MCP_SERVER_HEADERS_REQUIRED | 422 | No headers, or none contains ${TOKEN} (${AGENT_SESSION} on a sign-in credential) |
MCP_SERVER_HEADER_INVALID | 422 | Bad header name, or control characters in a value |
MCP_SERVER_LITERAL_CREDENTIAL | 422 | A credential-like header holds a literal value instead of ${TOKEN} (${AGENT_SESSION} on a sign-in credential) |
MCP_SERVER_INVALID | 422 | template is not a short slug |
SERVICE_NOT_HOSTABLE | 422 | The credential name cannot appear in a URL |
MCP_SERVER_NOT_FOUND | 404 | No such MCP server (or a malformed name on the endpoint) |
MCP_SERVER_CHANGED | 409 | The MCP server changed while its tools were fetched |
VALUE_NOT_ALLOWED | 400 | A key tried to send a credential value through Token Vault. Use a store ticket |
TOKEN_OWNED | 409 | The name belongs to someone else, or still has bindings |
TOKEN_EXISTS | 409 | tvault add (a store ticket with intent: "create") named a credential that already exists. Nothing was replaced. Use tvault set to rotate the value |
TOKEN_OWNERSHIP_UNAVAILABLE / TOKEN_EXISTENCE_CHECK_UNAVAILABLE | 503 | Could not verify. Nothing was changed. Retry |
Details: Labels API, MCP servers API.
Token Vault sign-in and old MCP connections
For Token Vault sign-in credentials and the old MCP connection URLs.
| Code | HTTP | Meaning |
|---|---|---|
NAME_TAKEN | 409 | POST /api/tokens/sign-in: the name exists, of any kind. Also reported by Convert for one connection |
USE_SIGNIN_ROUTE | 400 | POST /api/tokens with tokenType: "TVSignIn". Use POST /api/tokens/sign-in |
SIGNIN_NO_VALUE | 409 | A value action on a sign-in credential: credential ticket, store ticket, OAuth connect, rotate, refresh, TOTP code |
SIGNIN_TOOLS_ONLY | 409 | A grant on a sign-in credential with value, or any key grant. Only MCP for an agent |
SIGNIN_URL_ON_TOKEN_VAULT | 422 | The URL of a sign-in MCP server is a Token Vault address |
SIGNIN_SESSION_REFUSED | 403 | The agent cannot get a pass (suspended, expired, no mcp:use, deleted) |
SIGNIN_SESSION_UNAVAILABLE | 503 | The lock state could not be read. Retry-After: 60. (Stopped access is VAULT_LOCKED, 423.) |
SIGNIN_SSRF_GUARD | 502 | The address of the sign-in MCP server is refused |
SIGNIN_UPSTREAM_ERROR | 502 | The call to the sign-in MCP server failed |
SIGNIN_SERVER_NOT_AGGREGATED | tool error | A sign-in MCP server was asked for on /api/agents/mcp. Use its own URL |
PROXY_CONFIG_INVALID | 500 | An MCP server config fits neither the ${TOKEN} path nor the ${AGENT_SESSION} path. Refused, not guessed |
MCP_KEY_RETIRED | 410 | An old mcp_ app key past its 90 days |
PROXY_CREATE_REMOVED | 410 | POST /api/proxy. Add an MCP server to a credential instead |
PROXY_GROUPS_REMOVED | 410 | A write to proxy folders |
PROXY_FROZEN | 409 | A change to a converted old MCP connection. Only {"status":"suspended"} is allowed |
PLAN_CHANGED | 409 | Convert: your account changed since the preview. Preview again |
INVALID_OPT_IN | 422 | Convert: an opt-in the preview did not offer |
MCP_TOGGLE_REMOVED | 400 | mcpEnabled: false on an agent. The per-agent MCP switch is gone |
SCOPE_RETIRED | 400 | Adding proxies:read or proxies:write to a key or agent. retiredScopes lists them |
Convert reports NAME_BUSY, PROXY_GONE and CONVERT_FAILED per connection under errors. Skip codes are on Old MCP connection URLs.
Agents
| Code | HTTP | Meaning |
|---|---|---|
AGENT_NAME_TAKEN | 409 | Another agent has this name, or one you did not create |
AMBIGUOUS_AGENT_NAME | 409 | More than one agent has this name. Use the id |
AGENT_NAME_CONFLICT | 409 | A concurrent create won. Try again |
AGENT_NOT_FOUND | 404 | POST /api/agents/connect without createIfMissing |
OAuth apps and refresh
| Code | HTTP | Meaning |
|---|---|---|
OAUTH_CONNECT_DISABLED | 410 | Connecting through Token Vault's own OAuth app is off. Use your own OAuth app |
UNKNOWN_PROVIDER | 404 | Provider is not google, github or spotify |
INVALID_CLIENT_ID | 400 | Not a valid OAuth client id |
INVALID_SCOPE | 400 | A scope has characters that are not allowed |
CLIENT_ID_MISSING | 400 | Save the provider's client id first |
WEBHOOK_UNSUPPORTED | 409 | The webhook lacks the oauth-callback capability. Update it |
TOO_MANY_PENDING | 429 | 20 connects in flight. Wait a few minutes |
REFRESH_RECONNECT_REQUIRED | 409 | The provider revoked the grant. Reconnect, or pass recheck=true |
REFRESH_NO_TOKEN | 404 | No token stored on the webhook |
REFRESH_NO_REFRESH_TOKEN | 412 | The stored token has no refresh token |
REFRESH_FAILED_AT_WEBHOOK | 424 | The webhook answered but the refresh failed |
WEBHOOK_RATE_LIMITED | 429 | Your webhook is rate-limiting Token Vault |
Details: OAuth apps API, Token refresh.
Webhook
| Code | HTTP | Meaning |
|---|---|---|
WEBHOOK_NOT_CONFIGURED | 502 | No webhook bound |
WEBHOOK_UNAVAILABLE | 502 | Could not be reached |
WEBHOOK_AUTH_FAILED | 502 | The webhook rejected Token Vault's signed request |
WEBHOOK_REDIRECT_BLOCKED | 502 | The webhook answered with a redirect, which is never followed |
UPSTREAM_REDIRECT_BLOCKED | 502 | The MCP server redirected to another address. Neither your webhook nor Token Vault follows it. Set the MCP server's URL to its final address |
WEBHOOK_CIRCUIT_OPEN | 503 | Failed repeatedly and paused. Retry-After is set |
Webhook-side error codes are on Webhook error codes.
CLI exit codes
tvault maps the server code first and the HTTP status second. Branch on the exit code in scripts.
| Exit | Kind | Arises from |
|---|---|---|
| 0 | success | Success. Also argument-count errors, which print help |
| 1 | user | Bad arguments or validation, not found, aborted prompt, any other 4xx (400, 403, 404, 409, 422), GRANT_REQUIRED, UNKNOWN_SCOPE, INVALID_EXPIRY |
| 2 | auth | No active context, context not found, any 401, a failed session refresh, REAUTH_REQUIRED |
| 3 | network | Cannot reach the API or the webhook |
| 4 | server | 5xx, a malformed ticket response, a webhook that refused the store ticket |
| 5 | vault locked | 423 or VAULT_LOCKED |
| 6 | empty | The credential exists but has no value (get --check, empty webhook token, missing composite field) |
| 7 | rate limited | 429, including a policy rate_limit denial. GETs make 3 attempts in all, honouring Retry-After up to 10 s |
| 8 | scope denied | SCOPE_DENIED (also a lookup by name when listing is denied) |
| 9 | human only | HUMAN_ONLY; a classic agent on a management route; a non-admin mcp-servers overwrite |
| 10 | key expired | KEY_EXPIRED |
| 11 | key suspended | KEY_SUSPENDED or AGENT_INACTIVE |
| 12 | invalid key | INVALID_KEY |
| 13 | policy denied | POLICY_DENIED (a policy rate_limit denial that arrives as 429 stays 7). CLI 0.14.0 and later; earlier versions exit 1 |
| 14 | no grant | NO_GRANT, GRANT_EXPIRED, GRANT_TOOLS_ONLY. CLI 0.14.0 and later; earlier versions exit 1 |
printf %s "$V" | tvault add stripe
case $? in
0) echo ok ;;
8) echo "key needs tokens:create" ;;
10) echo "key expired, rotate it" ;;
11) echo "key or agent suspended" ;;
12) echo "bad key" ;;
esacA presence probe that never prints the value:
tvault get github --check >/dev/null 2>&1 && echo presentRun tvault explain <CODE> for what a code means and how to fix it. Full CLI reference: tvault CLI.
Ready to try it?
Sign in with Google or email. Your credentials stay on your own webhook, and the quickstart gets Claude Code making its first MCP tool call in about 15 minutes.
Denials
The full contract for refused requests, covering policy denial bodies for agents versus humans, access and rate-limit codes, JSON-RPC errors on MCP routes, and the tvault CLI denied and hint lines.
Grants API
Reference for the access endpoints that give agents and keys a credential, covering uses, MCP servers, expiry, find-or-create connect, revoke-all and the account-wide grants list.