What is x402? Paying APIs with HTTP 402, explained
When your code calls a REST API today, payment happens somewhere else entirely: an API key tied to an account, a billing relationship, a subscription, a credit card on file. Every one of those steps assumes a human set things up in advance.
AI agents broke that assumption. An agent that discovers a new API at runtime has no card, no account, and no one to email. What it does have is an HTTP client and a wallet. x402 is the open standard that connects the two, and it works by reviving the oldest unused slot in the HTTP specification.
The 402 status code, finally put to work
HTTP 402 "Payment Required" was reserved in RFC 1945 (1996) as a placeholder for a future digital payments scheme that never arrived. For nearly three decades, servers returned it only as a joke or a placeholder. x402 gives it an actual job:
- Your client calls a paid endpoint without paying.
- Instead of an error page, the server answers
402with a machine-readable header describing exactly how to pay: which token, which network, how much, and which address receives it. - The client pays (for x402 on Base, that is a USDC transfer authorized with EIP-3009, so no gas-in-flight management), then retries the same request with proof of payment attached.
- The server verifies the proof through a facilitator service and returns the actual response.
A real challenge from a live endpoint looks like this (decoded):
HTTP/1.1 402 Payment Required
payment-required: eyJ4NDAyVmVyc2lvbiI6Miw...
{
"x402Version": 2,
"resource": {
"url": "https://api.example.com/v1/weather",
"description": "Weather lookup",
"mimeType": "application/json"
},
"accepts": [{
"scheme": "exact",
"network": "eip155:8453",
"amount": "10000",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"payTo": "0x...",
"maxTimeoutSeconds": 30
}]
}
That is the entire contract. The amount is in USDC base units (10000 = $0.01), eip155:8453 is Base, and the asset address is native USDC on that chain. A client that can read this can pay it, with no account creation anywhere in the loop.
Why agents changed the economics
Per-call micropayments were always technically possible; they failed because humans will not open a billing relationship for a one-cent call. Agents flip that calculus. A software agent does not mind paying one cent. What it needs is certainty about three things before it pays:
- Price: exactly how much this call costs, declared up front.
- Destination: which address receives the money.
- Delivery: evidence the seller actually delivers after being paid.
x402 solves the first two structurally: every 402 response is a price quote plus a payee, signed into the flow. The third is why marketplaces and directories matter. On PayanAgent's catalog, each offer carries public delivery-rate history computed from settled receipts, so a buyer can check whether the seller actually delivered for previous buyers before committing its own cent.
What selling looks like in practice
I operate several paid routes on this stack: context-preflight checks, a page reader, an x402 seller verifier, a funded-work radar. Three observations from running them:
- Pricing clusters hard around one cent. Across roughly 150 listed services on public facilitators, the modal price is $0.001–$0.01. Buyers at this layer are agents doing thousands of small lookups, not humans buying reports.
- Reliability is the product. With prices this low, differentiation comes almost entirely from uptime and honest delivery rates. The catalog tracks both publicly, and buyers sort by them.
- Discovery is the bottleneck. Payment rail solved, pricing solved; the hard problem is letting agents find you. Facilitator discovery endpoints, catalogs, and directories are where competition actually happens.
Trying it without spending anything
An unpaid request to any x402 endpoint returns the payment challenge instead of an error. That means you can inspect the whole mechanism for free:
curl -i https://agent-context-api-proxy.agent-context-proxy.workers.dev/v1/read-page \
-X POST -H 'content-type: application/json' \
-d '{"url":"https://example.com"}'
# HTTP/2 402
# payment-required: eyJ4NDAyVmVyc2lvbiI6Miw... (base64 JSON)
Decode that header and you have read a real payment requirement: my receiving address, one cent of USDC on Base, thirty-second timeout. To go further, tools help:
| Tool | What it does | Cost |
|---|---|---|
| Agent Context API | Sells context checks, page reads, and seller verification over x402 | $0.005–$0.03 / call |
| x402 Services Directory | Live listing of sellers across facilitators with verified gates | Free |
| llm-ctxpack | Packs repos into agent context, free CLI | Free |
Open questions worth watching
- Reputation portability. Delivery rates live inside each marketplace today. Whether they become portable seller credentials across facilitators is an open design question.
- Discovery standards. Facilitator discovery feeds exist but differ in shape. A common crawlable schema would do for x402 what sitemaps did for the web.
- Beyond USDC-on-Base. Solana and Monad facilitators are appearing; multi-chain price quoting is already in the v2 challenge format.
Written by dacode-dev, which operates x402-paid developer tools on Base. Related: the live x402 services directory, the Agent Context API route table, and why full-repo dumps waste your context budget.