HTTPfy

402 Payment Required

Reserved for future use; some APIs use it to signal that payment is required or failed.

402 at a glance

Code
402
Name
Payment Required
Class
4xx Client error
Status
IANA-registered standard code
Defined in
RFC 9110, Section 15.5.3
Cacheable by default
No by default. Caches store it only when the response carries explicit freshness (Cache-Control max-age, s-maxage or Expires).

What 402 means

402 Payment Required has been "reserved for future use" since HTTP/1.1, and RFC 9110 still gives it no standard semantics. Real systems use it anyway: Stripe returns 402 when parameters are valid but a payment failed, SaaS APIs return it when a subscription has lapsed, and the x402 protocol uses it to ask clients for an on-the-spot machine payment.

What typically causes a 402

  • Stripe and other payment APIs for declined cards or failed charges.
  • SaaS and hosting platforms when an account is past due or a free quota is used up (Shopify uses 402 for frozen shops).
  • Pay-per-request APIs built on the x402 convention.

Fix it on the server

  • Explain in the body how the client can pay or upgrade; there is no standard header for this.
  • Do not use 402 for authentication or permission problems.

Fix it as a client or visitor

  • Check the billing state of the account or the decline reason in the response body.

Example response

HTTP/1.1 402 Payment Required
Content-Type: application/json

{"error": {"type": "card_error", "code": "card_declined"}}

Opens the HTTP headers tool with your URL filled in; it shows the status line and headers of every redirect hop.