402

Payment Required

Overview

402 Payment Required was reserved for future use and has no officially standardized meaning in HTTP. Even so, some APIs and SaaS products use it pragmatically to signal that payment or a credit top-up is needed.

It is adopted for "you must pay to continue" situations — exhausted free-tier quota, insufficient credits, an expired subscription. Since there is no standardized header convention, the specifics are usually placed in the response body.

When it happens

Request / Response example

Request
POST /api/v1/generate HTTP/1.1
Host: api.example.com
Authorization: Bearer sk_live_...
Response
HTTP/1.1 402 Payment Required
Content-Type: application/json

{"error":"quota_exceeded","message":"Free tier limit reached","upgrade_url":"/billing"}

In code

app.use('/api', (req, res, next) => {
  if (account.creditsLeft <= 0)
    return res.status(402).json({ error: 'quota_exceeded', upgrade_url: '/billing' });
  next();
});

Common causes

How to fix

Notes

Related status codes

Related headers

Specification