ApiSimul logo ApiSimul — the switchboard

HTTP 402 — Payment Required

HTTP 402 was reserved for a pay-per-request web that never became standard, yet the code found a second life: modern APIs use it as an application-level signal that a payment or quota issue blocks the request.

When 402 shows up

Mocking a 402 response

A response with this status can be faked end to end with a local mock rule — no backend changes needed. The configuration below mirrors the rule fields the ApiSimul editor uses (method, path, status, delay in milliseconds, response body):

{
  "method": "GET",
  "path": "/api/reports/export",
  "status": 402,
  "delay": 200,
  "enabled": true,
  "body": {
    "error": "quota_exceeded",
    "plan": "free",
    "upgradeUrl": "https://example.com/pricing"
  }
}

Dynamic placeholders such as {{random.name}}, {{string.uuid}} or {{number.int 1 100}} can appear inside the body to vary each response, which keeps client-side list rendering and retry logic honest during development.

Frequently asked questions

What does HTTP 402 mean?
Standardised semantics say the request is refused until payment terms are met; in practice the meaning is defined by each API that returns it.

How can I test a 402 response without a real backend?
Define a mock rule with the method and path your client requests and set the status to 402. The example configuration above returns this response after the listed delay, so the client exercises its 402 handling exactly as it would against a live server.

Related status codes

Need the response in your own project? Spin up rules for any status with the ApiSimul mock server, or browse every status code page.