Token VaultDocs
Your Webhook

Self-host your webhook

Run the Token Vault webhook yourself with Docker or Node, expose it over HTTPS, and bind it to your account.

Your webhook is the data plane: the small server that holds your credentials. Token Vault does not run it and has no access to what is stored behind it. It only calls the public URL. Self-hosting means you run that server on infrastructure you control. The setup wizard offers two deploy methods: Deploy to Cloudflare Workers and Self-host.

Prefer one click?

Deploy to Cloudflare Workers needs no server to keep online. Self-host if you already run a homelab box, VPS or cloud account, or you are writing a webhook of your own.

Requirements

  • A public HTTPS URL. localhost, 127.0.0.1 and private IP ranges are refused at bind time. A tunnel (ngrok, Cloudflare Tunnel) fixes a machine with no public IP.
  • Persistent storage. Your webhook holds credentials and an audit copy. Lose the volume and you lose every stored credential.
  • Durable keys. On Cloudflare Workers the keys derive from one root secret, TV_WEBHOOK_SEED: generate it once and keep it across redeploys. On Docker and Node there is no seed. The webhook generates random keys into /data/tokenvault_store.json, so back up the /data volume. Never send either anywhere.
  • CORS for the Token Vault origin. The browser calls /v1/credential, /v1/store and /v1/totp-code directly. Allow your Token Vault frontend origin or those calls fail while the webhook looks healthy.
  • The contract. Spec 2.12.0 at tokenvault.uk/llm.txt. Always required: POST /v1/exchange, GET|POST /v1/health. Everything else is a capability: storage, credential, store, proxy, refresh, totp, ticketConstraints, oauth-callback.

Encryption at rest is your choice

Token Vault does not require or check it. The reference webhook encrypts at rest with a key it holds itself (derived from the seed on Workers). Use that for anything beyond a local test.

Runtimes

  • Docker: clone c-lgrant/tvault, then in examples/webhook run docker compose up -d --build. This builds the TypeScript reference (examples/webhook) on your machine. It runs on a homelab box, VPS, Cloud Run, or Lambda with a container runtime. There is no published image.
  • Node from source: clone the same repo, then in examples/webhook run the command under Run with Node.
  • Your own: any stack that implements llm.txt. A conformance suite lives in examples/webhook/test/conformance/.

Run with Node

TOKENVAULT_FRONTEND_URL is required. Without it the webhook refuses to start. The keys and data default to /data, so on a laptop point them at a folder you can write to:

cd tvault/examples/webhook
npm install
TOKENVAULT_FRONTEND_URL=https://tokenvault.uk \
TOKENVAULT_STORE_PATH=./data/store.json \
TOKENVAULT_KV_STORE_PATH=./data/kv.json \
npm run dev:node

It listens on port 8080 (PORT changes it). Put a tunnel or a reverse proxy with HTTPS in front before you bind.

Settings

The reference webhook reads these environment variables. Docker compose passes on TOKENVAULT_FRONTEND_URL (default https://tokenvault.uk), TOKENVAULT_IP, OAUTH_PROVIDERS_JSON and the tunnel variables only. To set another one in Docker, add it to the environment list in docker-compose.yml.

VariableRequiredDefaultPurpose
TOKENVAULT_FRONTEND_URLYesnoneThe Token Vault frontend origin, for example https://tokenvault.uk. Use https://tokenvault.one for a dev account
TOKENVAULT_STORE_PATHNo/data/tokenvault_store.jsonWhere the generated keys are kept (Node and Docker)
TOKENVAULT_KV_STORE_PATHNo/data/tokenvault_kv_store.jsonWhere credentials and metadata are kept (Node and Docker)
TOKENVAULT_IPNononeToken Vault's egress IP. It is added to DENY_IPS. See Security
DENY_IPSNononeComma-separated IPs refused on /v1/credential, /v1/store and /v1/totp-code
OAUTH_PROVIDERS_JSONNononeProvider client secrets for own-app OAuth and refresh
TV_REFRESH_ENABLEDNoofftrue turns on the legacy tv-refresh capability. See Token refresh
AUDIT_RETENTION_DAYSNo0 (keep everything)Delete audit events older than this many days
TV_PROXY_ALLOW_PRIVATENoofftrue lets /v1/proxy call private addresses. Set it only if an MCP server is on your own network
TV_PROXY_ALLOWED_ORIGINSNonone (any public origin)JSON object of credential name to the origins /v1/proxy may send it to, for example {"github":["https://api.githubcopilot.com"]}. "*" applies to every credential. When set, a credential with no entry is refused. A value that is not valid stops the webhook at start
TV_REPLAY_NONCESNoD1 (Workers)Workers only. cache keeps one-shot ticket nonces in the per-colo cache (best effort) instead of D1 (atomic, one row write for each ticket)

Expose it

ngrok (needs a static domain)
git clone https://github.com/c-lgrant/tvault.git && cd tvault/examples/webhook
NGROK_AUTHTOKEN=<your-ngrok-token> NGROK_URL=<your-domain>.ngrok-free.app \
TUNNEL=ngrok docker compose up --build
Cloudflare Tunnel (no open ports)
git clone https://github.com/c-lgrant/tvault.git && cd tvault/examples/webhook
CF_TUNNEL_TOKEN=<your-tunnel-token> TUNNEL=cloudflared docker compose up --build

A static ngrok domain matters: a random one changes on every reconnect and breaks the binding. Get the tunnel token under Zero Trust > Networks > Tunnels. The named volume keeps your keys stable across restarts. Without it a redeploy re-provisions keys and breaks the binding.

Once it is up, tvault webhook bind binds it and tvault webhook status shows its health.

Bind it

Continue the setup wizard, enter the URL at Enter URL, or open your webhook's own /bind page.
Your webhook mints a one-time link and sends you to Token Vault's confirm screen.
Check the URL on that screen. It is the anti-phishing control.
Press Connect Webhook. Token Vault calls /v1/exchange once and receives the HMAC secret.

Details: Binding your webhook.

On this page