Home / Guides / Get paid by AI agents into your Coinbase Business account with agent402-tollbooth

Get paid by AI agents into your Coinbase Business account with agent402-tollbooth

Coinbase Business now takes payments from AI agents over x402: an agent pays your x402 URL in USDC and the funds settle into your Coinbase Business account, where you reconcile, withdraw, or hold them. Coinbase's own path is a hosted checkout that returns an x402 URL. If you sell an API and want a price on every request, this guide puts x402 in front of the API itself and settles into the same account.

agent402-tollbooth is an open-source (MIT) gate for Express, Next.js, Cloudflare or a plain reverse proxy: humans browse normally, AI agents and crawlers get a 402 with a USDC price and pay it, and the gate settles through the facilitator you name. Point it at your Coinbase Business address and every settled call lands there.

1. Two things from Coinbase

  1. Your USDC receive address on Base from the Coinbase Business account (Receive, network Base, asset USDC; Coinbase's Deposit Destinations API is the programmatic route to a receive address). This is the payTo on every 402 you serve, so funds settle straight into the account.
  2. A CDP API key (id + secret) from the Coinbase Developer Platform. The tollbooth uses it to sign requests to Coinbase's x402 facilitator, which verifies and settles each payment. On Base no fee is taken from the payment itself; Coinbase's facilitator is free for the first 1,000 settlements a month and $0.001 each after.

2. One command in front of anything

npm i agent402-tollbooth @x402/express @x402/core @x402/evm @coinbase/x402
TOLLBOOTH_PAYTO=0xYourCoinbaseBusinessBaseAddress \
TOLLBOOTH_CDP_API_KEY_ID=organizations/.../apiKeys/... \
TOLLBOOTH_CDP_API_KEY_SECRET='-----BEGIN EC PRIVATE KEY-----...' \
TOLLBOOTH_PRICE='$0.005' \
TOLLBOOTH_UPSTREAM=http://localhost:8080 \
npx agent402-tollbooth

Keep the key out of your shell history: put the three values in a .env file and load it (set -a; . ./.env; set +a) or use your secret store.

That is a reverse proxy in front of your existing API on :8080. In the default mode known AI crawlers (matched by user agent) get a 402 quoting $0.005 in USDC on Base, pay it, and are proxied through; the payment settles into the Coinbase Business account before the response is released, and browsers pass untouched. To charge every non-browser caller, stock x402 clients included, set TOLLBOOTH_MODE=all and whitelist your own clients with free().

3. Or as Express middleware, with the price per route

import express from "express";
import { createTollbooth } from "agent402-tollbooth";
import { paymentMiddleware } from "@x402/express";
import { HTTPFacilitatorClient, x402ResourceServer } from "@x402/core/server";
import { ExactEvmScheme } from "@x402/evm/exact/server";
import { createFacilitatorConfig } from "@coinbase/x402";

const PAY_TO = process.env.COINBASE_BUSINESS_ADDRESS;  // USDC receive address on Base
const facilitator = new HTTPFacilitatorClient(
  createFacilitatorConfig(process.env.CDP_API_KEY_ID, process.env.CDP_API_KEY_SECRET)
);
const server = new x402ResourceServer(facilitator).register("eip155:8453", new ExactEvmScheme());
const x402 = paymentMiddleware(
  { "GET /api/quote": { accepts: [{ scheme: "exact", network: "eip155:8453", payTo: PAY_TO, price: "$0.005" }] } },
  server
);

const app = express();
app.use(createTollbooth({ x402 }));            // humans free, agents pay, MPP accepted too
app.get("/api/quote", (req, res) => res.json({ price: 42 }));
app.listen(8080);

The gate delegates verify and settle to @x402/express in its own order (verify, run your handler, settle only on a success response) and, by default, also accepts the MPP wire, so agents on either protocol can pay. The full runnable example is in the repo: examples/coinbase-business-tollbooth.

4. Prove it with one paid call

We ran exactly this path with real money before publishing: the CLI's own middleware built from CDP keys, paid $0.001 by a stock x402 client, settled through Coinbase's facilitator on Base (transaction). One rule to know: Coinbase's facilitator refuses a payment whose payer is the payTo (self_send_not_allowed), so test from a second wallet, never from the receiving address.

Any stock x402 client pays it; we proved it with @x402/fetch and the agent402-client SDK speaks the same wire. The receipt on the 200 response (PAYMENT-RESPONSE) carries the settlement; it lands on Base within seconds and Coinbase credits the deposit on its normal schedule.

What you get

  • Payments from agents settle in USDC into the account you already reconcile from, with no card network, no invoices and no agent accounts.
  • Discoverable: list the endpoint on Agent402's open index (/sell); agents can find it at once, and once it shows settled transactions the router at /api/route can pay you on their behalf; a route can also carry the x402 Bazaar discovery extension for Coinbase's own directory.
  • The rest of the tollbooth: proof-of-work for callers with no wallet, observe-before-charge mode, per-route prices, analytics, and native MPP on Tempo if you want a second rail. See /tollbooth.
Back to guides