Logo
DevUtilsAll-in-one toolkit
Back to all codes
4024xx
4xx — Client Error

Payment Required

Reserved for future use. Sometimes used by APIs to indicate quota limits or billing issues.

What it means

The HTTP 402 Payment Required is a nonstandard client error status response code that is reserved for future use.

Initially created to enable digital cash/micropayment systems, it is rarely used natively, but modern SaaS APIs (like Stripe or Shopify) use it to indicate that a developer's account has run out of credits or has billing issues.

How it works

  • 1The client makes a request to a paid API.
  • 2The server checks the account and sees an unpaid invoice.
  • 3The server returns 402, prompting the client to update their payment method.

Why you're seeing this

  • Subscription expired.
  • Insufficient credits.

How to fix it

  • Update the billing information in the provider's dashboard.

Framework Implementations

Express.js

app.post('/premium-feature', (req, res) => {
  if (req.user.credits <= 0) {
    return res.status(402).json({ error: 'Payment required' });
  }
});

Real-Life Scenarios

Use this when a user hits a paywall, their subscription expires, or they exceed a hard quota on a paid API plan.

API Quota Exceeded

A developer is using an AI API on a pre-paid plan. Their credits run out. The next request returns 402, indicating they need to top up their account.

HTTP Transaction

1. Client Request

POST /api/generate-image HTTP/1.1
Authorization: Bearer my-token

2. Server Response

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

{"error": "Insufficient funds for this request"}

SEO Implications

Pages behind strict paywalls shouldn't be indexed directly, but Google provides structured data to handle paywalled content without returning 402 to the crawler.

Related Codes