Clawy / Guides / What is x402

What is x402?

An open protocol that turns "HTTP 402 Payment Required" — the status code that sat unused for 30 years — into actual payments. It lets a program pay for an API call with stablecoins, no account and no API key.

Every API today gates access with an API key you sign up for, store, and bill against a monthly plan. That works for humans clicking through a dashboard. It's friction for software — especially AI agents that need to call a service once, pay for exactly that, and move on. x402 removes the account entirely: the price is in the response, and the client pays per request.

The flow, in three steps

1
The client calls the endpoint with no payment. The server responds 402 Payment Required and includes the price and where to pay (in a header).
2
The client signs a stablecoin payment for that exact amount — typically USDC on Base — using an EIP-3009 authorization (a signature, no on-chain transaction from the client).
3
The client retries the same request with the signed payment in an X-PAYMENT header. A facilitator settles it on-chain, the server returns 200 OK with the result.
POST /v1/chat/opus            -> 402  (PAYMENT-REQUIRED: amount=150000, payTo=0x...)
   sign EIP-3009 for 0.15 USDC
POST /v1/chat/opus + X-PAYMENT -> 200  { "choices": [ ... ] }

Why it matters for AI agents

It's early — the ecosystem of paying agents is still forming — but it's the cleanest answer to "how does one program pay another for a single call" that exists today.

Common questions

Is it a blockchain transaction every call? The client only signs; a facilitator batches/settles. The buyer needs a funded wallet, not gas per call.

What does it cost to accept? You receive stablecoins to your wallet; facilitator fees are small. No payment-processor account or monthly fee.

Which chains? Base mainnet is most common (USDC); Solana and others are supported by some services.

→ Call one in 5 minutes. A complete, copy-paste x402 client (Node) that hits a live endpoint, signs the payment, and gets a response — start on a $0.04 tier.

Want to sell a pay-per-call API yourself? Two things decide whether it makes money: getting the integration right, and pricing it so token costs don't eat your margin.

→ AI API Pricing Kit (€19). An Excel cost/margin model + drop-in margin-guard code so a flat per-call price never costs you more than you charge, plus an offline calculator and quick-start.