What Is x402? The HTTP Payment Protocol for AI Agents
x402 is an open protocol that turns the long-dormant HTTP 402 "Payment Required" status code into a working payment handshake, settled in USDC stablecoins. When an AI agent hits a paid endpoint, the server answers with a price, the agent's wallet signs the payment, and the data returns, all in one HTTP round-trip with no API keys and no signup.
The history of HTTP 402
The 402 status code was reserved in the HTTP/1.1 spec back in 1997, then sat unused for close to thirty years. Browsers and servers never agreed on what a "payment required" response should carry, so it stayed a placeholder. x402 gives 402 a concrete definition: the server returns structured payment terms (a price, a currency, a destination address, and a chain), and the client pays against them.
How the x402 handshake works
The exchange is four steps inside one round-trip. The agent makes a normal request. The server replies with HTTP 402 and a JSON body listing the price, the currency (USDC), a destination address, and the settlement chain. The agent's wallet signs a USDC transfer and retries with an X-Payment header. The server verifies the payment and returns the resource. There is no checkout redirect, no OAuth step, and no billing dashboard.
Why x402 matters in 2026
Autonomous agents discover services at request time and call them thousands of times per task. API keys tied to a human's credit card and monthly subscription tiers do not fit that pattern. x402 lets an agent read the price from the 402 response, weigh it against a budget, and pay per call, so it can use a service it has never registered for. That shift, from key-driven access to task-driven access, is what makes runtime API selection practical.
What x402 replaces
x402 collapses the usual stack of API keys, subscriptions, and billing dashboards into one wallet balance. The payment authorizes the request, so providers do not have to build user management or invoicing, and developers do not have to track a credential for every vendor. One funded balance covers every provider that speaks the protocol.
How MCP servers integrate x402
For tool-calling agents, an MCP server can act as a payment-aware proxy. It handles the 402 handshake on the agent's behalf, so the tool author writes no custom payment logic and the language model sees the endpoint as if it were free. AgentCash ships an MCP server you install into environments like Cursor and Claude Code.
How AgentCash uses x402
AgentCash plays two roles in the flow: the client, an agent wallet that signs USDC payments, and the router, an index of x402-protected endpoints the agent can discover. The AgentCash index currently spans 30 priced endpoints with a median price of $0.028 per call, ranging from $0.002 to $0.440 as of April 2026, settling on Base, Solana, and Tempo. Install it with npx agentcash.
Tradeoffs and current limits
x402 needs server-side support, and adoption is still early, so not every API answers with a 402 yet. Settlement finality depends on the chain, with Base and Solana confirming in seconds or less. And because an agent can spend on its own, you set per-call and per-session caps so a runaway loop cannot drain the balance.
Related
References: the HTTP 402 status code on MDN and the x402 protocol site.
Frequently asked questions
What happens when an agent receives an HTTP 402?
The server returns a 402 response with a JSON body naming the price, the USDC amount, a destination address, and the settlement chain. The agent's wallet checks the price against its spending rules, signs a USDC transfer, and retries the request with an X-Payment header. The server verifies payment and returns the data.
Which blockchains settle x402 payments?
AgentCash settles x402 payments in USDC on Base, Solana, and Tempo. The protocol itself is chain-agnostic, so the API provider names the chain it wants in the 402 response and the agent's wallet signs a transfer on that chain. You fund one balance and the router matches payments to the right chain automatically.
Do I have to sign up with each API provider?
No. With x402 the payment itself is the authorization, so one funded USDC wallet covers every x402-protected provider. There are no per-vendor accounts, API keys, or billing dashboards to manage. You send USDC to a single address once, and your agent can then call any endpoint that speaks x402.
How is x402 different from the Lightning Network?
Both move small payments, but x402 is built directly into HTTP using the existing 402 status code and settles in USDC stablecoins, which keeps pricing stable. Lightning is a Bitcoin layer with its own channels and network. x402 targets machine-to-API payments, so any HTTP client can speak it without joining a separate network.
Put it into practice
AgentCash gives your AI agent a wallet to pay for any payment-protected API — no keys, USDC on Base.