Skip to content

402 Payment Required

Reserved for future use in the HTTP spec. Some APIs use it to say that payment, credit or a paid plan is needed.

What 402 Payment Required means

402 has been reserved since early HTTP with digital payments in mind, but no standard ever defined how it should work. RFC 9110 still lists it as reserved for future use.

Some services send it on their own terms, for example when an account runs out of credit or a subscription lapses. The exact meaning depends on the service.

Common causes

  • An unpaid invoice, expired subscription or used-up credit on an API account.
  • A plan that does not include the feature or endpoint you called.

How to fix 402 Payment Required

  1. Check the service's billing page and update the payment method or plan.
  2. Read the response body. Services that use 402 usually explain what is needed.
  3. If you run the API, consider 403 with a clear message, since 402 has no standard meaning.

Example response

HTTP/1.1 402 Payment Required
Content-Type: text/plain; charset=utf-8

402 Payment Required

How to check for a 402 response

cURL

# Print only the status code
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/

JavaScript (Node.js)

const res = await fetch("https://example.com/");
if (res.status === 402) {
  console.log(res.status, res.statusText);
}

Python

import requests

res = requests.get("https://example.com/")
if res.status_code == 402:
    print(res.status_code, res.reason)

Go

res, err := http.Get("https://example.com/")
if err != nil {
	log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 402 {
	fmt.Println(res.Status)
}

Specification

402 Payment Required is defined in RFC 9110, section 15.5.3.

  • 403

    Forbidden

    The server understood the request but refuses to allow it. Logging in again will not help unless your account gets access.

  • 401

    Unauthorized

    The request needs authentication. You are not logged in, or the credentials or token you sent are missing, invalid or expired.

  • 429

    Too Many Requests

    You sent too many requests in a short time and hit a rate limit. Wait, then retry, ideally after the Retry-After time.

← all 63 HTTP status codes

Type to search posts, tools and projects.

Keyboard shortcuts

Search+Kor/
Go to homegthenh
Go to bloggthenb
Go to projectsgthenp
Go to timelinegthent
Show this help?
Close search or helpesc