Skip to content
woza.ink
← Notebook
6 min readWritten with AI

Part 1 of 3 in Agent payments

Exploring the x402 Standard

x402 turns HTTP's long-dormant 402 status code into a way to pay for a single API call with stablecoins. What goes over the wire, who does what, and where it falls short.

On this page
  1. Why bother
  2. What goes over the wire
  3. The facilitator
  4. Paying without gas
  5. Four ways to charge
  6. Trade-offs
  7. Where it fits
  8. Further reading

Correction, November 2026. The first version of this post described x402 as a format for explaining authorization decisions. That was wrong: x402 is a payment protocol. This is a full rewrite.

HTTP has had a status code for "pay me" since the 1990s. 402 Payment Required was reserved for future use and then left there1, because the web never got a payment method a server could ask for in a response.

x402 is the attempt to finally use it. A server answers a request with a price2, the client pays in stablecoins and retries the same request, and the data comes back. No account, no API key, no invoice at the end of the month.

It started at Coinbase and launched in May 2025. Since July 2026 it has lived at the x402 Foundation under the Linux Foundation, with about 40 member organizations. The protocol charges no fee of its own; you pay the network's.


Why bother

Normal API billing assumes a person: sign up, add a card, copy a key, get a bill. That works when a developer picks a vendor once. It doesn't work for an AI agent that found a service a minute ago and needs one response from it.

It doesn't work for small amounts either. Card fees make it impossible to charge a tenth of a cent, so APIs sell subscriptions and prepaid credits instead. x402 makes a single request the thing you buy.


What goes over the wire

The exchange uses three headers, each carrying Base64-encoded JSON:

Header Sent by Carries
PAYMENT-REQUIRED Server, with the 402 What it costs and how to pay
PAYMENT-SIGNATURE Client, on the retry The signed payment
PAYMENT-RESPONSE Server, with the final answer What happened at settlement

Here's what PAYMENT-REQUIRED decodes to, trimmed from the spec's example:

{
  "x402Version": 2,
  "error": "PAYMENT-SIGNATURE header is required",
  "resource": {
    "url": "https://api.example.com/premium-data",
    "mimeType": "application/json"
  },
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:84532",
      "amount": "10000",
      "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
      "payTo": "0x209693Bc6afc0C5328bA36FaF03C514EF312287C",
      "maxTimeoutSeconds": 60,
      "extra": { "name": "USDC", "version": "2" }
    }
  ]
}

accepts is a menu: a server can list several chains and tokens, and the client picks one it can pay with. network is a CAIP-2 chain ID3, here the Base Sepolia testnet. amount is in the token's smallest unit, so 10000 is 0.01 USDC.

One entry from the accepts list, field by field. Scheme exact, network eip155:84532 is Base Sepolia, amount 10000 is 0.01 USDC, asset is the token contract, payTo is the seller, and maxTimeoutSeconds 60 is the time limit One entry in the accepts menu scheme exact how to charge network eip155:84532 Base Sepolia testnet amount 10000 0.01 USDC asset 0x036C…CF7e which token payTo 0x2096…287C who gets paid maxTimeoutSeconds 60 time limit
One entry, decoded. The amount is in USDC's smallest unit.

The client signs a payment matching one entry and resends the same request with it in PAYMENT-SIGNATURE. The server answers with the data and a PAYMENT-RESPONSE holding the transaction hash.

Developers rarely touch any of this. A middleware does it: you declare a price per route, like "$0.001" on GET /weather, and it handles the rest.


The facilitator

Checking a payment and putting it onchain means running chain infrastructure, which most API authors don't want to do. So x402 lets the server hand both jobs to a facilitator, an optional service with two main endpoints.

/verify is read-only. For the default EVM method it checks that the signature recovers to the payer, that the payer has the balance, that the amount and validity window meet the requirement, and that the token and network match. Then it simulates the transfer.

/settle puts the transaction onchain and waits for it to confirm.

The agent requests a resource, gets a 402 with the price, and retries with a signed payment. The server asks the facilitator to verify it, does the work, then asks the facilitator to settle. The facilitator sends the transaction onchain, pays the gas and confirms, and the server returns the data. Verifying is read-only, so nothing moves until settle Agent Server Facilitator GET /weather 402 and the price Signed payment /verify valid /settle confirmed 200 and the data Does the work Sends it onchain, pays the gas Verify is read-only. Nothing moves until settle.
The server verifies first, does the work, and only then settles. The facilitator broadcasts the transaction and pays the gas.

