Token VaultDocs
ReferenceWebhook Protocol

Request Authentication

How Token Vault signs its requests to your webhook with HMAC-SHA256, how to verify them, and which endpoints use other authentication.

Every request from the Token Vault backend to your webhook, except /v1/exchange, carries an HMAC-SHA256 signature. Tickets, which agents and browsers present, are a separate mechanism: see Tickets and capabilities.

Signature flow

Loading diagram...
A signed request
POST /v1/storage HTTP/1.1
Host: webhook.example.com
Content-Type: application/json
X-TokenVault-Signature: sha256=9f2c...e41a
X-TokenVault-Timestamp: 1708300000
X-TokenVault-Request-Id: req_3fa91c07be22

{"requestId":"req_3fa91c07be22","operation":"list","collection":"tokens","attemptId":"req_3fa91c07be22"}

The signature is shortened and the example is illustrative. Token Vault adds attemptId as the last key of every body before it signs, so the signature covers it.

HeaderValue
X-TokenVault-Signaturesha256= followed by the lowercase hex HMAC-SHA256 digest
X-TokenVault-TimestampUnix time in seconds
X-TokenVault-Request-Idreq_ plus 12 hex characters
Content-Typeapplication/json

Verify

The signed string is {timestamp}.{raw_json_body}. The key is the secret that /v1/exchange returned.

Verification
signature = request.headers["X-TokenVault-Signature"]   # "sha256=abc123..."
timestamp = request.headers["X-TokenVault-Timestamp"]   # "1708300000"
raw_body = request.body                                  # bytes as received

signing_payload = f"{timestamp}.{raw_body.decode('utf-8')}"
expected = hmac_sha256(hmac_secret, signing_payload.encode("utf-8")).hexdigest()

if not constant_time_compare(expected, signature[7:]):   # strip "sha256="
    return 401  # {"error": "auth_failed", "message": "HMAC signature invalid"}

Verify the raw bytes

Token Vault serialises the body as compact JSON with no whitespace (json.dumps(body, separators=(",", ":"))). Verify the bytes you received. If you re-serialise, use the same compact form.

Replay prevention

  • Reject a request whose timestamp is more than 300 seconds from your clock.
  • Every request body carries attemptId, equal to that attempt's X-TokenVault-Request-Id header. The header is not covered by the HMAC, but the body is. After the signature check, reject (401) a request whose body attemptId is present and differs from the header. Use attemptId as the replay nonce: remember it for the timestamp window and refuse a repeat. A webhook that rejects a repeat answers 401, and the caller sees WEBHOOK_AUTH_FAILED.
  • A retry carries a fresh attemptId (and header id, timestamp and signature), so tracking attemptId never rejects a retry. The body requestId is the same on every attempt of one call: use it to correlate attempts, not to deduplicate.
  • A request with no attemptId comes from an older Token Vault. Fall back to the header id.

Which endpoints use which authentication

EndpointAuthentication
POST /v1/exchangeOne-time code in the body. Called before the HMAC secret exists
POST /v1/healthHMAC
GET /v1/health, HEAD /v1/healthNone. HEAD is the connection warm-up probe Token Vault sends before a credential fetch and on dashboard loads. It carries no HMAC
POST /v1/storage, /v1/refresh-notify, /v1/admin/migrateHMAC
POST /v1/refresh (legacy tv-refresh)HMAC
POST /v1/proxyHMAC plus a proxy ticket in the body
GET|POST /v1/credential, POST /v1/store, GET|POST /v1/totp-codeTicket, no HMAC headers
GET /v1/oauth/start, GET /v1/oauth/callbackState ticket plus the tv_oauth_state cookie
GET /v1/register-url, GET /bindOperator helpers, not called by Token Vault. Sealed after the first bind

Every other request must pass HMAC verification.

The HMAC secret is the identity of your account on this webhook. Token Vault holds it to sign requests and tickets, so it is the authority for every read your webhook serves: a ticket that verifies is honoured with no other check. It is not an encryption key. The reference webhook keeps its encryption key itself, and Token Vault never receives it. Limit what the secret can authorise: remove the legacy tv-refresh capability (see Token refresh), and block Token Vault's egress IP on the direct-access endpoints (see Security).

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