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.
Token Vault refuses a request in one of four ways. Each has a fixed body shape. Branch on code, never on the message text.
| Family | Status | Body | Example codes |
|---|---|---|---|
| Policy denial | 403, or 429 for rate_limit | Top-level JSON | POLICY_DENIED |
| Rate limit | 429 | Top-level JSON | RATE_LIMITED |
| Access refusal (Token Vault's own gates) | 4xx, 5xx | {"detail": {"code", "message"}} | NO_GRANT, GRANT_EXPIRED, GRANT_TOOLS_ONLY, SCOPE_DENIED |
| MCP route errors | 200 (tool result) or 4xx (JSON-RPC error) | JSON-RPC | -32001, -32029, structuredContent.code |
Every denial is also recorded as an event in Activity. The owner reads the full detail there.
Policy denials
A policy said no. Status is 403, except a rate_limit rule, which is 429.
{
"error": "Access denied by policy",
"policy": "office-hours",
"rule": "time_window",
"reason": "Access denied: current time 21:14 Europe/London is outside allowed window 09:00–18:00",
"code": "POLICY_DENIED",
"retryAfter": 42360
}| Field | Type | Always | Notes |
|---|---|---|---|
error | string | yes | Access denied by policy |
policy | string | yes | The policy's name |
rule | string | yes | Rule type: time_window, ip_allowlist, rate_limit, max_usage, geo_restrict, access_channel, manual_approval |
reason | string | yes | Human-readable sentence |
code | string | yes | POLICY_DENIED |
retryAfter | integer | no | Seconds. See below |
retryAfter appears when the rule knows when it lets the caller in again:
rate_limit(429): seconds until the window rolls, clamped to 1 to 900. ARetry-Afterheader carries the same number.time_window(403): seconds until the window opens. NoRetry-Afterheader.
manual_approval denies every request, because no approval channel is wired up yet. The reason says so.
What a human sees
A human caller gets three more fields. A human is a signed-in web session, or the owner's own tvault login (an admin context). Agents, keys and OAuth sessions never get them: knowing which label carries a rule, or which countries are allowed, would help route around the policy.
{
"error": "Access denied by policy",
"policy": "burst-60",
"rule": "rate_limit",
"reason": "Rate limit exceeded: 60 requests per minute",
"code": "POLICY_DENIED",
"retryAfter": 12,
"policyId": "3f9c1ae2b7d44e0f8a21c5d6e9b07a13",
"appliedVia": { "type": "label", "id": "ai", "carriedBy": ["token"] },
"ruleSettings": { "limit": 60, "windowSeconds": 60 }
}| Field | Type | Notes |
|---|---|---|
policyId | string | The policy's id (32 hex characters). Use it with tvault policy detach |
appliedVia | object | How the policy reached this request: {type, id} plus carriedBy for labels |
ruleSettings | object | The denying rule's owner-written settings. Shape depends on rule |
appliedVia.type is the attachment: agent, token (a credential), api_key, mcp_server (id is {service}:{server}), label, or the legacy proxy and token_group. Convert copies the policies of an old MCP connection to its mcp_server, so proxy only shows for one not yet converted. For a label, carriedBy lists which sides carry it: agent, token, api_key. A label carried by both sides is evaluated once.
rule | ruleSettings |
|---|---|
rate_limit | { "limit": 60, "windowSeconds": 60 } |
time_window | { "days": [1,2,3,4,5], "start": "09:00", "end": "18:00", "timezone": "Europe/London" } |
geo_restrict | { "mode": "allow", "countryCodes": ["GB","IE"] } |
ip_allowlist | { "cidrCount": 3 } (the ranges are never returned) |
access_channel | { "mode": "allow", "channels": ["cli","agent"] } |
max_usage | { "max": 5, "used": 5 } |
Channels are web, cli, agent, key and proxy (shown as MCP tools).
On MCP routes
/api/agents/mcp: the denial is a tool result withisError: true.structuredContentholdscode: "POLICY_DENIED",message,policy, andretryAfteras above. The caller here is always an agent, sopolicyId,appliedViaandruleSettingsare never returned on this endpoint. The owner sees them in Activity./api/mcp/{service}/{server}POST: arate_limitdenial is a JSON-RPC error-32029(HTTP 429) withdata.code: "POLICY_DENIED". Any other rule returns the plain403body above.
Access refusals
Token Vault's own gates. Body: {"detail": {"code": "...", "message": "..."}}. On /api/agents/mcp the same conditions arrive as JSON-RPC errors or tool results (below). On /api/mcp/{service}/{server}, grant refusals (NO_GRANT, GRANT_EXPIRED, GRANT_NOT_FOR_TOOLS, SERVER_NOT_GRANTED, SERVER_NOT_FOUND) use this same envelope. Only authentication failures there are JSON-RPC -32001.
code | HTTP | Meaning | Fix |
|---|---|---|---|
MISSING_KEY | 401 | No key sent | Send Authorization: Bearer ... |
INVALID_KEY | 401, or 403 for a classic tvagent_ key | Unknown, revoked or rotated-out key | Use the current key |
KEY_EXPIRED | 401 | The key or scoped agent is past its expiry | Rotate it or make a new one |
KEY_SUSPENDED | 403 | The tvkey_ key is suspended | Resume it |
AGENT_INACTIVE | 403 | Agent is suspended or deleted | Resume the agent |
WRONG_RESOURCE | 401 | A tvsess_ was issued for a different MCP URL | Sign in again for this URL |
IDENTITY_ONLY_SESSION | 403 | The session proves identity only, such as the pass a Token Vault sign-in MCP server gets. Only introspection accepts it | Use an agent session |
SCOPE_DENIED | 403 | The caller lacks a scope. Adds missingScope and missingScopes | Add the scope, see Scopes |
HUMAN_ONLY | 403 | Only a signed-in human may do this | Do it in the web app or an admin login |
NO_GRANT | 404 (403 on the MCP server endpoint) | No live grant. The same answer whether the credential exists or not | Grant access |
GRANT_EXPIRED | 403 | The grant lapsed | Grant again |
GRANT_TOOLS_ONLY | 403 | The grant allows MCP but not the value | Add Value to the grant |
GRANT_NOT_FOR_TOOLS | 403 | The grant is value-only (MCP server endpoint) | Add MCP |
SERVER_NOT_GRANTED | 403 | The MCP grant does not cover this MCP server | Edit the grant's MCP servers |
SERVER_NOT_FOUND | 404 | The credential has no MCP server of that name | Check the name |
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) | Narrow the request |
GRANT_SERVERS_EXCEEDED | 403 | Same, for servers | Narrow the request |
GRANT_REQUIRED | 403 | You need a live grant of your own on the credential | Get one |
VAULT_LOCKED | 423 | You stopped all access | Resume access |
WEB_CONSOLE_REQUIRED | 403 | A Who can read policy makes this change web-app only | Use the web app |
REAUTH_REQUIRED | 401 | A fresh sign-in (5 minutes) is needed | Sign in again |
SIGNIN_SESSION_REFUSED | 403 | A sign-in MCP server cannot give this agent a pass (suspended, expired, no mcp:use, deleted) | Resume the agent or add mcp:use |
SIGNIN_SESSION_UNAVAILABLE | 503 | A sign-in MCP server call while the lock state could not be read. Retry-After: 60. (If you stopped all access, the answer is VAULT_LOCKED, 423.) | Retry |
SIGNIN_TOOLS_ONLY | 409 | A grant on a Token Vault sign-in credential asked for Value, or was for a key | Grant MCP to an agent |
SIGNIN_NO_VALUE | 409 | A value action on a sign-in credential. It holds no value | Use MCP access |
MCP_KEY_RETIRED | 410 | An old mcp_ app key past its 90 days | Connect through the MCP server URL |
PROXY_FROZEN | 409 | A change to a converted old MCP connection | Edit the MCP server instead |
PROXY_CREATE_REMOVED | 410 | An attempt to make an old MCP connection | Add an MCP server to a credential |
MCP_TOGGLE_REMOVED | 400 | An attempt to switch an agent's MCP off. The switch is gone | Revoke its MCP grants or suspend it |
WEBHOOK_NOT_CONFIGURED | 502 | No webhook bound | Bind one |
WEBHOOK_UNAVAILABLE | 502 | The webhook could not be reached | Check it is up |
WEBHOOK_CIRCUIT_OPEN | 503 | The webhook failed repeatedly and is paused. Retry-After set | Wait, then retry |
Branch examples:
{
"detail": {
"code": "GRANT_TOOLS_ONLY",
"message": "This grant does not allow reading the credential value; it can only be used through MCP access."
}
}{
"detail": {
"code": "SCOPE_DENIED",
"message": "Missing required scope: tokens:create",
"missingScope": "tokens:create",
"missingScopes": ["tokens:create"]
}
}The full list of HTTP codes, including management endpoints, is on Errors and exit codes.
Rate limits
{ "error": "Rate limit exceeded", "code": "RATE_LIMITED", "retryAfter": 41 }Sent with a Retry-After header. It covers the per-agent floor, the penalty box, the no-grant miss limit and the account ceiling. Wait retryAfter seconds before retrying; a lockout from the penalty box grows each time it is earned again. Numbers: Rate limits.
JSON-RPC errors on MCP routes
| Code | Where | Meaning |
|---|---|---|
-32001 | HTTP 401 or 403 | Authentication or authorisation failed. 401 includes WWW-Authenticate: Bearer resource_metadata="..." |
-32029 | HTTP 429 | Rate limited or policy rate_limit. error.data is { "code": "RATE_LIMITED" or "POLICY_DENIED", "retryAfter": N }, with a Retry-After header |
-32600 | HTTP 200 | Invalid request, for example a JSON-RPC batch |
/api/agents/mcp reports grant, scope, policy and kill-switch refusals as tool results with isError: true and structuredContent.code. See MCP endpoint.
{
"jsonrpc": "2.0",
"id": 3,
"error": { "code": -32029, "message": "Rate limit exceeded by policy.", "data": { "code": "POLICY_DENIED", "retryAfter": 20 } }
}In the tvault CLI
From 0.14.0 the CLI turns a denial into two lines on stderr:
denied: rate limit 60 requests per minute (policy burst-60, on label ai). Try again in 12s. The label is on the credential.
hint: to loosen it, edit policy burst-60 in the web app, or run `tvault policy detach <policy-id> --label ai`- With the owner's own
adminlogin, a policy denial reads out the rule, the policy and where it applies (fromappliedViaandruleSettings). - An agent or key gets the policy name, rule type and reason, plus
Try again in Ns.whenretryAfteris set. - Access refusals (
NO_GRANT,GRANT_EXPIRED,GRANT_TOOLS_ONLY,AGENT_INACTIVE,VAULT_LOCKED,SCOPE_DENIED,RATE_LIMITED,WEBHOOK_CIRCUIT_OPEN) get a sentence for every principal.
denied: no access to github: this key or agent was never granted it.
hint: grant it with `tvault grant <agent> github=value` (a key: `tvault keys grant <key> github`)The exit code does not change: POLICY_DENIED on 403 exits 1, on 429 exits 7. Run tvault explain POLICY_DENIED (or any code) for what it means and how to fix it. All exit codes: Errors and exit codes.
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.
MCP Server Endpoint
Reference for /api/mcp/{service}/{server}, the URL that lets an agent call one credential's MCP server through Token Vault without ever receiving the credential value.
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.