x402 is an HTTP payment protocol for machine-to-machine payments. When a key’s wallet cannot cover a call and x402 is enabled, the backend answers 402 Payment Required with an x402 offer instead of refusing.
Offer
GET /payment/x402/config advertises the current offer template:
{
"data": {
"enabled": true,
"payment": {
"chainId": "8453",
"asset": "USDC",
"amount": "0.01",
"recipient": "0x..."
},
"verifier": "https://x402.org/verifier"
}
}
Flow
- A request the wallet cannot cover returns
402with theX-Payment-Requiredheader (a base64url-encoded JSON offer) and apayment_requiredbody. - The client (a wallet or an agent) pays the offer on-chain on Base in USDC.
- The client obtains a receipt from the verifier and retries with:
X-Payment-Receipt: <base64url JSON receipt>
- The backend verifies the receipt once, matches the offer reference, records it, and serves the request.
Guarantees
- Offers expire after 15 minutes.
- Receipts are single-use (
receipt_idis unique); a replay is rejected. - The receipt must reference an offer issued to the same user.
- A failed verification returns a fresh
402with a new offer.
Notes
x402 is an alternative to the prepaid credit wallet. While credits remain, x402 is not triggered. It applies to metered tools served through the tool gateway; email verification does not issue x402 offers and refuses with 402 INSUFFICIENT_CREDITS instead.