HTTP STATUS CODE

HTTP 402 Payment Required

The HTTP status code reserved for digital payment systems. Learn how to implement payment-required responses for API monetization and agent commerce.

What is HTTP 402?

HTTP 402 Payment Required is a standard HTTP status code that was originally reserved for future use in digital payment systems. It indicates that payment is required to access the requested resource.

When a server returns a 402 response, it signals to the client that the request cannot be fulfilled without payment. The response typically includes information about the payment amount, currency, and payment methods accepted.

While HTTP 402 has been part of the HTTP specification since HTTP/1.1, it remained largely unused until recent interest in API monetization and agent-to-agent commerce revived its purpose.

How HTTP 402 works

  1. Client requests a resource - The client makes an HTTP request to a protected endpoint
  2. Server returns 402 - The server responds with HTTP 402 Payment Required, including payment details in the response body
  3. Client makes payment - The client processes the payment through the specified payment method
  4. Client retries with proof - The client retries the original request with a payment receipt or proof of payment

Basic HTTP 402 response

HTTP/1.1 402 Payment Required
Content-Type: application/json
Cache-Control: no-store

{
  "error": "Payment required",
  "message": "Access to this resource requires payment",
  "amount": "0.10 USD"
}

HTTP 402 vs x402

HTTP 402

The HTTP status code itself. Part of the HTTP/1.1 specification.

  • Standard status code
  • No specific format
  • Implementation-agnostic

x402

A protocol specification for implementing HTTP 402 in practice.

  • Standardized headers
  • Payment challenge format
  • Receipt verification

Use cases for HTTP 402

API Monetization

Charge for API access on a per-request or subscription basis. Enable pay-per-use pricing models.

Agent Commerce

Enable autonomous agents to discover pricing and pay for services automatically.

Content Paywalls

Protect premium content behind payment requirements with verifiable receipts.

Implement HTTP 402 in your application

Ready to add HTTP 402 to your API?

Get started with our developer tools and implementation guides.