Tollgate documentation
Tollgate is a two-sided micropayments platform built on x402, the open protocol that gives HTTP status code 402 ("Payment Required") a job. Publishers put content, feeds, datasets, and tools behind a per-request price measured in fractions of a cent. AI agents hit the URL over plain HTTP, receive a machine-readable 402 offer, pay in-flight, retry, and get the content with a receipt, all in one request-response loop. No accounts, subscriptions, or checkout forms in the hot path.
The pitch in one line: a price tag, not a paywall. Humans browsing with a normal browser get a free preview page; machines pay per request.
The two sides
Publishers sell. Sign up, drop content in (markdown, JSON, HTML, whole folders), set a per-request price (minimum $0.001), and get a toll road URL of the shape /r/<slug>/<path>. Every unpaid machine request to that URL answers 402 with payment instructions. Earnings accrue to your balance and every paid request lands in your storefront dashboard. You also get a publisher API key (tg_pk_...) for publishing from the CLI or scripts.
Agents buy. Create an agent and it gets an API key (tg_sk_...), a prepaid credit balance, and four server-enforced spending rules: a hard cap per purchase (max_per_request_micro), a daily budget (daily_budget_micro), an ask-above threshold that holds expensive purchases for owner approval (ask_above_micro), and a domain allowlist (allowed_domains). Every attempt, including blocked and held ones, is written to the payments ledger, so the wallet screen shows exactly what the agent tried and why it was stopped.
What works today
Everything below is live in production, not planned:
- Custodial credits (
tollgate-credit), fully live. The Tollgate-native scheme. The payment payload is just the agent API key; settlement is a Postgres transaction that debits the agent, credits the publisher, and writes a ledger row. All amounts are integer micro-dollars (1,000,000 micro = $1). - Real on-chain payments (
exact), live via facilitator. The standard x402 scheme: a gasless EIP-3009transferWithAuthorizationof USDC on Base (default networkbase-sepolia). Tollgate recovers the EIP-712 signature locally with viem, then delegates balance checks, simulation, and broadcasting to a live x402 facilitator (defaulthttps://x402.org/facilitator). Fail-closed: if the facilitator is unreachable, the payment is rejected. Successful settlements carry a real transaction hash you can view on Basescan. - Browser wallet pay. Every marketplace resource page has a "Pay with wallet" button. MetaMask (or any EIP-1193 wallet) signs the
TransferWithAuthorization, Tollgate settles via the facilitator, and the unlocked content renders in place with the receipt. - CLI and SDK.
tollgate publish,tollgate get,tollgate pay,tollgate me,tollgate agents. Pays with either scheme (--scheme credit|exact) and signs on-chain payments locally with viem. The samepayFetchfunction is importable as a library. - MCP server. Three tools (
market_search,buy,wallet_status) that let any MCP-capable agent shop the marketplace and pay over x402 mid-task, with all spending rules enforced server-side. - Scheduler. Agents run on a schedule without you pressing anything:
daily HH:MM(UTC) orevery N(minutes, minimum 5). The in-process scheduler ticks once a minute and claims each slot before running, so restarts cannot double-run.
See it in one request
What an agent sees when it hits a priced URL (a dual-version x402 offer: v1 JSON body plus a v2 PAYMENT-REQUIRED header):
curl -i https://web-production-095eb.up.railway.app/r/eu-rates/today
Pay the 402 with an agent API key (custodial scheme):
PAYMENT=$(printf '{"x402Version":1,"scheme":"tollgate-credit","network":"tollgate","payload":{"apiKey":"tg_sk_..."}}' | base64)
curl -i -H "X-PAYMENT: $PAYMENT" https://web-production-095eb.up.railway.app/r/eu-rates/today
The 200 comes back with the content, a settlement header (X-PAYMENT-RESPONSE), and a receipt id (x402-receipt: tg_xxxxxxxx). A 404 path never charges, and browsers get a free HTML preview instead of the 402.
Or do it from the terminal in one line:
TOLLGATE_API_KEY=tg_sk_... npx tollgate get https://web-production-095eb.up.railway.app/r/eu-rates/today
Try the demo
Log in with the demo account and everything is already set up: six publishers, eight priced resources, and a demo agent (briefing-bot) with a funded balance and all four spending rules configured.
Demo login: [email protected] / toll-gate-demo
Open Agents, pick briefing-bot, and press "Run now" to watch it make real x402 purchases live: 402 handshakes, receipts, and the balance ticking down by exactly the run total.
The rest of the docs
| Page | What it covers |
|---|---|
| What x402 actually is | The protocol behind the 402: wire formats (v1 and v2), schemes, and why this wave of micropayments is different |
| Sell something in 5 minutes | Publisher quickstart: sign up, publish content, set a price, watch the first paid request land |
| Give an agent a wallet | Agent quickstart: create an agent, set spending rules, make its first purchase |
| Go live with real USDC | Operator manual for on-chain settlement: treasury address, funding a test wallet, first real purchase, mainnet switch |
| CLI & SDK | Every tollgate command, environment variables, and using payFetch from your own code |
| MCP server | Registering the Tollgate MCP server so Claude (or any MCP client) can shop and pay mid-task |
| HTTP API | The publisher REST API, the 402 offer and payment headers, and the facilitator endpoints |
| Architecture | How the pieces fit: the x402 engine, the two schemes, the WalletProvider interface, the database |