Tollbooth (pay-per-crawl)
The sell side: middleware or a reverse proxy that puts a per-request price on a site or API for AI crawlers and agents while human visitors browse free. One 402 carries an x402 offer and an MPP challenge, plus a proof-of-work path for a walletless agent. Non-custodial: payments go to your own wallet.
Install
npm install agent402-tollbooth
Example
import express from "express";
import { createTollbooth } from "agent402-tollbooth";
const app = express();
// Humans pass through; known AI crawlers get 402 and must pay or solve a proof-of-work.
app.use(createTollbooth({ price: "$0.002" }));
app.get("/article", (_req, res) => res.send("...your content..."));
app.listen(3000);
What it exposes
createTollbooth(config): Express-compatible middleware with charge modes, adaptive proof-of-work and a stats sink.npx agent402-tollbooth: a reverse proxy that needs no code change on the origin.- An edge build on the Web Crypto and Fetch APIs, with deploy templates for Cloudflare Workers, Next.js and Docker.
- A
/__tollboothdashboard andgate.stats()for what was served and paid.
How payment works
- x402: USDC through a facilitator you choose, verified before the request is served and settled only on a successful response.
- MPP:
WWW-Authenticate: Paymentchallenges on the same 402, including native MPP on Tempo with split payments. - Proof-of-work: a sha256 puzzle, single-use and bound to the exact URL, so a crawler with no wallet can still get through.
# reverse proxy in front of any site, settling over x402 and MPP from env alone
npm i @x402/express @x402/core @x402/evm
TOLLBOOTH_UPSTREAM=https://your-site.com \
TOLLBOOTH_PAYTO=0xYourWallet \
TOLLBOOTH_FACILITATOR_URL=https://x402.org/facilitator \
npx agent402-tollbooth
A call that fails is not charged: settlement runs after the tool and only on a successful response. Background: HTTP 402 Payment Required · Pay-per-call APIs.
Tools to try first
Every tool, price and input schema: the catalog.
Links
agent402-tollbooth on npm · source on GitHub
Guides: Sell your API to AI agents over x402 - no billing system required · Get paid by AI agents into your Coinbase Business account with agent402-tollbooth
All integrations