Understanding x402, the Payment Protocol for AI Agents
An AI agent calling a paid API usually halts the moment it receives a billing response. Registering a payment method, choosing a plan, and confirming a charge were all designed for a person to read and operate, and the response the agent gets does little more than point to that screen. HTTP has long had a status code for exactly this situation, 402 Payment Required, yet the code is still defined only as reserved for future use. The signal that payment is needed is thus already in the standard. What was missing is a format an agent can read that says how much to pay, to whom, and by when.
This post covers x402, an open protocol that aims to fill that gap. AI agent payment without human intervention becomes possible once the payment request itself is a standard format the agent can read, and x402 builds that approval flow by carrying payment terms in the 402 response. The post first looks at how human approval becomes a bottleneck as agents move into execution, and at a criterion for deciding which payments can be left to the agent's approval. It then explains the structure of the payment request in a 402 response and the sequence by which a signed authorization leads to verification and settlement, and closes with the delegation and after-the-fact verification problems that recent research has exposed.
The shift to executing agents and the approval bottleneck
As agents move from answering and recommending to executing, booking, buying, and querying paid data, payment has become one step within a tool call. Human approval turns into a bottleneck because of call frequency and billing granularity. An agent working through a single task calls several APIs dozens of times. Some of those APIs are metered resources that charge a small amount per call. If a person must confirm each call, the task's latency is determined by that person's response time. The more often confirmations arrive, the more the person approves without reviewing them. At that point the approval step loses its value as a control. Handing the agent a prepaid balance or an API key up front removes the confirmations, but then there is no per-call record of which terms the agent agreed to when it paid.
The limits of both approaches ultimately stem from the payment request being in a form only a person can read. x402 addresses the problem at the format of the payment request. The server returns the payment terms as a structured object, and the client reads that object, builds a signed authorization, and sends the same request again. Here the client means any application or agent that requests a protected resource and pays for it. The payment data types are defined independently of the transport, so the same structure rides on both HTTP and MCP. A step in which a person read a checkout page and decided becomes a step in which the agent reads fields and checks them against policy. That shift makes it possible to keep a per-call record of what was agreed without calling a person for every request, and it is the precondition for handing payment to an agent.
The line between human and AI agent approval
A payment can be left to an AI agent's approval when the signed authorization fully bounds the payment's effect. In x402's default exact scheme, the client signs the payer, the payee, the amount, a validity window, and a single-use nonce. Because those five values are fixed, a wrong decision by the agent cannot cost more than the signed amount, and the same authorization cannot settle twice. The signature does not cover which resource the payment is for, whether the payee actually is the server providing that resource, or whether the payment can be reversed after settlement. The line for delegation should therefore be drawn by the conditions left outside the signature rather than by the size of the amount.
Client-side budget management is outside the specification's scope, and the client in the reference implementation, @x402/core, splits that decision into stages. Spend controls run first, applying a per-payment ceiling on USD-pegged assets (maxAmountPerPayment, default $1) and an asset allowlist. Policy functions then filter the options by trusted payTo addresses or required schemes, and a selector picks one of the remaining options. Finally, the onBeforePaymentCreation hook can abort the payment just before signing, which also makes it the natural place to attach human approval. With this structure, a payment under the ceiling to an allowlisted payee can be approved by the agent, while an unfamiliar payee or spending that needs a cumulative view goes to a person or a separate policy engine. The reference implementation's ceiling, though, applies per payment. No daily or per-task cumulative cap is documented, so a cumulative budget has to be implemented by whoever deploys it. The structure for evaluating policy just before execution was covered in "From Guardrails to the Execution Boundary — Policy Enforcement for Agent Tool Calls."
The payment request inside a 402 response
In x402 a payment request is expressed as a single PaymentRequired object returned by the server. Under the HTTP transport, a client that requests a protected resource without payment receives status 402 along with a PAYMENT-REQUIRED header. The header value is the object serialized as JSON and then base64-encoded. The object holds the protocol version (x402Version, currently 2), a resource carrying the resource's URL, description, and MIME type, the reason payment is needed (error), and accepts, an array of acceptable payment terms.
Each element of accepts is a PaymentRequirements object describing one set of terms. scheme names the payment method, and network is a CAIP-2 network identifier (for example eip155:8453). amount is a string in the asset's smallest unit, and asset is a token contract address or an ISO 4217 code for fiat currency. payTo is the recipient address, maxTimeoutSeconds is the maximum time allowed to complete payment, and extra holds scheme-specific data and the payment flow (paymentFlow). A server can offer terms on several networks and assets for the same resource. The client picks the one that matches a scheme-and-network pair it has registered and copies it verbatim into its authorization.
The structure is the same over MCP, the path an agent's tool calls already take. Under the MCP transport, a tool call that needs payment returns a tool result with isError: true and carries the same PaymentRequired object in its structuredContent. The client puts its authorization in _meta["x402/payment"] and sends the same tool call again. Because the payment request arrives as structured fields in a tool result, the agent can read and evaluate the terms within the flow of the tool call, without any checkout screen.
From verification to settlement
The authorization the client builds from the chosen terms is a PaymentPayload, consisting of the chosen terms (accepted) and scheme-specific data (payload). For exact on EVM networks, payload is the parameter set of ERC-3009's transferWithAuthorization plus an EIP-712 signature. The parameters are from, to, value, the time the authorization becomes valid (validAfter), its expiry (validBefore), and a random 32-byte nonce. Using random rather than sequential nonces lets many authorizations be created concurrently without ordering conflicts. The token contract records used nonces and rejects a second execution of the same authorization. The client base64-encodes the object, puts it in the PAYMENT-SIGNATURE header, and resends the original request.
The resource server either delegates verification and settlement to a facilitator or performs them itself. A facilitator is a service that verifies signatures and submits transactions on the resource server's behalf. The default authorization flow runs verify, execute the resource, settle, respond, and the POST /verify call used for verification is a read-only check that changes no state. Under the EVM exact scheme, the check first confirms that the signature recovers to the from address and that the balance is sufficient. It then checks that the amount and validity window satisfy the terms and that token and network match, and simulates transferWithAuthorization. Once verification passes, the server executes the resource and POST /settle broadcasts the transaction using the signed authorization. The facilitator pays the gas, but amount and recipient are fixed by the signature and the facilitator cannot change them.
The settlement result becomes a SettlementResponse carrying a success flag, transaction hash, network, and payer, and it returns with the resource in the PAYMENT-RESPONSE header. If the transaction was broadcast but confirmation could not be established, the facilitator returns settlement_pending with the transaction hash, and the caller checks the chain before retrying. Flows that reorder these steps are also defined. upfront settles before the resource executes, and escrow deposits a ceiling before execution and settles the final amount afterward. In the upto scheme, where the amount depends on usage, the server sets the actual amount within the signed maximum and the facilitator checks that the settled amount does not exceed it. In every flow, either verification or settlement happens before the resource executes. Throughout the process the only basis for each decision is the signature and the object's fields, and no human step exists apart from a hook the client chooses to add.
What delegation and after-the-fact verification leave unsolved
The x402 signature fixes amount and payee, but HTTP requests complete synchronously while blockchain settlement finalizes asynchronously. Research published in 2026 used experiments to expose the relationships between those two layers that the signature does not guarantee. The open problems are these.
First, binding the authorization to the resource. In Free-Riding the Agentic Web, researchers from City University of Hong Kong and Zhejiang University showed that the EIP-712 signature covers amount, payee, nonce, and expiry but not the resource. In a test that attached a signature for resource A to a request for a same-priced resource B, all 100 attempts succeeded. 38% of the hosts surveyed exposed same-priced sibling resources. The proposed countermeasure is to include a hash of the HTTP request in the signature. Because today's signature does not record what the agent meant to buy, the mapping between payments and tasks has to be recorded separately in the client's audit log.
Second, the asynchrony between response and settlement. In the same study, sending one authorization in 20 concurrent requests, repeated 50 times on mainnet, produced unpaid duplicate deliveries in 6% of rounds. At 50 requests per second against a settlement endpoint rate-limited to 10 per second, the share of resources delivered without settlement reached 86.95%. In Five Attacks on x402 Agentic Payment Protocol, researchers at Ohio State University, the University of Manchester, and others reported a server that did not atomically record payment identifiers and delivered a resource 248 times for a single payment. A caching reverse proxy was also found serving a paid response to all 1,000 unpaid requests. The server bears most of this loss, but the countermeasures, two-phase settlement and waiting for confirmations, add latency the agent has to absorb.
Third, who settles, and the payer's exposure. ERC-3009's transferWithAuthorization can be submitted by anyone holding the signature. If an intermediary that can see the payment header submits the authorization before the legitimate facilitator, the payer is charged and still does not receive the resource. This attack was reproduced on a testnet, and binding settlement to the facilitator the payer designated was proposed as a countermeasure. In the same work, a single server with crafted metadata in a discovery listing was selected by an LLM agent at a rate of 71.8%. When the selection step before signing is poisoned, the signature merely fixes the wrong payee with precision.
Fourth, reversal and accountability. Settlement under exact has no reversal procedure. The auth-capture scheme defines hold (authorize), capture (capture), release (void), and refund (refund). Refunds, however, are only possible until extra.refundDeadline and each one requires the resource server's consent, so the power to reverse sits with the seller rather than the payer. In A Formal Analysis of Agent Payment Protocols, researchers from Southern University of Science and Technology and City University of Hong Kong modeled four agent payment protocols, x402 among them, in Tamarin. The analysis derived 18 security principles and found 40 previously undocumented consistency issues across 86 verification cases. One of them is that x402 lacks a relation confirming that payment terms came from the intended resource server. The payer, too, is identified only by a wallet address, so which agent signed on behalf of which user has to be handled outside the protocol. That delegation structure was covered in "Delegation Without Handing Over the User's Account — Workload Identity and Scoped Tokens for Agents."
Summary
x402 puts a PaymentRequired object into the 402 response that RFC 9110 had only reserved, turning payment terms into a format an AI agent can read. The client picks one option from accepts and signs an authorization that fixes amount, payee, validity window, and nonce, and the facilitator checks signature, balance, and terms with a read-only /verify before settling with /settle. The same structure rides in MCP tool results, so an agent can receive a payment request and return an authorization within a tool call. The signature, however, does not bind the resource, the settling party, or the origin of the payment terms, and the time gap between the HTTP response and on-chain settlement produces duplicate delivery and unsettled service.
Delegating payment to agents, in the end, is not a matter of setting a spending ceiling but of deciding who judges the relationships the signature leaves unfixed. With x402 as it stands, a payment an agent can approve on its own is one made under exact to an allowlisted payee, within the per-payment ceiling, with the client recording which task and which resource it paid for. Unfamiliar payees, servers freshly chosen through discovery, spending that needs a cumulative budget, and payments whose refund depends on the seller's consent belong with human and policy judgment.
References
- RFC 9110: HTTP Semantics
- X402 Protocol Specification
- @x402/core
- Transport: HTTP
- Transport: MCP (Model Context Protocol)
- ERC-3009: Transfer With Authorization
- Scheme:
exactonEVM - Scheme:
upto - Free-Riding the Agentic Web: A Systematic Security Analysis of x402 Payments
- Five Attacks on x402 Agentic Payment Protocol
- Scheme:
auth-capture - A Formal Analysis of Agent Payment Protocols