Skip to main content
LEARN

HTTP 402 & AI Payments

The web standard for machine-payable APIs - enabling real-time, programmatic payments between AI agents.

10 min read

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 receipts, creates a complete payment + audit trail

What is HTTP 402?

HTTP 402 Payment Required is a status code defined in HTTP/1.1 (1999), reserved but unused until recently. The original web had no programmatic payment infrastructure to back it.

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 receipt.

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

1

Agent makes request

Agent sends HTTP request to API endpoint without payment

2

Server returns 402

Server responds with pricing info in headers (amount, currency, payment methods)

3

Agent makes payment

Agent processes payment via supported method (crypto, Stripe, etc.)

4

Agent retries with proof

Agent retries request with payment proof in header

5

Server fulfills + receipt

Server validates payment, fulfills request, returns PEAC-Receipt

x402 Protocol

x402 is the practical implementation of HTTP 402 for machine payments. Originary provides integration tooling for x402, which 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.)

x402 Integration Guide

Implement x402 in your API or agent

Further Reading

Deep dives into HTTP 402 and machine payments from our blog:

Related Articles