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.1and 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/datavolume. Never send either anywhere. - CORS for the Token Vault origin. The browser calls
/v1/credential,/v1/storeand/v1/totp-codedirectly. 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 inexamples/webhookrundocker 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/webhookrun the command under Run with Node. - Your own: any stack that implements
llm.txt. A conformance suite lives inexamples/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:nodeIt 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.
| Variable | Required | Default | Purpose |
|---|---|---|---|
TOKENVAULT_FRONTEND_URL | Yes | none | The Token Vault frontend origin, for example https://tokenvault.uk. Use https://tokenvault.one for a dev account |
TOKENVAULT_STORE_PATH | No | /data/tokenvault_store.json | Where the generated keys are kept (Node and Docker) |
TOKENVAULT_KV_STORE_PATH | No | /data/tokenvault_kv_store.json | Where credentials and metadata are kept (Node and Docker) |
TOKENVAULT_IP | No | none | Token Vault's egress IP. It is added to DENY_IPS. See Security |
DENY_IPS | No | none | Comma-separated IPs refused on /v1/credential, /v1/store and /v1/totp-code |
OAUTH_PROVIDERS_JSON | No | none | Provider client secrets for own-app OAuth and refresh |
TV_REFRESH_ENABLED | No | off | true turns on the legacy tv-refresh capability. See Token refresh |
AUDIT_RETENTION_DAYS | No | 0 (keep everything) | Delete audit events older than this many days |
TV_PROXY_ALLOW_PRIVATE | No | off | true lets /v1/proxy call private addresses. Set it only if an MCP server is on your own network |
TV_PROXY_ALLOWED_ORIGINS | No | none (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_NONCES | No | D1 (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
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 --buildgit clone https://github.com/c-lgrant/tvault.git && cd tvault/examples/webhook
CF_TUNNEL_TOKEN=<your-tunnel-token> TUNNEL=cloudflared docker compose up --buildA 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
/bind page./v1/exchange once and receives the HMAC secret.Details: Binding your webhook.