Skip to content

HTTP Response Status Code 402 Payment Required

What is HTTP Response Status Code 402 Payment Required?

HTTP response status code 402 Payment Required was originally intended for use with digital payment systems. It is reserved for future use and is not widely implemented, but it can be used in custom applications to indicate that access requires payment.

When is HTTP Response Status Code 402 Payment Required Used?

The 402 status code is not widely used but might appear in custom APIs where access to a service or resource requires payment or subscription.

Example 1: Accessing a Paid API

# Client sends a request to access a premium API.
GET /api/premium-content HTTP/1.1
Host: api.example.com

# Server Response
HTTP/1.1 402 Payment Required
Date: Wed, 09 Oct 2024 14:15:00 GMT
Server: CustomServer/1.0

{
"error": "Payment required to access this resource"
}

Example 2: Subscription Expired

# Client tries to access a resource with an expired subscription.
GET /api/subscriber-only HTTP/1.1
Host: api.example.com

# Server Response
HTTP/1.1 402 Payment Required
Date: Wed, 09 Oct 2024 14:17:00 GMT
Server: Apache/2.4.41 (Ubuntu)

{
"error": "Your subscription has expired. Please renew to access this content."
}

Summary

The HTTP 402 Payment Required status code is not standardized and is reserved for future use. It can be implemented in custom APIs for cases where payment is required to access certain resources.

I am the founder of SEO Leaders and have been involved in the internet and web development in one way or another for over 20 years. Since founding SEO Leaders some 6 years ago I have been heavily involved in web develepment, Digital PR and technical SEO for a wide variety of projects. I hope to enlighten you on a wide range of topics related to my chosen profession!

Back To Top