The x402 Payment Flow, Step by Step, for AI Agents
· updated · 3 min read
An x402 payment takes four steps: your agent calls the API, gets a 402 quote, pays it, and calls again with the payment attached. Add one check before paying and one report after, and your agent only pays endpoints that deliver.
Step 1: The API answers with a 402 quote
Your agent calls a paid API like any other. Instead of data, the API answers 402 Payment Required with a quote:
- The price, in atomic units written as a string. USDC has 6 decimals, so
"10000"is $0.01 and"1000000"is $1.00. - The network, such as Base (
eip155:8453) or Solana. - The token, usually USDC.
- The payout wallet (
payTo): who gets paid.
x402 version 2 puts the quote in a base64 PAYMENT-REQUIRED header; version 1 puts it in the JSON body. There's no account and no API key. Want to read one by hand? Paste it into the free x402 quote decoder.
Step 2: Check the quote before paying
USDC payments can't be charged back, so check first. Send the quote's details to Lumière PayCheck's free check:
curl -X POST https://lumierepaycheck.org/v1/check-payment -H "content-type: application/json" \
-d '{"url":"https://api.seller.example/data","amount":"10000","payTo":"0xSELLER_WALLET","network":"eip155:8453","asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"}'Pay only if allow is true. Each field catches a different trick: a raised price, a swapped wallet, a swapped network or a swapped token. With an MCP client, the same check is the check_payment tool on https://lumierepaycheck.org/mcp.
Step 3: Pay and call again
Your x402 client signs a payment for the exact quoted amount and repeats the request with the payment in a header (PAYMENT-SIGNATURE in version 2, X-PAYMENT in version 1). The API settles the payment and returns the data.
If the request fails after you've sent a payment, retry with the same payment instead of signing a new one, or you could be charged twice.
Step 4: Check what you got
A settled payment proves money moved, not that the data was right. After the call, report the outcome with the report_outcome tool, so the endpoint's record reflects what really happened.
PayCheck also makes its own real paid tests of endpoints, and every test has a receipt signed with our Ed25519 key, at GET /v1/test-receipts?url=<endpoint>.
Picking endpoints worth paying
GET /v1/score?url=<endpoint> gives any endpoint a free grade and one of these verdicts:
- proceed: a real paid test delivered, and the endpoint is reliable in monitoring.
- caution: something isn't confirmed yet, often because it hasn't been paid-tested. It doesn't mean "don't pay".
- avoid: buyers shouldn't pay it.
- insufficient_data: too new to judge.
PayCheck monitors more than 140,000 x402 endpoints every 30 minutes and watches for price jumps and payout wallets that change without warning.
FAQ
Do I need an account to pay an x402 API? No. The quote says what to pay, your agent pays it, and the payment itself is the access. Lumière PayCheck's free checks don't need an account either.
What does an amount like 10000 mean? It's in atomic units. USDC has 6 decimals, so 10000 is $0.01.
Does Lumière PayCheck hold or move my money? No. It never moves anyone's money. It only checks endpoints and quotes before your agent pays.
Check any x402 endpoint for free: https://lumierepaycheck.org/check
Related reading
More from the blog
OpenAI Alternatives on x402: How to Check an AI API Before Your Agent Pays
More AI model APIs now sell by the call over x402: text generation, image generation, embeddings, speech. No account, no API key, no monthly plan. Your…
We started grading MPP endpoints. Here's what 1,226 of them look like.
We checked every callable endpoint in the MPP catalog and read 30 days of MPP payments on Tempo: 581,000 real payments at a median of 1 cent, 98%…
What Happens When an x402 Payment Fails
When an x402 payment fails, what happens to your money depends on where it failed. If the seller rejects the payment, nothing settles and you keep your…