Token VaultDocs
Reference

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.

FamilyStatusBodyExample codes
Policy denial403, or 429 for rate_limitTop-level JSONPOLICY_DENIED
Rate limit429Top-level JSONRATE_LIMITED
Access refusal (Token Vault's own gates)4xx, 5xx{"detail": {"code", "message"}}NO_GRANT, GRANT_EXPIRED, GRANT_TOOLS_ONLY, SCOPE_DENIED
MCP route errors200 (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.

403 for an agent or a key
{
  "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
}
FieldTypeAlwaysNotes
errorstringyesAccess denied by policy
policystringyesThe policy's name
rulestringyesRule type: time_window, ip_allowlist, rate_limit, max_usage, geo_restrict, access_channel, manual_approval
reasonstringyesHuman-readable sentence
codestringyesPOLICY_DENIED
retryAfterintegernoSeconds. 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. A Retry-After header carries the same number.
  • time_window (403): seconds until the window opens. No Retry-After header.

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.

429 for the owner's tvault login
{
  "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 }
}
FieldTypeNotes
policyIdstringThe policy's id (32 hex characters). Use it with tvault policy detach
appliedViaobjectHow the policy reached this request: {type, id} plus carriedBy for labels
ruleSettingsobjectThe 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.

ruleruleSettings
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 with isError: true. structuredContent holds code: "POLICY_DENIED", message, policy, and retryAfter as above. The caller here is always an agent, so policyId, appliedVia and ruleSettings are never returned on this endpoint. The owner sees them in Activity.
  • /api/mcp/{service}/{server} POST: a rate_limit denial is a JSON-RPC error -32029 (HTTP 429) with data.code: "POLICY_DENIED". Any other rule returns the plain 403 body 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.

codeHTTPMeaningFix
MISSING_KEY401No key sentSend Authorization: Bearer ...
INVALID_KEY401, or 403 for a classic tvagent_ keyUnknown, revoked or rotated-out keyUse the current key
KEY_EXPIRED401The key or scoped agent is past its expiryRotate it or make a new one
KEY_SUSPENDED403The tvkey_ key is suspendedResume it
AGENT_INACTIVE403Agent is suspended or deletedResume the agent
WRONG_RESOURCE401A tvsess_ was issued for a different MCP URLSign in again for this URL
IDENTITY_ONLY_SESSION403The session proves identity only, such as the pass a Token Vault sign-in MCP server gets. Only introspection accepts itUse an agent session
SCOPE_DENIED403The caller lacks a scope. Adds missingScope and missingScopesAdd the scope, see Scopes
HUMAN_ONLY403Only a signed-in human may do thisDo it in the web app or an admin login
NO_GRANT404 (403 on the MCP server endpoint)No live grant. The same answer whether the credential exists or notGrant access
GRANT_EXPIRED403The grant lapsedGrant again
GRANT_TOOLS_ONLY403The grant allows MCP but not the valueAdd Value to the grant
GRANT_NOT_FOR_TOOLS403The grant is value-only (MCP server endpoint)Add MCP
SERVER_NOT_GRANTED403The MCP grant does not cover this MCP serverEdit the grant's MCP servers
SERVER_NOT_FOUND404The credential has no MCP server of that nameCheck the name
GRANT_USES_EXCEEDED403A 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_EXCEEDED403Same, for serversNarrow the request
GRANT_REQUIRED403You need a live grant of your own on the credentialGet one
VAULT_LOCKED423You stopped all accessResume access
WEB_CONSOLE_REQUIRED403A Who can read policy makes this change web-app onlyUse the web app
REAUTH_REQUIRED401A fresh sign-in (5 minutes) is neededSign in again
SIGNIN_SESSION_REFUSED403A 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_UNAVAILABLE503A 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_ONLY409A grant on a Token Vault sign-in credential asked for Value, or was for a keyGrant MCP to an agent
SIGNIN_NO_VALUE409A value action on a sign-in credential. It holds no valueUse MCP access
MCP_KEY_RETIRED410An old mcp_ app key past its 90 daysConnect through the MCP server URL
PROXY_FROZEN409A change to a converted old MCP connectionEdit the MCP server instead
PROXY_CREATE_REMOVED410An attempt to make an old MCP connectionAdd an MCP server to a credential
MCP_TOGGLE_REMOVED400An attempt to switch an agent's MCP off. The switch is goneRevoke its MCP grants or suspend it
WEBHOOK_NOT_CONFIGURED502No webhook boundBind one
WEBHOOK_UNAVAILABLE502The webhook could not be reachedCheck it is up
WEBHOOK_CIRCUIT_OPEN503The webhook failed repeatedly and is paused. Retry-After setWait, then retry

Branch examples:

403 GRANT_TOOLS_ONLY
{
  "detail": {
    "code": "GRANT_TOOLS_ONLY",
    "message": "This grant does not allow reading the credential value; it can only be used through MCP access."
  }
}
403 SCOPE_DENIED
{
  "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

429 RATE_LIMITED
{ "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

CodeWhereMeaning
-32001HTTP 401 or 403Authentication or authorisation failed. 401 includes WWW-Authenticate: Bearer resource_metadata="..."
-32029HTTP 429Rate limited or policy rate_limit. error.data is { "code": "RATE_LIMITED" or "POLICY_DENIED", "retryAfter": N }, with a Retry-After header
-32600HTTP 200Invalid 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.

-32029 on /api/mcp/github/github
{
  "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 admin login, a policy denial reads out the rule, the policy and where it applies (from appliedVia and ruleSettings).
  • An agent or key gets the policy name, rule type and reason, plus Try again in Ns. when retryAfter is 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.
Agent context, no grant
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.

On this page