Skip to content

What is x402?

x402 revives the long-reserved HTTP status code 402 Payment Required as a real payment flow for machine-to-machine commerce. A resource advertises its price in the response itself; the client pays at request time with a signed payload; the server verifies and settles before doing the work. No accounts, no API keys, no invoices, no checkout pages.

  1. The client requests a paid resource, e.g. POST /services/token-risk.
  2. The server responds 402 Payment Required with a PAYMENT-REQUIRED header: a Base64-encoded description of accepted payment terms (scheme, network, asset, amount, pay-to address).
  3. The client picks a supported option and creates a signed payment payload.
  4. The client retries the same request with a PAYMENT-SIGNATURE header.
  5. The server verifies the payload — usually through a facilitator — and settles the payment.
  6. The server runs the handler and returns the resource, attaching a PAYMENT-RESPONSE header with settlement confirmation.

One request, one retry, one payment. Client libraries such as @x402/fetch wrap fetch so the 402-sign-retry loop is invisible to application code.

The facilitator is a service exposing /verify and /settle. It abstracts chain-specific details and broadcasts the client-signed transaction without ever custodying funds — the payment is authorized by the buyer’s signature, not by handing money to a middleman. Facilitators are public infrastructure defined by the protocol — the key property is that your funds move only on your own signature.

x402 identifies networks with CAIP-2 ids. This project uses:

Concept Value here
Scheme exact — fixed-price resources (“this request costs $0.01”)
Network Base (eip155:8453 family); every 402 quote names its network exactly
Asset USDC — string prices like "$0.01" resolve to USDC on Base networks

Other schemes (upto, batch settlement) and other ecosystems (Solana, TON, Stellar, …) exist in the protocol but are not used by this API today.

Traditional paid APIs assume a human created an account, entered a card, and generated an API key. Autonomous agents can’t do any of that mid-task — but they can hold a wallet and sign a payload. With x402:

  • The resource advertises its own price; agents discover cost programmatically.
  • The buyer needs no pre-existing relationship with the seller.
  • Sub-cent-scale transactions are economically viable.
  • The server verifies payment before doing expensive upstream work.

That is exactly the model 1-cent-requests is built on: an agent finds a service via GET /services, reads its JSON input schema, pays a cent, and gets context back. See Your First Paid Request to run the loop yourself, and Agent Integration for client code.