What is x402?
For decades, 402 Payment Required sat in the HTTP specification marked "reserved for future use." The x402 protocol is that future: a vendor-neutral convention for charging money over plain HTTP. Instead of redirecting a user to a checkout page, a server can answer a request with a 402 and a small JSON document that says, in effect, "pay this, to here, on this chain, and ask again."
It matters because the web is increasingly browsed by software, not people. An AI agent can't fill in a credit-card form, but it can read JSON and sign a stablecoin transfer. x402 gives machines a native, standard way to pay for exactly what they use.
How the 402 handshake works
A complete paid request is a two-trip exchange:
- Request. The client requests a protected resource, e.g.
GET /premium. - 402 challenge. The server replies
402 Payment Requiredwith a JSON body containing anacceptsarray. Each entry lists a way to pay:scheme,network,maxAmountRequired(in base units),payTo,assetand a timeout. - Payment. The client picks an entry and makes the on-chain transfer — usually USDC on Base — producing a signed proof.
- Retry with proof. The client repeats the original request, now with an
X-PAYMENTheader carrying that proof. - Verify & deliver. The server (or a facilitator) verifies the payment and returns the resource, confirming settlement in an
X-PAYMENT-RESPONSEheader.
You can generate a spec-shaped challenge body and copy ready-to-use server and client code with our free x402 / HTTP 402 response builder, and get the maxAmountRequired integer right with the base-unit converter.
What people build with x402
AI agent API access
Let autonomous agents pay per call for data, inference or tools — no pre-provisioned keys, no shared secrets to leak.
Pay-per-request APIs
Charge a fraction of a cent per endpoint hit instead of monthly tiers. Pricing scales exactly with usage.
One-off digital goods
Sell a report, file or generation with a single 402 — no cart, account or subscription.
MCP & tool monetization
Add a price to Model Context Protocol servers and developer tools so agents can transact with them directly.
x402 vs. traditional payment rails
| x402 (USDC on Base) | Card processor (e.g. Stripe) | |
|---|---|---|
| Minimum charge | Fractions of a cent | ~$0.30 effective floor |
| Settlement | ~2 seconds, on-chain | Days, via bank rails |
| Accounts / keys | None — just a wallet | Merchant + cardholder accounts |
| Human in the loop | Not required | Usually required |
| Best for | Agents, APIs, micropayments | Human checkout, large amounts |
x402 and cards aren't strictly competitors — x402 opens use cases (sub-cent, autonomous, per-request) that card rails can't serve economically. See a fuller breakdown on the protocol comparison page.
The x402 ecosystem at a glance
mpp.best currently tracks 1211 open-source projects that reference x402, across 30+ languages. They fall into a few broad roles:
Server middleware
Drop-in handlers for Express, Hono, FastAPI, Next.js and more that return a 402 and verify payment.
Client SDKs
Libraries that detect a 402, pay, and retry with proof — for JS/TS, Python, Go and others.
Facilitators
Services that verify and settle payments on your behalf so your app skips the RPC plumbing.
Agent integrations
Connectors that give LangChain, MCP and custom agents a wallet and the ability to pay 402s.
Full stacks & demos
End-to-end examples and starter kits showing a complete paid request loop.
Tooling & infra
Explorers, dashboards, testing utilities and wallets built around x402 traffic.
Browse all 1211 x402 projects →
Getting started
- Understand the shape. Generate a sample 402 body with the response builder and read the field reference there.
- Pick a network. Start on Base Sepolia (testnet) with free faucet USDC so you risk nothing.
- Add server middleware. Choose a library for your stack from the directory and return a 402 on protected routes.
- Verify payments. Verify on-chain yourself or via a facilitator before serving the resource.
- Go live. Switch to Base mainnet and set your real
payToaddress.
Glossary
- 402 challenge
- The JSON body a server returns with an HTTP 402, listing acceptable payment options in its
acceptsarray. - Base unit
- The smallest integer unit of a token. USDC has 6 decimals, so $1.00 = 1,000,000 base units.
- Facilitator
- An optional service that verifies and settles payments so your server avoids direct chain calls.
- X-PAYMENT header
- The header a client sends on its retry, carrying cryptographic proof of payment.
- USDC on Base
- The de-facto default rail for x402: a dollar stablecoin on a low-fee Ethereum Layer 2.
Frequently asked questions
What is the x402 protocol?
x402 is an open protocol that gives the long-reserved HTTP 402 Payment Required status code a concrete meaning. A server responds to a paid request with a 402 and a JSON body describing how to pay (amount, token, network, recipient). The client pays on-chain — typically USDC on Base — and retries the request with cryptographic proof in an X-PAYMENT header. The server verifies it and returns the resource. No accounts, API keys or checkout redirects are involved. Coinbase published the canonical specification in 2025.
How is x402 different from Stripe or traditional payments?
x402 settles on-chain in roughly two seconds, supports micropayments down to a fraction of a cent, and needs no human approval — a program with a funded wallet can pay autonomously. Card processors like Stripe impose a per-transaction minimum (around $0.30), require a cardholder and account, and take days to settle. For machine-to-machine and AI-agent payments, x402 removes the floor and the human.
Which blockchains and tokens does x402 support?
x402 is chain-agnostic, but the reference implementation uses USDC on Base, an Ethereum Layer 2 with sub-cent fees and fast finality. The community has built implementations targeting Ethereum mainnet, Polygon, Solana, TON and Bitcoin Lightning. Amounts are always expressed in the token base unit (USDC has 6 decimals).
Do I need a facilitator to use x402?
No, but it helps. A facilitator is an optional service that verifies and settles payments so your server never has to talk to the chain directly. You can verify on-chain yourself, or use a public facilitator (Coinbase runs one for Base). See our x402 facilitators list and comparison at /x402-facilitators. Either way the 402 challenge body is identical.
Can AI agents pay an x402 request automatically?
Yes — that is the primary motivation. Because the challenge is plain JSON over HTTP, an agent that can make a fetch request and holds a funded wallet can read the payment requirements, pay, and retry without any human in the loop. This is the foundation of agentic commerce.
Where can I find open-source x402 implementations?
mpp.best tracks 1211 GitHub projects that reference x402 — server middleware, client SDKs, agent integrations, MCP plugins and full stacks. Browse them by language and framework from this page or the homepage.
Ready to build? Use the free 402 response builder and unit converter, browse 1211 x402 projects, or compare payment protocols.