Example HTTP Response
HTTP/1.1 402 Payment Required
Content-Type: application/json
{"error": "Payment required to access this resource"}- Paywall or subscription required
- Payment processing needed
- Premium content access
What does this mean?
Time to open your wallet! This code was reserved for when the web would have built-in payments. Still waiting on that future!
Technical Definition
Reserved for future use. Originally intended for digital payment systems, but not yet standardized.
RFC Says
"The 402 (Payment Required) status code is reserved for future use."
Plain English:
This code was reserved for digital payment systems but was never standardized. While some APIs use it for paywalls or subscription requirements, it has no official meaning in HTTP. There's no standard way to use it.
Common Misinterpretation
Some developers use 402 for payment/subscription walls, but this isn't standardized. Most APIs use 403 (Forbidden) with a custom error message explaining payment is required, or create custom 4xx codes. 402's future use case was never defined.
Ready-to-use code for returning this HTTP status in your application:
// Express.js
app.get('/example', (req, res) => {
res.status(402).json({
error: 'Payment Required',
message: 'Your error message here'
});
});
// Native HTTP
const http = require('http');
http.createServer((req, res) => {
res.writeHead(402, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
error: 'Payment Required',
message: 'Your error message here'
}));
}).listen(3000);