Stablecoin Payments for AI Agents: The x402 Guide
An AI agent with a USDC budget can compare, select and pay without a credit card, without a bank intermediary and without friction. The x402 protocol makes this possible today.
Executive summary
An AI agent with a USDC budget can compare, select and pay without a credit card, without a bank intermediary and without friction. The x402 protocol makes this possible today.
Published
2026-03-20
9 min
Author
Integration Architecture Team
Implementation architects
The integration architecture team focuses on practical rollout patterns for stores adopting MCP-compatible commerce surfaces.
View profileCategory
Agentic Commerce
When an AI agent encounters an HTTP 402 Payment Required response, the x402 protocol kicks in. The agent reads the payment requirements from the response header, constructs a stablecoin payment, and settles the transaction — all without human intervention, credit card networks, or traditional banking rails.
What is x402?
x402 is a payment protocol designed for the agentic web. It leverages the long-dormant HTTP 402 status code to create a native payment layer for AI agents. When a merchant returns HTTP 402, the response includes a PAYMENT-REQUIRED header with structured payment details: wallet address, amount in USDC, network, and expiration. The agent parses this, signs a stablecoin transaction, and returns payment proof in a PAYMENT-SIGNATURE header.
The payment flow in 6 steps
- 1Agent requests a resource or checkout endpoint.
- 2Merchant returns HTTP 402 with a PAYMENT-REQUIRED header containing wallet address, amount, network, and expiration.
- 3Agent parses the payment requirement and validates the terms against its budget and policies.
- 4Agent signs and submits a USDC transaction on the specified network.
- 5Agent sends the transaction proof via PAYMENT-SIGNATURE header in a retry request.
- 6Merchant verifies the payment on-chain and fulfills the order, returning the requested resource.
Security: SSRF guard, HTTPS, and float precision
The x402 implementation includes multiple security layers. SSRF protection blocks RFC-1918 private addresses, loopback, and cloud IMDS endpoints from being used as facilitator URLs. All facilitator communication requires HTTPS. A float precision guard enforces MAX_SAFE_CENTS to prevent rounding errors in stablecoin amounts, since USDC uses 6 decimal places and conversion to cents must be exact.
Settlement with exponential backoff
Settlement follows a fire-and-forget pattern via HTTP 202. The merchant initiates verification and returns immediately. Behind the scenes, settlement retries with exponential backoff — 5 attempts at 5s, 10s, 20s, 40s intervals. Pending payments that exceed the expiration window are automatically marked as expired, protecting both merchant and agent from stuck transactions.
x402 eliminates chargebacks entirely. Once a USDC transaction is confirmed on-chain, it is final. For merchants, this means 0% chargeback rate and no dispute resolution overhead.
Advantages over fiat payment rails
- 1Zero chargebacks: on-chain finality means no reversals after confirmation.
- 2No credit card fees: stablecoin transfers cost a fraction of card processing fees.
- 3No bank intermediary: agents pay directly from their wallet to the merchant wallet.
- 4Global by default: USDC works across borders without currency conversion friction.
- 5Instant verification: on-chain confirmation is faster than traditional payment authorization.
Implementation walkthrough
To accept x402 payments, a merchant configures a wallet address and supported network in their protocol settings. The platform generates HTTP 402 responses with the correct PAYMENT-REQUIRED header format. On the agent side, the x402 adapter detects the 402 response, normalizes the payment intent from the header (converting USDC smallest units to cents), and handles the signature flow. The entire cycle — detection, normalization, payment, and settlement — is managed by the protocol bridge.
Frequently asked questions
What is x402?
x402 is a payment protocol that uses the HTTP 402 status code to enable AI agents to pay merchants with USDC stablecoins directly, without credit cards or banking intermediaries.
Is x402 production-ready?
Yes. The x402 adapter is fully implemented with 195 tests covering detection, normalization, outbound generation, and settlement. It supports USDC on multiple networks with full security hardening.
How does settlement work?
Settlement is fire-and-forget via HTTP 202. The merchant verifies the on-chain transaction with exponential backoff retries. Payments transition from pending to completed, failed, or expired based on verification results.
Can merchants receive fiat instead of USDC?
The protocol settles in USDC. Merchants can use off-ramp services like Coinbase or Circle to convert USDC to fiat automatically, but the on-chain settlement itself is in stablecoin.
Sources and references
- x402 Protocol Specification
x402 Working Group
- USDC by Circle
Circle
- HTTP 402 Payment Required
MDN Web Docs
Related articles
Agentic Commerce
Agentic Commerce: The Practical Guide for E-commerce Teams
A business-first guide to understanding what changes in discovery, trust, checkout, and operations when AI agents start influencing purchases.
developer-tools
MCP vs Traditional API: What Changes for E-commerce
A practical comparison of what changes when an e-commerce stack must be interpreted and used by AI agents, not only by developers.
Agentic Commerce
The start of the agentic commerce era
Ecommerce is entering a phase where agents move beyond assistance and start comparing, selecting, and purchasing within explicit constraints.