The HTTP 402 status code stands for "Payment Required". It is a client error response that is reserved for future use and was originally intended for cases where the client must make a payment in order to access the requested resource.

Why is HTTP 402 Not Widely Used?

  • HTTP 402 was part of the HTTP/1.1 specification, and the idea was to use it for payment systems (e.g., microtransactions, subscriptions). However, it was never fully implemented or adopted.
  • Today, HTTP 402 is not widely used, and it does not have a specific standard application. In practice, payment requirements are often handled via other mechanisms (e.g., 401 for authentication, 403 for forbidden access).

When Could HTTP 402 Have Been Used?

  • When a client tried to access content or a service that requires a payment (like purchasing digital goods or subscribing to a service).
  • It could have been used for pay-per-use services or when the user’s account balance was insufficient.

Example Scenario

If a user attempts to access a premium service but hasn’t paid or doesn’t have sufficient funds, the server might respond with HTTP 402, indicating that payment is required to proceed.

Client Request (Accessing a Paid API)

    
        GET /premium-content HTTP/1.1
        Host: example.com
    

Server Response (Payment Required)

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

        { "error": "Payment is required to access this content." }
    

Summary

HTTP 402 Payment Required is a reserved status code that was intended to indicate that payment is needed to access a resource. It is not widely used today, and other mechanisms usually handle payment and access control.