Skip to content

Learn

x402, explained. A price inside the HTTP request.

x402 is an open way to pay for a single HTTP request. The server answers with a price, the client pays and asks again, and the result comes back. No account and no API key.

Updated

The short version.

HTTP has had a status code for payments since the 1990s: 402 Payment Required. It was reserved for future use and never got a standard meaning. x402 gives it one.

When a client asks for something that costs money, the server answers 402 with the price, the token, the network and the address to pay. The client signs a payment for exactly that amount and sends the same request again with the signature in a header. The server checks the payment, does the work, settles the payment and returns the result.

Because the whole exchange is ordinary HTTP, any program can do it, including an AI agent. Nobody has to create an account, accept terms in a browser or paste an API key.

One paid call, step by step.

This is the flow Sourcy runs for every paid call, using x402 version 2.

  1. 1Request. The agent asks for a service, for example a screenshot of a web page.
  2. 2402 Payment Required. The server answers with what it accepts: the scheme (exact), the network, the price in USDC and the address that gets paid.
  3. 3Sign and retry. The client signs a payment for that exact amount and sends the request again with a PAYMENT-SIGNATURE header.
  4. 4Verify, run, settle. The server has a facilitator verify the payment, runs the call, and only then settles. If the call fails, it does not settle.
  5. 5200 and a receipt. The result comes back with a PAYMENT-RESPONSE header that records the settlement.
Example exchange, shortened
POST /v1/buy/<provider>/capture
← 402 Payment Required
  accepts: exact · eip155:8453 · 0.002 USDC · payTo 0x…

POST /v1/buy/<provider>/capture
  PAYMENT-SIGNATURE: <signed payment>
← 200 OK
  PAYMENT-RESPONSE: <settlement record>

Why it suits AI agents.

Most paid APIs were built for people: sign up, verify an email, add a card, copy a key, pick a plan. An agent cannot do most of that, and a person does not want to repeat it for every service the agent might need once.

With x402 the price is part of the response, so an agent can see what something costs before it pays, pay only for what it uses, and stop when its budget says so. Prices can be fractions of a cent, which subscriptions and card payments cannot handle.

What x402 does not do.

x402 moves a payment. It does not decide whether the payment is a good idea. Limits such as a maximum per purchase or a daily cap have to live somewhere else. In Sourcy they live in the wallet's rules, checked before every payment.

A payment in the exact scheme is a token transfer. Once it settles it is final, so the order matters: a careful server verifies first, does the work, and settles only when the work succeeded.

Questions. Short answers.

Is x402 a cryptocurrency?

No. x402 is a protocol on top of HTTP. Payments in it are usually made in a stablecoin such as USDC, which is designed to track the US dollar. Sourcy uses USDC on Base.

Does the agent need gas to pay?

Not with the exact scheme on an EVM network: the facilitator submits the transfer, so the paying wallet only needs USDC.

Who created x402?

x402 was introduced by Coinbase as an open protocol. Sourcy is not affiliated with Coinbase; it uses the open-source x402 packages and a payment facilitator.