Hardening your webhook
The rate limits Token Vault enforces for you, plus the webhook-side limits, kill switch and Cloudflare rules worth adding.
Every credential fetch and tool call lands on infrastructure you pay for. A crash-looping container that re-fetches a credential on every restart can burn a Worker's daily quota in minutes, with authenticated, policy-passing traffic that looks like no attack. These layers stop that. Exact numbers: rate limits.
What Token Vault enforces by default
| Path | Limit | On exceed |
|---|---|---|
GET /api/agents/credentials | 60/min per agent | 429 + Retry-After |
MCP server calls (/api/mcp/{service}/{server}) and legacy proxies | 300/min per MCP server or proxy | 429 / JSON-RPC -32029 |
POST /api/tokens/{service}/refresh | 10/hour per token | 429 |
| MCP handshakes | 120/min | 429 |
| Credential history | 20/min | 429 |
| Key reveal | 20/hour | 429 |
| Calls for a service with no grant | 10/min per agent (never a penalty strike) | 404/429 |
| Whole account | 600 to 3000/min, scaled by your agents | 429 |
Repeated denials (bad keys, policy denials, expired grants) feed a penalty box: a lockout that starts at 1 second, doubles per strike and caps at 15 minutes. Requests are refused before any policy or webhook work.
Token Vault also protects your webhook. A 429 from it is never retried, and its Retry-After is passed to the agent. After repeated failures a circuit breaker opens (WEBHOOK_CIRCUIT_OPEN, 503) and Token Vault stops calling it for a cool-off.
For tighter limits on one agent, credential, label or MCP server, attach a rate_limit policy. Both apply.
Have your webhook return 429
429 with Retry-After is a first-class response in the contract. The reference webhook ships a token bucket, per client IP and per isolate:
[vars]
TV_RATE_LIMIT_PER_MINUTE = "300"Each isolate counts alone, so treat it as damage-bounding, not a global limit.
Add a Cloudflare rate-limiting rule
The global limit lives at the edge. It also covers traffic that never touches Token Vault: agents follow a 307 and then talk to your webhook directly, so their retries are invisible to Token Vault.
Dashboard > your zone > Security > WAF > Rate limiting rules:
- If hostname equals your webhook host
- Rate 300 requests per 1 minute per IP
- Then block for 1 minute
Set a budget alert
Limits bound the damage. An alert tells you it is happening. On Cloudflare: Notifications > Usage Based Billing / Workers usage. On Cloud Run or Lambda, use budget alerts. Pair it with Activity filtered to outcome=denied or error.
Other levers
- Encrypt at rest with the reference webhook, and back up
TV_WEBHOOK_SEED(Workers) or the/datavolume (Docker, Node). - Ticket constraints (
ticketConstraints, spec 2.6.0): store and credential tickets can carry the credential's creation id (cid) that your webhook checks. - Kill switch: Stop all access refuses new requests in one click.
- IP allowlist (prod): Token Vault calls from
34.12.35.243.
Client side
tvault honours Retry-After on 429. It makes up to 3 attempts at a GET (2 retries) when the wait is 10 seconds or less, otherwise exits 7, and never retries a write. Do the same in scripts: a 429 means sleep, then retry.
Update your webhook
Pull in the latest reference webhook release with the Cloudflare update Action, a manual script, or a Docker redeploy.
Agent Credentials API
Reference for GET /api/agents/credentials, covering accepted keys, the 307 redirect and ticket, list mode, grant checks and the error catalogue.