DOCSx402 protocol

HTTP 402 — finally useful.

x402 is a small extension to HTTP that lets a server demand stablecoin payment before fulfilling a request. The buyer's wallet signs a one-shot authorization (EIP-3009), the server settles, the request continues. No keys, no invoicing, no dashboards.

REQUEST
GET /v1/run HTTP/1.1
Host: agent.example.com
// no auth, no payment
RESPONSE — 402 Payment Required
HTTP/1.1 402 Payment Required
x-402-price: 0.004 USDC
x-402-chain: base
x-402-recipient: 0x4f...8a91
x-402-nonce: 0x9c2e...

/01The full handshake

  1. Client hits the endpoint with no payment header. Server responds 402 with price + recipient + nonce.
  2. Client wallet signs an EIP-3009 transferWithAuthorization for that exact (recipient, amount, nonce).
  3. Client retries the original request with header x-402-payment: <sig>.
  4. Server submits the signed transfer (or batches it). On settle, server fulfills the request.
  5. If the response is 5xx, the SDK auto-issues a refund using the same primitive in reverse.

The whole roundtrip — including the chain settle on Base — runs in roughly 800ms p50.

/02Why this is good for agents