How does x402 work?

x402 is an open payment standard, started by Coinbase, that uses the HTTP status code 402 Payment Required. The server answers a request with 402 and a price; the client signs a stablecoin payment (usually USDC) and sends the same request again with the signed payment in a header; the server checks it, settles it on-chain and returns the result. There are no accounts or API keys, which is why it suits AI agents paying per request.

See the API Email Address Check API — format, mail servers, disposable · $0.01 / call

The flow in four steps

  1. The client sends a normal request, for example a POST with JSON.
  2. The server answers 402 with a PAYMENT-REQUIRED header (base64 JSON) saying what to pay: amount, token, network and the address to pay to.
  3. The client's wallet signs a payment authorization for exactly that amount and repeats the request with a PAYMENT-SIGNATURE header.
  4. The server has a facilitator verify the signature and settle the transfer on-chain, then returns the result with a PAYMENT-RESPONSE header holding the transaction id.

A real 402 from one of our APIs

This is what our $0.01 email check answers before payment (shortened). The same JSON is in the body and, base64-encoded, in the PAYMENT-REQUIRED header.

POST https://iamai.markets/api/x402/services/8slmXVBtEEfw
{"email": "name@gmail.com"}

HTTP/1.1 402 Payment Required
{
  "x402Version": 2,
  "resource": {"url": "https://iamai.markets/api/x402/services/8slmXVBtEEfw", ...},
  "accepts": [{
    "scheme": "exact",
    "network": "eip155:8453",
    "amount": "10000",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "payTo": "0x...",
    "maxTimeoutSeconds": 300,
    "extra": {"name": "USD Coin", "version": "2"}
  }],
  "extensions": {"bazaar": {...}}
}

What the signature is

In the "exact" scheme on Base, the wallet signs an EIP-3009 transferWithAuthorization: a permission for a transfer of that exact amount to that exact address, with a one-time nonce and a short validity window. Signing doesn't move money by itself. The facilitator submits it on-chain, so the buyer doesn't need ETH for gas.

What a careful server checks

How to try it

You need an x402 v2 client and a wallet with USDC on Base. Any x402 v2 client works, for example Coinbase's x402 packages or Coinbase AgentKit with the iamai-agentkit plugin. Point it at any of our 17 APIs, from $0.01 per call. To see what the APIs return before setting up a wallet, use the free tries on their listing pages.

The product

Questions

Is x402 a blockchain?

No. It's a way to ask for and send payments over HTTP. The payment itself settles on a blockchain, such as Base.

Which coins does it use?

Typically USDC, a dollar stablecoin. Our endpoints accept USDC on Base.

Can a payment be reversed?

On-chain transfers have no chargebacks. That's why our APIs settle only after the call succeeds.

Related

Updated 2026-12-01