The facilitator never holds the money. The client's signature fixes the amount and the destination, so it can't change either. The public facilitator at x402.org only serves testnets, so production means picking another one or running your own.


Paying without gas

An agent shouldn't need a second balance just to pay for gas. On EVM chains the default path is EIP-3009: the client signs a transferWithAuthorization message4, the facilitator broadcasts it and pays the gas, and the tokens move straight from payer to payee.

Tokens without EIP-3009 go through Permit2 instead. That needs a one-time approval, which the user pays gas for unless a gas-sponsoring extension covers it.


Four ways to charge

  • exact transfers a specific amount. This is the weather API case.
  • upto authorizes a maximum, and the seller settles what was actually used, up to that cap. It suits anything priced by what the response turned out to cost.
  • batch-settlement uses escrow and offchain vouchers, redeemed onchain in batches, for high-frequency use.
  • auth-capture authorizes a maximum and gives the payment a lifecycle: funds can be held, captured for less, voided or refunded.
A sketch of the four schemes. Exact moves the whole authorized amount. Upto authorizes a cap and the seller settles what was used. Batch-settlement collects offchain vouchers and redeems them onchain together. Auth-capture holds a maximum, then captures, voids or refunds it Authorized against charged. A sketch, not data. exact All of it, at once upto What was used, up to the cap batch-settlement Vouchers offchain, one redemption auth-capture Held, then captured, voided or refunded cap captured released to the client
Four answers to how much the seller takes. A sketch, not data.

Trade-offs

The server works before it's paid. In the default flow the order is verify, resource, settle, respond. A payment can pass verification and still fail settlement, and the spec doesn't give the server anything back when that happens. For a cheap response that's noise. For an expensive job it's real exposure.

Clients can't safely retry. Once PAYMENT-SIGNATURE is sent, the outcome is unknown until the server answers. The docs tell clients not to create a second payment automatically, and a settlement_pending error is "non-terminal, not permission to pay again." A timeout is harder to handle here than on a normal API call.

Once PAYMENT-SIGNATURE is sent the outcome is unknown. A 200 with PAYMENT-RESPONSE means it's done. settlement_pending is non-terminal, so reconcile the transaction hash onchain. With a timeout, don't create a second payment, because the server may have settled the first PAYMENT-SIGNATURE sent From here the outcome is unknown What can come back 200 and the data PAYMENT-RESPONSE holds the hash Done settlement_pending Non-terminal: it may still confirm Check the chain A timeout The first payment may have settled Don't pay again
Only one of the three answers ends the matter.

Confirmation is latency. With exact, every call waits for a chain confirmation. That's quick on a fast L2, but it's still slower than checking an API key.

Paying isn't permission. x402 says how to pay. It doesn't say whether this agent is allowed to spend, or whether the server on the other end is any good. Those are separate problems with separate protocols.


Where it fits

x402 is the settlement layer: it moves the money and nothing else. AP2 handles whether an agent may spend, ACP handles the checkout, and L402 is the real rival5, using the same status code over Lightning. The Agentic Payments Stack maps all of them. ERC-8004 covers the other question, which agent you're dealing with.

The appeal is how little it asks for. One status code, three headers and a signature, on top of HTTP, which everything already speaks.


Further reading

Notes

  1. 1Context

    HTTP status 402 ("Payment Required") was reserved in the original HTTP/1.1 spec (RFC 2068) with the intention of supporting digital cash or micropayment schemes. It sat unused for over 25 years because no universal payment system materialized. The spec literally says: "This code is reserved for future use."

    source →
  2. 2Note

    Despite 402's "reserved" status, it has seen informal adoption. Google APIs return 402 when a developer exceeds quotas. Shopify uses it when a store hasn't paid its fees. Stripe returns it for blocked payments. These uses are technically non-standard but demonstrate the demand for a payment-aware HTTP status code.

    source →
  3. 3Source

    CAIP-2 is a chain-agnostic way to name a blockchain: a namespace plus a reference. eip155:8453 is Base, and solana:... names a Solana cluster. It's why one network field can describe any ecosystem x402 supports.

    source →
  4. 4Source

    EIP-3009 lets a token holder sign a transfer that someone else submits. The signature carries a validity window and a random nonce, so it can't be replayed, and whoever broadcasts it pays the gas without being able to change the amount or the recipient.

    source →
  5. 5Counter

    L402 answers the same 402 with a macaroon and a Lightning invoice. Proof of payment lives in the credential, so no facilitator has to attest that anything settled. It avoids x402's facilitator entirely, at the cost of needing a Lightning wallet that returns payment preimages.

    source →