Token VaultDocs
Your Webhook

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

PathLimitOn exceed
GET /api/agents/credentials60/min per agent429 + Retry-After
MCP server calls (/api/mcp/{service}/{server}) and legacy proxies300/min per MCP server or proxy429 / JSON-RPC -32029
POST /api/tokens/{service}/refresh10/hour per token429
MCP handshakes120/min429
Credential history20/min429
Key reveal20/hour429
Calls for a service with no grant10/min per agent (never a penalty strike)404/429
Whole account600 to 3000/min, scaled by your agents429

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:

wrangler.toml
[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 /data volume (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.

On this page