# HTTP 402 Payment Required: what it means and how x402 uses it

> HTTP 402 Payment Required is still only reserved in the HTTP standard. What it means, how to fix it, and a real x402 402 → pay → 200 exchange, header by header.

Source: https://hashspan.dev/learn/http-402-payment-required

By Selim Aytaç, maintainer · Published Oct 21, 2026

## Short answer

402 Payment Required tells the client that the resource costs money and no acceptable payment came with the request. The HTTP standard, RFC 9110, still only reserves it for future use, so each service defines what to do next. x402 gives it a full flow. The 402 carries a price in a header, and the client signs a payment and retries. The 200 carries the settlement's transaction hash.

## What does HTTP 402 Payment Required mean?

It means "pay first". The server would answer the request, but it costs money and no acceptable payment came with it.

For a long time that was all. [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.3), the HTTP standard, has one line on it: the status code "is reserved for future use". There is no standard way to say what to pay, how, or to whom.

A [2026 Internet-Draft](https://www.ietf.org/archive/id/draft-nottingham-httpbis-402-00.html) proposes a meaning. The resource "requires payment", and "no acceptable payment has been made". The draft says a server sending 402 should tell the client how to pay, in headers or in the body. It is a draft, not a standard yet.

## Who sends 402 today?

Each service gives it its own meaning:

| Who | What the 402 means | What comes with it |
|---|---|---|
| [Stripe's API](https://docs.stripe.com/api/errors) | "Request Failed": the parameters were valid, but the request failed | an error object that says why |
| [Cloudflare pay per crawl](https://developers.cloudflare.com/ai-crawl-control/features/pay-per-crawl/use-pay-per-crawl-as-ai-owner/crawl-pages/) | an AI crawler must pay for the page | a `crawler-price` header; the crawler retries with `crawler-exact-price` or `crawler-max-price` |
| [x402](https://github.com/coinbase/x402/blob/main/specs/transports-v2/http.md) | this request costs money, payable on chain | a `PAYMENT-REQUIRED` header with the price, the token and who gets paid |

So the fix depends on the sender. Read the response's headers and body before anything else.

## How do I fix a 402 Payment Required error?

1. **Read what came with it.** A price header means the service wants a payment for this request. An error body or error header says why the request failed.
2. **If it is x402, pay and retry.** Decode the `PAYMENT-REQUIRED` header, check the price against your limit, sign, and send the request again with `PAYMENT-SIGNATURE`. The x402 client libraries do this for you.
3. **If it is a payment API,** read the error code. It says what to fix on the account, and a plain retry usually fails again.
4. **In an agent, cap the spend before it signs.** A tool that pays on every 402 will pay whatever it is asked.

## What is x402?

x402 is an open protocol that turns 402 into a payment flow over HTTP. The price, the payment and the receipt each travel in a header, base64-encoded JSON. A **facilitator** checks the payment and settles it on chain, so the server can leave the chain work to it.

In the flow below, the agent has no account with the service. It only needs a wallet that holds the token. For the other ways agents pay, such as cards with limits, see [how AI agents pay](https://hashspan.dev/learn/ai-agent-payments).

## What does a real 402 → pay → 200 look like?

We ran one payment on a local chain, with the x402 SDK's server and facilitator, and logged every request and header:

Figure: A real x402 exchange. 1: the agent sends GET /weather and gets 402 Payment Required in 2 ms, with a PAYMENT-REQUIRED header: x402Version 2, scheme exact, network eip155:84532, amount 1000, payTo and maxTimeoutSeconds 60. 2: the agent signs an EIP-3009 token transfer, a signature and not a transaction, so no gas. 3: it sends GET /weather again with a PAYMENT-SIGNATURE header holding the authorization and a 132-character signature. The API asks the facilitator to verify and settle; the facilitator sends the transfer and pays the gas. The API answers 200 OK with the weather in 1035 ms, and a PAYMENT-RESPONSE header: success true, the transaction hash and the network.

*How we measured: one payment on 2026-10-21, local Anvil 1.8.3 as chain 84532, the x402 SDK's server and facilitator in the same process, @x402/core 2.28.0, @hashspan/x402 1.3.1.*

Three things stand out:

- **The first answer is fast and free.** The 402 took 2 ms and carried only the price. Nothing was signed yet.
- **The agent never sends a transaction.** It signs a transfer authorization ([EIP-3009](https://eips.ethereum.org/EIPS/eip-3009)), and the facilitator puts it on chain.
- **The 200 carries the proof.** `PAYMENT-RESPONSE` names the transaction, so the client can check the payment on chain.

The paid request took 1035 ms because the server waited for the settlement before it answered. Most of that wait was the facilitator checking for the receipt once a second, viem's default for Base. With checks every 50 ms, the paid request took about 76 ms ([x402 vs MPP](https://hashspan.dev/learn/x402-vs-mpp#is-one-faster)). On a public network, it also waits for a block.

## What changed from x402 v1 to v2?

| Part | v1 | v2 |
|---|---|---|
| Price on the 402 | JSON body | `PAYMENT-REQUIRED` header |
| Payment from the client | `X-PAYMENT` header | `PAYMENT-SIGNATURE` header |
| Settlement result | `X-PAYMENT-RESPONSE` header | `PAYMENT-RESPONSE` header |
| Network names | `base-sepolia` | CAIP-2 ids, `eip155:84532` |

In both, a failed settlement comes back as another 402. `PAYMENT-RESPONSE` (`X-PAYMENT-RESPONSE` in v1) then says `success` false, with an `errorReason` such as `insufficient_funds`. Sources: the [v1](https://github.com/coinbase/x402/blob/main/specs/transports-v1/http.md) and [v2](https://github.com/coinbase/x402/blob/main/specs/transports-v2/http.md) HTTP transport specs.

## How do I see x402 payments in a trace?

In plain words: the agent's tool can say "done" while the payment failed. A trace puts the payment next to the step that made it, so you can tell.

**In a hashspan trace:**
`@hashspan/x402` records each payment as a span. From the run above:

  - `payment 84532`: `blockchain.payment.protocol` `x402`, `x402.scheme` `exact`, `blockchain.payment.amount` `1000`, `blockchain.payment.status` `settled`, `blockchain.payment.verified` `true`, and the settlement's `blockchain.tx.hash`
  - `confirm 84532`: the facilitator's transaction, `blockchain.tx.status` `success`, gas used 82,594, linked to the payment span

There is no `send` span: the agent never sent a transaction. The fee on the confirm span is the facilitator's. The [x402 tutorial](https://hashspan.dev/docs/x402-tutorial) builds this agent step by step, and the [x402 adapter](https://hashspan.dev/docs/adapters/x402) lists every attribute.

## FAQ

### Is 402 an official HTTP status code?

It is registered, but RFC 9110 only says it is reserved for future use. A 2026 Internet-Draft proposes a meaning: the resource requires payment, and none acceptable was made. It is a draft, not a standard.

### How do I fix a 402 error?

Read what the server sent with it. Stripe's API uses 402 when the parameters were valid but the request failed, and its error says why. A pay-per-request API using x402 puts the price in a PAYMENT-REQUIRED header: pay it and retry. Otherwise check your plan, credits or billing with that service.

### What is the difference between 401, 402 and 403?

401 means the request lacks valid authentication. 403 means the server understood the request and refuses it. 402 means it would serve the request once it is paid for.

### Does the agent pay gas with x402?

No. In the exact scheme on EVM, the agent signs a token transfer authorization. The facilitator sends the transaction and pays the gas, as in our run.

### What changed between x402 v1 and v2?

v1 put the price in the 402's JSON body and used the X-PAYMENT and X-PAYMENT-RESPONSE headers. v2 moves everything into headers: PAYMENT-REQUIRED, PAYMENT-SIGNATURE and PAYMENT-RESPONSE, and names networks with CAIP-2 ids such as eip155:84532.
