Skip to content

Welcome to tollbooth

tollbooth is an API gateway that sits in front of your upstream APIs and charges callers per-request using the x402 payment protocol. No API keys, no subscriptions — just instant USDC micropayments.

  • API providers who want to monetize endpoints without building billing infrastructure
  • AI agent developers who need machine-to-machine payment flows
  • Anyone who wants to add pay-per-request pricing to an existing API

YAML config

Define upstreams, routes, and pricing in a single tollbooth.config.yaml — no code required.

Dynamic pricing

Match on body fields, query params, and headers with glob patterns. Or use custom pricing functions.

Multi-upstream

Proxy to multiple APIs from a single gateway. Route by path, rewrite URLs, inject headers.

Lifecycle hooks

Hook into onRequest, onPriceResolved, onSettled, onResponse, and onError.

x402 V2

Modern payment headers with auto-discovery at /.well-known/x402.

Multi-chain

Accept USDC payments on Base, Base Sepolia, Solana, or any supported network.

Terminal window
bun add x402-tollbooth

Next: Getting Started →