x402
x402 is a lightweight protocol pattern that uses HTTP 402 Payment Required responses with machine-readable JSON hints to enable agent-to-agent paid transactions.
How it works
- Client requests a priced resource
- Server returns
402 Payment Requiredwith a JSON payment hint - Client pays using any payment rail that provides a verifiable receipt
- Client retries the request with the receipt (typically in a header or body field)
- Server verifies the receipt and returns
200 OKwith the resource
Key characteristics
- Rail-agnostic: Works with any payment system that provides verifiable receipts (crypto, cards, ACH, Lightning)
- Machine-readable: JSON responses enable automated agent workflows
- HTTP-native: Uses standard status codes and headers, no custom protocols
- Verifiable: Cryptographic receipts prove payment without manual reconciliation
Example 402 response
HTTP/1.1 402 Payment Required
Content-Type: application/json
{
"detail": "Payment required to access this resource.",
"payment": {
"protocol": "x402",
"amount": "0.10",
"currency": "USDC",
"reference": "order-abc-123",
"instructions": "Pay and present receipt in retry."
}
}Why “x402”?
The x prefix indicates an experimental or extension pattern. x402 revives the long-reserved HTTP 402 status code for practical use in agent-to-agent commerce, where automated clients need a standard way to discover, pay for, and access priced resources.
Learn more
- x402 Implementation Guide - Complete technical documentation with code examples
- HTTP 402 Practical Guide - Design principles and common pitfalls
- HTTP 402 for APIs Blog Post - Real-world implementation patterns