x402 v1 and x402 v2
The x402 spec moved on, and clients did not move together. Rather than pick a side and break half the ecosystem, the gateway speaks both dialects on every paid response, and accepts a payment proof in either header. Most integrators never need this page: an x402 SDK handles it. Read on if you are writing the402 loop yourself, or debugging a client that pays correctly
but is still refused.
The challenge, one 402, two dialects
A paid route answersHTTP 402 carrying both at once:
Alongside the v2 header the response also carries
X-Payment-Amount,
X-Payment-Currency and X-Payment-Protocol.
A v1 client reads the body and ignores the header. A v2 client reads the header
and ignores the body. Neither has to know the other exists.
The proof, either header
PAYMENT-SIGNATURE first and falls back to X-Payment, so
v1 and v2 clients can pay the same route. New integrations should send
PAYMENT-SIGNATURE.
Most of these docs show x-payment, because it is the header the widely
deployed SDKs still send. It keeps working. It is not the header to reach for in
new code.
Which one your client speaks
- x402-fetch and the older reference SDKs: v1. They parse the body and send
x-payment. - x402scan’s embedded wallet and current reference SDKs: v2. They parse the
PAYMENT-REQUIREDheader and sendPAYMENT-SIGNATURE. @apiosk/sdk: handles the negotiation for you, see /guides/sdk.
Related links
- Consumer flow: /guides/consumers
- Payment options: /guides/payment-options
- Multi-chain settlement: /guides/multichain
- Errors and retries: /guides/errors-and-retries