Learn how the x402 protocol uses HTTP 402 for AI agent payments, paid APIs, and metered services, with a step-by-step flow and real implementation examples.
Explore x402’s origins, understand how its HTTP 402 payment flow works, and see how developers use it to power paid APIs, metered AI services, and autonomous AI agent payments. You’ll also learn how spending limits, delivery checks, and other safeguards help keep agent purchases within budget and confirm that paid services were actually delivered.

Imagine a coding agent testing an application before release. It finds a bug that appears only in a browser environment it cannot run locally. A remote testing service could reproduce the problem, but access costs money. The agent has an approved budget; what it needs is a way to read the price, authorize the purchase, and start the test without waiting for its operator to create another account and configure billing. The web has long had a status code for this moment: HTTP 402, “Payment Required,” one of the standard codes a server sends back to tell a client what happened to its request.
That code has existed for decades, but no one defined how the payment itself should work. Coinbase introduced x402 to fill that gap, giving software a common way to complete the exchange: receive the payment requirements, authorize a payment, and retry the request with a proof of that authorization.
For our coding agent, that means purchasing access to the testing service can become part of resolving the bug. For developers, x402 creates a practical connection between an agent’s funded wallet (the digital account holding the funds it's allowed to spend) and the APIs, data, and compute its work requires. This guide explains how the x402 protocol makes that connection, where it is being implemented, and what developers need to build around it to apply x402 to paid APIs, metered AI services, controlled agent payments, and more.
What is x402?
x402 is an open payment protocol for buying resources over HTTP, such as a web page, file, or API response. When a client requests a paid resource, the server replies with its price and payment terms. The client then retries the request with a signed payment payload, a digitally signed message that authorizes that specific payment, and receives access once the payment is accepted. Because the price and the payment both travel in standard HTTP messages, software can handle the whole exchange programmatically.
The client can be an AI agent, a conventional application, or another service. The protocol itself doesn’t require buyers to create an account or obtain an API key (a credential that identifies the caller) with each provider. Providers can still impose authentication, eligibility, or other access requirements based on their needs.
For developers, the practical change is a common interface for buying individual resources. A client can read payment terms as part of its interaction with a service, rather than building separate billing integrations for each provider.
x402 is often discussed as a crypto payment protocol because its payments can settle in stablecoins on blockchain networks. The protocol itself, however, defines only the HTTP exchange. The payment method underneath is a separate choice, covered in more detail below.
From HTTP 402 to the x402 protocol
Hypertext Transfer Protocol (HTTP) is the set of rules web browsers, apps, and servers use to communicate. (HTTPS is the secure, encrypted version of HTTP.) When you open a website, your browser sends an HTTP request, and the server returns a response with the page’s content and a status code describing what happened. HTTP defines dozens of status codes. The familiar 404 “Not Found,” for example, means the requested resource, typically a URL or an API endpoint (the specific address a program calls to get data or trigger an action), doesn’t exist.
The idea of using HTTP to signal that payment is required predates both blockchain technology and AI agents. HTTP drafts reserved the 402 status code for future use in 1996, but never defined how the payment should actually happen. The web had a signal for “Payment Required” without a standard way to complete the exchange.
Coinbase introduced x402 in May 2025 to supply that missing step for software buying APIs, data, and services. x402 turned the reserved 402 status code from a bare signal into a working payment flow: it specifies how a service states its price over HTTP and how a client proves it has authorized payment. The protocol doesn't move money on its own. That job falls to the payment method, and stablecoins can supply a programmable option that works with compatible x402 flows.
Development has since expanded beyond Coinbase. The x402 Foundation now stewards the protocol under the Linux Foundation, a nonprofit that hosts many major open-source projects, with participants including AWS, Circle, Cloudflare, and the Solana Foundation.
How the x402 protocol works: a step-by-step HTTP 402 payment flow
Consider a premium API endpoint that charges a fixed amount per request. A typical x402 exchange follows five steps:
- Request the resource: The agent’s HTTP client calls the endpoint.
- Receive payment requirements: The server returns 402 Payment Required. Its PAYMENT-REQUIRED header (a labeled field of metadata attached to the response) lists the accepted payment options: the scheme (the payment model, such as a fixed price per request), the amount, the asset (for example, USDC), the network (the blockchain the payment runs on), and the recipient.
- Check and authorize payment: The application checks the terms against the agent’s permissions and budget. A protected wallet signer (the secured component that holds the wallet's signing keys) creates the required payment payload, such as a signed stablecoin transfer authorization.
- Retry with the signed payload: The client repeats the request with a PAYMENT-SIGNATURE header. This proves the client has authorized payment; it doesn't mean the funds have moved yet.
- Verify, settle, and respond: The server checks the payload directly or through a facilitator, an optional service that handles verification and settlement (the actual transfer of funds) on the server’s behalf. In this fixed-price flow, once settlement succeeds, the server returns the resource along with payment details in a PAYMENT-RESPONSE header.
Payment details travel as encoded, structured data that client libraries can process. That means the developer integrates payment handling once, while each server declares its own terms for every protected resource.
Why x402 suits AI agent payments
An agent may need one data query from a service it rarely uses. Requiring a subscription, prepaid credit balance, or manual checkout for that query adds a separate commercial workflow, often one a human needs to complete. With compatible infrastructure, x402 makes payment part of acquiring the resource.
Stablecoins such as USDC fit these AI agent payments because they combine programmable transfers, which software can initiate and verify on its own, with an asset tied to a reference currency like the US dollar. That makes small, per-request purchases possible, though whether a given purchase is economical still depends on network transaction costs, facilitator fees, and settlement design.
x402 is often described as enabling near-instant, automated payments, but actual settlement speed depends on the underlying payment method. Some schemes settle each payment onchain, meaning each one is recorded on a blockchain as its own transaction. Batch settlement schemes authorize individual requests and then settle many payments together later. The x402 protocol standardizes the exchange, but the selected payment method determines when funds actually move.
x402 use cases: paid APIs, AI models, data feeds, and agents
The same exchange supports several ways of selling digital resources:
- Premium API endpoints: A provider can charge for an individual search, document conversion, or specialized calculation. Developers can add paid functionality without requiring every buyer to commit to a recurring plan.
- Metered AI model access: The cost of inference (running a model to generate a response) can depend on how much output it produces. The upto payment scheme lets a buyer authorize a maximum amount for a request. The seller then settles the actual charge at or below that ceiling.
- Proprietary data feeds: A research agent could purchase a licensed dataset response when its task requires information beyond public sources. Payment terms must work alongside the provider’s data usage terms.
- Autonomous agent workflows: Like the coding agent in our opening example, an agent could buy a testing service, inspect the result, and continue its assignment. Each purchase remains subject to its operator’s spending authority and available budget.
These use cases show how x402 can support granular, programmatic commerce for both conventional software and AI-driven systems. Several companies have already built infrastructure to support them.
x402 implementations: Cloudflare, AWS, Solana, and Circle
x402 is being implemented across cloud infrastructure and payment systems to support automated access to paid web resources. Cloudflare supports x402 via its Monetization Gateway, which handles payment negotiation and settlement for protected resources. This places payment enforcement directly within the infrastructure that already serves web traffic.
AWS provides an x402 reference implementation that connects agents running on Amazon Bedrock AgentCore, AWS's service for deploying and operating AI agents, with content delivered through CloudFront, its content delivery network. It illustrates how a cloud-hosted agent can encounter a payment request, authorize a stablecoin payment, and obtain access.
On the blockchain side, Solana supports x402 settlement and documented a live demonstration in which an agent used a directory to find a paid endpoint, purchased a data query, and returned the result.
Circle operates x402 facilitators, including one that settles each USDC payment individually and Gateway Nanopayments, which aggregates many small payments into batched settlement.
Payment is only half the problem, though. Agents also need to find services that can accept x402 in the first place. Circle’s Discovery API returns x402-compatible services that accept USDC, along with their prices and payment options, in a single call. Circle’s agent marketplace lets agents and their human operators browse services and filter them by price, category, blockchain network, and more.
Across all of these implementations, buyers and sellers still need compatible networks, assets, and payment schemes for a payment to go through. Where they align, x402 connects web infrastructure, AI agents, and blockchain payment rails to enable machine-to-machine payments for digital resources.
Building safe, reliable x402 payments for AI agents
x402 standardizes how a payment is requested and authorized, but it doesn't decide what an agent should buy. Developers still need to set those rules, protect signing credentials, and keep records connecting each payment to what was delivered. Spending rules should run in code outside the model’s reasoning, so the model can’t approve a purchase on its own, and they should check the amount, recipient, asset, and network before any authorization.
Failures need the same care. A timeout after submitting payment can leave the outcome uncertain: the payment may or may not have gone through. Before authorizing another payment, check the status of the original transaction, and where available, use supported duplicate-request protections, which keep a retried request from being charged twice. A successful transfer also needs a separate delivery check, because paying for an API response doesn’t guarantee its contents are useful.
How to get started with x402
For an x402 trial integration, start with one endpoint, a supported test network, and a fixed price. Test the successful exchange alongside rejected payments and interrupted responses, since those failure cases are where the safeguards above prove themselves.
Once those pieces hold up, the coding agent from our opening scenario becomes practical: it can read the testing service's price, pay within its budget, and get back to fixing the bug. That is the core value of x402: software can acquire a paid resource through an interface it already understands, under financial boundaries its operator controls.
Agent Wallets, Agent Marketplace, Circle CLI, Nanopayments, and Circle Skills (together, the “Agent Stack”) are offered by Circle Technology Services, LLC (“CTS”). CTS is a software provider and does not provide financial, advisory, or marketplace services. Agent Stack enables users, developers, and their artificial intelligence agents ("AI Agents") to build, deploy, discover, hold and transact their own funds, and interact with other third-party AI Agents, applications and services. Transactions initiated by AI Agents are executed based on user-defined permissions and may occur without real-time human review. Circle does not verify, screen, monitor, or make any representations or warranties regarding the identity, legitimacy, safety, security, reliability, or performance of any AI Agent, including any AI Agent developed by you, other users, or third parties, or any AI Agent that interacts with the Agent Stack. AI Agents may operate unpredictably, may be controlled by unknown or unauthorized parties, and may expose users to security, financial, or other risks. Users are solely responsible for their use of these tools, reviewing commands before execution, and for evaluating associated risks. For additional details, please see the Agent Platform Terms of Use available at agents.circle.com/terms-of-use and the Circle Developer Terms of Service available at console.circle.com/legal/developer-terms.
Gateway is software infrastructure provided by Circle Technology Services, LLC ("CTS"). Gateway is non-custodial; CTS does not hold, control, manage, or transfer user assets or act as a transfer agent, registrar, broker-dealer, investment adviser, or clearing agency. Gateway is not a financial, payment, or advisory service and has not been reviewed or approved by NYDFS or any other regulatory authority. Fee estimates are previews only; actual fees may differ. Deposit times vary by chain and network conditions; deposits may be delayed or fail. Source-chain burns are irreversible. USDC only. Eligibility and geographic restrictions apply. Developers are responsible for their own compliance obligations. CTS may modify or discontinue this feature at any time. Developer Terms https://console.circle.com/legal/developer-terms apply.
Facilitator Service is offered by Circle Technology Services, LLC, a software provider. Facilitator Service verifies buyer-signed EIP-3009 USDC payment authorizations under the x402 protocol only — it does not hold, control, or transmit user funds, verify transaction purpose, or confirm agent authority scope. On Base and Polygon, settlements are subject to blockchain reorganization risk; Circle does not guarantee fund receipt. Arc settlements are final. Use of the Facilitator Service is subject to Circle Console Service Terms and Developer Terms. Not reviewed or approved by any regulatory authority. Features may change at any time. Nothing herein constitutes a commitment, warranty, or guarantee. Use involves risk.



