x402 is an open way for a program to pay for a single web request. The server answers an unpaid request with HTTP status 402 Payment Required and states its price. The client signs a payment, sends the same request again, and gets the result. There is no sign-up, no API key and no monthly plan. In practice the payment is usually a few tenths of a cent to a few cents in USDC, a dollar-pegged stablecoin.
The status code is old. HTTP has reserved 402 "for future use" for decades, and x402 is one way of finally using it. What makes it interesting now is that the caller is often an AI agent, which can find a tool at run time but cannot fill in a sign-up form or enter a card number.
The flow in four steps
- Ask. The client sends a normal HTTP request, with no payment attached.
- Get the price. The server answers 402 with its terms: how much, in which token, on which network, and to which address.
- Sign and retry. A client library signs an authorisation for exactly that amount and repeats the request with the signature in a header.
- Get the result. The server has a facilitator check the payment, does the work, settles the payment on chain and returns the answer with a receipt.
Your code normally sees none of this. A wrapper around fetch or httpx handles steps 2 and 3, so the call looks like any other request. The longer version with working code is in how an AI agent pays for an API.
See a real 402 for free
You do not need a wallet to look at a payment request. Asking for the terms costs nothing, so this is the fastest way to understand the protocol. Here is an unpaid call to the DNS lookup tool in our shop:
curl -i "https://shop.lordevo.com/api/quick/dns-lookup?host=example.com"
The answer is HTTP 402. The terms sit in a PAYMENT-REQUIRED header as base64 JSON (x402 version 2), and again in the JSON body for version 1 clients. Decoded and shortened, the version 2 terms we received on 4 November 2026, and again unchanged on 12 November, were:
{
"x402Version": 2,
"accepts": [{
"scheme": "exact",
"network": "eip155:8453",
"amount": "2100",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"payTo": "0x0876A79Bb5A88Bf338E6b47b4530359527b01d73",
"maxTimeoutSeconds": 120,
"extra": { "name": "USD Coin", "version": "2" }
}]
}
Reading it line by line:
- scheme: exact means pay this exact amount, not "up to".
- network: eip155:8453 is Base, a low-fee Ethereum layer 2 network.
- amount: 2100 is in the token's smallest unit. USDC has 6 decimals, so 2100 is $0.0021.
- asset is the USDC contract on Base. A careful client checks this rather than trusting any token it is offered.
- payTo is the address that receives the money.
- maxTimeoutSeconds is how long the signed payment stays usable.
What the signature actually is
With the USDC setup above, the client does not send a blockchain transaction itself. It signs an authorisation (the EIP-3009 standard) that says "move this amount from me to that address, within this time window". The facilitator, a service that verifies and submits payments, puts it on chain and pays the network fee. That is why a buyer's wallet in this setup needs USDC but no ETH for gas. Our shop uses the Coinbase CDP facilitator.
The signature only covers the stated amount and recipient, and it is good for one use. It is not a standing permission to take money from the wallet.
Version 1 and version 2
You will see both in the wild, and they differ mainly in where things go. Version 2 puts the terms in the PAYMENT-REQUIRED header, and the client replies with PAYMENT-SIGNATURE. Version 1 puts the terms in the JSON body, and the client replies with X-PAYMENT. Version 1 also names the network base where version 2 uses eip155:8453. Our shop accepts both, but use version 2 for new code, because the older client packages are deprecated.
How does an agent find a paid API?
A payment step is no use if nothing can find the tool. There is no single directory, so sellers publish in several places at once:
- The x402 Bazaar, a discovery listing run through facilitators, which an agent can query at run time.
- A file on the seller's own site, such as /.well-known/x402, an OpenAPI file or llms.txt. Ours are llms.txt and catalog.json.
- MCP server listings, where the tools are found through a normal tools/list call.
What x402 does not give you
It helps to be clear about the gaps, because some articles skip them.
- It is a payment step, not a billing system. There is no built-in chargeback, invoice or dispute process. Each seller decides what happens when a call fails. See what happens when a paid call fails.
- It does not tell you a seller is honest. A valid 402 proves only that someone wants to be paid. Your client should decide what it is willing to pay, which is covered in how to limit what an agent can spend.
- It suits some workloads and not others. For steady, heavy use by a known customer, a normal API key can be the better fit. The comparison is in x402 vs API keys and Stripe.
What agents use it for
Most paid calls are small jobs an agent repeats in the middle of a task: look up a domain, read a page, check a link. Two worked examples, each with a complete script: enriching a list of domains for a lead list at $0.0021 per lookup, and turning web pages and PDFs into Markdown chunks for RAG at $0.0021 per page.
Try one call without a wallet
Our shop lets you see a real result before setting up anything. Add trial=1 and you get 3 free calls per IP address per UTC day, on tools priced up to $0.0022:
curl "https://shop.lordevo.com/api/quick/dns-lookup?host=example.com&trial=1"
That shows the output. The next step is the shop's start page, which has copy-paste examples for curl, JavaScript, Python and MCP. Prices there come from the shop's price table, and the 402 answer is always the final word on what a call costs.