Concepts

x402 in one page

x402 is a micro-spec for HTTP-native, on-chain payments. It reuses the long-forgotten HTTP status code 402 Payment Required and defines a standard JSON body that tells the caller how to pay. The spec lives at x402.org.

The flow

Client                                  Agent
  │                                        │
  │  POST /a2a  (no payment header)        │
  ├───────────────────────────────────────▶│
  │                                        │ 402 Payment Required
  │                                        │ Body: accepts: [...schemes]
  │◀───────────────────────────────────────┤
  │                                        │
  │  ── sign a payment for one scheme ──   │
  │                                        │
  │  POST /a2a  (X-PAYMENT: <signed>)      │
  ├───────────────────────────────────────▶│
  │                                        │ verify signature + settle on-chain
  │                                        │ 200 OK + agent response
  │◀───────────────────────────────────────┤

No accounts. No keys to rotate. No invoices.

The 402 response

When a caller hits a gated endpoint without payment, the server replies 402 with a body like:

{
  "accepts": [
    {
      "scheme": "exact",
      "price": "0.01 USDC",
      "chain": "base-sepolia",
      "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
      "payTo": "0xYourAgentWallet..."
    }
  ]
}

The caller picks one scheme, signs a payment (EIP-712 for EVM), and retries with X-PAYMENT: <base64-json>. The server verifies the signature, settles on-chain, and serves the response.

Schemes

Scheme Semantics
exact One call, one fixed price. The simplest case.
(future) stream / session Metered usage, time-boxed sessions. Not required for A2X v0.x.

A2X cares about exact first — it covers "pay per agent call" end-to-end.

Why this composes with A2A

A2A gives you a public endpoint. x402 gives you a public paywall. Together: a public, monetized agent endpoint that any caller can discover and pay without pre-arrangement. That's the bet A2X is built on.

Where A2X fits

Today: x402 middleware in front of your A2A route is manually wired. See the Preview step in the Quickstart.

Next release: SDK helpers for

  • Server-side: withX402({ price, chain, payTo }) middleware.
  • Client-side: automatic 402 → pay → retry loop inside A2XClient.

Next