HTTP 402 and payment records
Key takeaways
- HTTP 402 is a standard status code for "Payment Required" reserved since 1999.
- Enables pay-per-request APIs without subscriptions or pre-purchased credits.
- x402 is the modern implementation with pricing headers and payment proofs.
- Combined with PEAC signed records, creates a complete payment + audit trail.
What is HTTP 402?
HTTP 402 Payment Required is a status code defined in HTTP/1.1 (1999) and is currently documented by MDN as nonstandard: reserved for future use, with no agreed convention for how clients and servers exchange payment data. The original web had no programmatic payment infrastructure to back it. Recent specifications layered on top of 402 (such as x402) define their own headers and bodies above the bare status code.
A 402 response means: this resource exists and is available, but payment is required before access. The response body includes pricing, accepted payment methods, and instructions. The requesting agent pays, retries with proof, and gets the resource plus a signed record.
Why it matters for AI
Most API monetization requires a human to sign up, enter a credit card, buy credits, and manage API keys. An autonomous agent cannot do those things. It needs a payment protocol that works in a single HTTP round-trip.
HTTP 402 provides exactly that: the server describes what payment it needs, the agent pays, and the server returns the resource. One request cycle. No accounts, no subscriptions, no human approval per call.
How it works
- Agent makes request. Agent sends HTTP request to API endpoint without payment.
- Server returns 402. Server responds with pricing info (amount, currency, payment methods).
- Agent makes payment. Agent processes payment via supported method (crypto, Stripe, etc.).
- Agent retries with proof. Agent retries request with payment proof in header.
- Server fulfills + record. Server validates payment, fulfills request, returns signed interaction record.
x402 protocol
x402 is the practical implementation of HTTP 402 for machine payments. It defines:
- 402 response body. Machine-readable pricing info (amount, currency, accepted methods).
- Payment proof. Cryptographic proof submitted with the retry request.
- Payment methods. Standard identifiers for crypto, Stripe, and other rails.
- Error codes. Specific failure modes (insufficient funds, expired proof, etc.).