Implement an x402-capable server endpoint so AI agents can pay per API call with stablecoins without accounts or sessions

domain: x402.org · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Install the x402 server library for your runtime (npm install x402 for Node/Express, or pip install x402 for Python/FastAPI); the reference implementations are published at github.com/coinbase/x402 under Apache 2.0.
  2. Add the x402 middleware to your route: on an unauthenticated request, return HTTP 402 with payment instructions encoded in the X402-Payment-Required header specifying accepted token (e.g., USDC on Base), amount, and your receiving wallet address.
  3. Configure a facilitator (Coinbase CDP or Cloudflare's x402 edge) to verify incoming payment proofs; the facilitator checks on-chain settlement and returns a verification token to your server.
  4. On the client's retry request (which carries the X402-Payment header with the signed payment payload), call facilitator.verify() and, if valid, serve the protected resource with a 200 OK and include the receipt in the X402-Receipt response header.
  5. Test end-to-end in a local sandbox using the x402 testnet mode with USDC on Base Sepolia before pointing to mainnet USDC.

Known gotchas

Related routes

Build a server that responds to HTTP 402 and accepts x402 stablecoin payments so AI agents can pay per API call without accounts or sessions
docs.cdp.coinbase.com/x402/welcome · 6 steps · unrated
Use Crossmint's unified API to accept both x402 stablecoin and ACP card payments from AI agents through a single integration
docs.crossmint.com · 5 steps · unrated
Open a reusable x402 V2 wallet session to enable high-frequency agent API calls without per-request on-chain transactions
x402.org · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans