402 Payment Required

HTTP response status code 402 Payment Required is a client error that is returned by the server to indicate that payment is required before the client can access the requested resource.

Usage

When the 402 Payment Required error message is received, the client understands that access to the requested resource may not be granted at this time.

Note

402 Payment Required is a server response that is reserved for future use. Currently, its use is non-standard and may be changed in the future if the specification is more fully defined.

Because this is a non-standard response, different providers have used it in different ways. For example, the Shopify API returns 402 Payment Required status to indicate the online shop is currently frozen and that the store administrator has to pay an outstanding account balance to bring it back online.

Note

Search engines like Google will not index a URL with 402 Payment Required response status, and consequently, URLs that have been indexed in the past but are now returning this HTTP status code will be removed from the search results.

Example

In the example, the client requests a resource and the server responds with the 402 Payment Required status to indicate that the user cannot access the resource at this time.

Request

GET /tech-news HTTP/1.1
Host: www.example.re

Response

HTTP/1.1 402 Payment required

Code references

.NET

HttpStatusCode.PaymentRequired

Rust

http::StatusCode::PAYMENT_REQUIRED

Rails

:payment_required

Go

http.StatusPaymentRequired

Symfony

Response::HTTP_PAYMENT_REQUIRED

Python3.5+

http.HTTPStatus.PAYMENT_REQUIRED

Java

java.net.HttpURLConnection.HTTP_PAYMENT_REQUIRED

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_PAYMENT_REQUIRED

Angular

@angular/common/http/HttpStatusCode.PaymentRequired

Takeaway

The 402 Payment Required status code is reserved for future use and thus its current use is non-standard. However, it is intended to support a digital cash or micro-payment scheme for content.

See also

Last updated: August 2, 2023