x402: how AI agents pay for APIs

An AI agent that needs a web search, a company record or a transcription usually hits the same wall: create an account, add a card, copy an API key, pick a subscription. x402 removes that wall. The service states its price in the HTTP response, the agent pays, and the service answers. This guide explains how the protocol works, why it suits agents, what it leaves out, and how to let an agent pay x402 services within limits you set.

Guide by KeybanUpdated 7 min read

What is x402?

x402 is an open protocol that lets a web service charge for a request inside the request itself. The service answers 402 Payment Required with its price; the client pays, usually in USDC, by signing an authorization, and sends the request again with the payment attached. There is no account, no API key and no subscription: the payment is the credential.

The name comes from the HTTP status code 402 Payment Required, reserved in the HTTP specification since the 1990s and almost never used until now. Coinbase created x402 in 2025. In April 2026 the Linux Foundation announced the x402 Foundation, which now stewards the protocol; its members include Cloudflare, Stripe, Google, Visa, Mastercard, AWS and Circle.

How an x402 payment works

One payment takes five steps:

  1. The client asks for a resource. An ordinary HTTP request to an API endpoint.
  2. The service answers 402 Payment Required with its payment requirements: the price, the token, the network, the address to pay and the payment scheme. A service can offer several options.
  3. The client signs an authorization to pay exactly that. For USDC, this is usually an EIP-3009 transferWithAuthorization: a signed message that says “pay this amount to this address before this time”. The client sends no transaction itself and needs no native token for fees.
  4. The client sends the request again, with the signed payment attached.
  5. The service has the payment verified and settled on the blockchain by a facilitator, then returns the resource.

The whole exchange takes a few seconds, and the price can be a fraction of a cent.

The words to know

  • Payment requirements: what the 402 response contains, meaning price, asset, network, recipient and scheme.
  • Scheme: how the price is charged. exact means a fixed price for the request. Other schemes exist or are in progress, such as upto, where the service charges up to a maximum according to usage.
  • Facilitator: the service that verifies the signed payment and settles it on the blockchain on behalf of the seller. The seller chooses it; the buyer only chooses among the options the seller offers.
  • Asset and network: the token and the blockchain the payment is made in, most often USDC on networks such as Base.

Why x402 suits AI agents

An agent cannot fill in a sign-up form, pass a card check or manage a subscription for each supplier it meets. x402 fits the way agents buy:

  • The price is in the response. The agent, or its wallet, can read what a request costs before paying, and compare it with a budget.
  • Small amounts are practical. Paying a fraction of a cent per search makes sense, where card fees would not.
  • No relationship is needed. An agent can pay a service it has never used, once, without anyone in the company creating an account.
  • One integration covers many services. A wallet that pays x402 can pay every service that accepts it.

What x402 does not do

x402 defines how a payment is requested and proven. It says nothing about whether a payment should be made. On its own, the protocol has:

  • no spending limit: nothing stops a client from paying the same request a thousand times;
  • no approval step: there is no moment where a person can say no;
  • no list of allowed suppliers: any service that answers 402 can be paid;
  • no budget across services or across agents;
  • no protection for the key that signs the payments.

All of this falls to the client’s wallet. For an AI agent, it is the part that matters most: an agent that follows instructions found in a web page can be told to pay the wrong service, and a loop can spend a budget in minutes.

x402 and the Machine Payments Protocol

x402 is not the only HTTP payment protocol for agents. In March 2026, Stripe and Tempo launched the Machine Payments Protocol (MPP).

x402Machine Payments Protocol (MPP)
OriginCreated by Coinbase, now the x402 Foundation (Linux Foundation)Co-authored by Stripe and Tempo
PrincipleThe service answers 402 with payment requirements; the client pays and retriesThe service returns a payment challenge; the client presents a payment credential
Payment methodsStablecoins, mostly USDC, on several blockchainsStablecoins on Tempo and other networks, and cards through Stripe
SettlementThrough a facilitator chosen by the sellerThrough the rail chosen, for instance to the seller’s Stripe balance

Both answer the same need: a price an agent can read, and a payment it can make inside an HTTP request. A service can accept both. For the wider picture, from card credentials to mandate protocols, see what agentic payments are.

Paying x402 APIs with Keyban

Keyban’s Agent Wallet pays x402 services for your agents, and adds what the protocol leaves out: a spending policy checked before every payment.

How a payment goes

  1. The agent gives Keyban the service’s URL.
  2. Keyban requests the service itself and reads the real price and recipient from the 402 response, never from the agent.
  3. Keyban checks the service’s domain and the price against the wallet’s policy: cap per payment, day, week and month budgets, allowed destinations. Above the approval threshold, the payment waits in the Inbox for a person. A refused payment stops here, with a reason, before anything is signed.
  4. Keyban builds the EIP-3009 authorization. The agent and Keyban sign it together; the agent cannot change the amount, the recipient or the time window.
  5. The agent sends the request with the payment and gets the result.

The tools the agent uses

Through the Keyban MCP server or CLI:

  • discover_x402_services searches Keyban’s directory of services that accept x402;
  • x402_info checks what a request would cost, without paying;
  • x402_pay makes the request and pays, within the policy.

What your agents can buy

Web search and research (Perplexity, Exa, Tavily, Brave Search, Firecrawl), contact and company data (People Data Labs, Apollo, Hunter), speech and transcription (ElevenLabs, AssemblyAI), models and images (OpenRouter, fal.ai) and more, each paid per call.

What the wallet pays today

The exact scheme, in USDC, on Base mainnet and XDC mainnet; upto is not supported yet. You fund it with USDC you already hold, or by card from 5 euros on Base.

€1 on us at sign-up, no card needed. Free for three months, then top up in euros by card.

If you sell an API

To accept x402, a service adds a middleware that answers 402 with its payment requirements and hands the signed payment to a facilitator. The x402 Foundation lists the reference implementations and facilitators on x402.org. Agents that use a Keyban wallet can then pay your service, as long as its domain is allowed by their policy.

Questions

What does HTTP 402 mean?

402 Payment Required is an HTTP status code that tells the client the resource is paid. It was reserved in the early HTTP specifications but almost never used, until x402 gave it a standard format: the response carries the price and how to pay.

Is x402 a cryptocurrency?

No. x402 is a protocol, not a token. It moves existing assets, most often the USDC stablecoin, whose value follows the US dollar.

Does the agent need ETH or another token to pay fees?

Not with an EIP-3009 authorization: the agent only signs a message, and the facilitator submits it to the blockchain.

Which blockchains does x402 support?

The protocol works on several networks; the service states which ones it accepts. A Keyban agent wallet pays on Base mainnet and XDC mainnet.

Can an AI agent overspend with x402?

The protocol itself sets no limit. The agent’s wallet must enforce one. With Keyban, every x402 payment is checked against a cap per payment, budgets and allowed destinations before it is signed, and payments above a threshold wait for a person.

What is an x402 facilitator?

A service that verifies a signed x402 payment and settles it on the blockchain for the seller. The seller picks the facilitator; the buyer never has to trust it with funds beyond the amount it signed.

NEXT STEP

Let your agents pay x402 APIs, within limits.

Add Keyban to your agent, sign in, set its cap. €1 on us at sign-up, no card needed. Free for three months, then top up in euros by card.

Open my agent’s account — €1 on us