Why x402 matters
- Machine-friendly payments for agents and bots
- No manual checkout required for each request
- Composable with existing API flows
x402 is a paywall pattern for APIs. Instead of old-school login walls,
an endpoint can return 402 Payment Required with payment instructions.
Once you pay on-chain, you retry and get the protected response.
When unpaid, API returns:
{
"code": "payment_required",
"data": {
"amount_wei": "10000000000000000",
"contract": "0x...",
"session_id": "0x...",
"next": { "action": "pay_then_retry" }
}
}
Client calls contract function (often native token payment), waits for confirmation, then retries the same URL with the session header. API returns 200 OK + data.
402 + payment metadata