Skip to content

AI Integration · Agentic Commerce

AP2 and x402: How AI Agents Actually Pay for Things Now

AI agents that shop or call paid APIs on your behalf need a way to pay without your credit card sitting in a prompt. Google's AP2 and Coinbase's x402 are the two standards doing that. Here's what each one actually does, in plain terms.

Abhishek Gupta

Abhishek Gupta

5 min read

AP2 and x402: How AI Agents Actually Pay for Things Now

Sponsored

Share

If you’ve wired an AI agent up to browse, compare, and buy things on a user’s behalf, or built an API you’d like agents to pay for automatically instead of provisioning API keys by hand, there’s now an actual standard for the payment step instead of everyone inventing their own. Two pieces make it work: Google’s AP2 for the purchase itself, and x402 for settling machine-to-machine micropayments in stablecoins. Here’s what each one does and where they fit.

The problem neither party could solve alone

An agent that can browse and reason its way to a purchase decision still hits the same wall every time: how does it actually pay, in a way the merchant can trust and the user can audit? Handing an agent a stored credit card and hoping for the best doesn’t give a merchant any way to verify the charge matches what the user actually wanted, and it doesn’t give the user a clean record to dispute a mistake. That trust gap is what kept “agents that shop for you” a demo rather than a production feature.

AP2: mandates, not blind trust

AP2, Google’s Agent Payments Protocol, launched with more than 60 partners including Mastercard, PayPal, Coinbase, American Express, and Salesforce. Its core idea is straightforward: every agent-initiated purchase gets represented as three separate signed records, called Mandates.

MandateWhat it capturesWho signs it
Intent MandateWhat the user actually asked for (“book a flight to Austin under $400”)The user
Cart MandateWhat the agent assembled to fulfill that intent (the specific flight, price, seller)The agent
Payment MandateWhat the merchant or payment network will actually chargeThe payment processor

A merchant or card network can check that all three line up before money moves, and if a dispute happens later, there’s a cryptographically verifiable trail showing exactly what was authorized versus what the agent decided on its own. That’s the piece that was missing before: not the ability for an agent to transact, but a paper trail a human, a merchant, and a bank can all trust after the fact.

The x402 payment cycle: an AI agent requests a resource, gets HTTP 402, signs a stablecoin payment, and retries

x402: reviving a 30-year-old HTTP status code

HTTP status code 402, “Payment Required,” has been sitting in the HTTP specification since 1997 as a placeholder for a micropayment layer the web never actually built. x402, developed with Coinbase, the Ethereum Foundation, and MetaMask as an extension to AP2, is what finally uses it.

The flow is simple enough to implement directly:

1. Agent requests a resource
   GET /api/weather?city=austin

2. Server responds 402, with machine-readable payment terms
   HTTP/1.1 402 Payment Required
   X-Payment-Required: {
     "amount": "0.001",
     "asset": "USDC",
     "network": "base",
     "payTo": "0xExampleRecipientAddress"
   }

3. Agent signs a payment authorization and retries the same request
   GET /api/weather?city=austin
   X-Payment: <signed EIP-3009 authorization>

4. A facilitator service verifies the payment onchain,
   the server returns the resource
   HTTP/1.1 200 OK

No signup flow, no provisioned API key, no invoice sitting in someone’s inbox. An agent that needs a weather lookup, a dataset, or a single inference call pays a fraction of a cent and gets the resource, in the same request cycle. For API providers, this turns “who’s calling my API and are they paying for it” into something the payment layer answers automatically, instead of a billing system bolted on afterward.

Where each one actually fits

AP2 is the broader contract layer for agent-initiated purchases across whatever rail makes sense, cards, bank transfers, real-time payment systems like FedNow or UPI, or stablecoins. x402 is one settlement rail built specifically for the case AP2 alone doesn’t optimize for well: fast, tiny, machine-to-machine payments where setting up a traditional merchant account per API call would be absurd. If you’re building an agent that books travel or shops for a user, you’re in AP2’s territory. If you’re building or consuming an API that should charge per call without an account system, x402 is the more direct fit.

Both plug into the same agent tooling ecosystem your team may already be using. If you’re building agents on MCP or orchestrating multiple agents that need to transact independently, payment capability is the next layer on top of the coordination layer you’ve likely already built.

The honest caution

Treat both as early. AP2’s reference SDK only reached v0.2.0 in April 2026, and reference implementations across languages are still maturing. The protocols themselves are designed around verifiability, mandates that can be checked and audited, but that doesn’t substitute for your own operational discipline. Before letting an agent transact with real money in production, put hard spending caps at the mandate level, scope exactly what each agent is authorized to buy, and log every Mandate somewhere you can actually audit later. The standard gives you the receipt. It doesn’t give you the judgment call on how much autonomy to hand an agent in the first place, that’s still on your team.

If your product roadmap includes agents that need to transact, whether that’s paying for third-party API calls or completing purchases on a user’s behalf, this is worth prototyping now while the ecosystem is still small enough to reason about end to end. Teams that wait until it’s a mainstream expectation will be retrofitting mandate logic into an agent architecture that wasn’t built for it. If you want a second set of eyes on that architecture before you commit to it, that’s exactly the kind of design review our AI integration work covers.

Frequently asked questions

What problem is AP2 actually solving?
When an AI agent buys something on your behalf, a merchant has no reliable way to know what you actually authorized versus what the agent decided on its own, and you have no cryptographic record to dispute a charge if the agent got it wrong. AP2 fixes that by requiring three signed Mandates for every transaction: what you asked for, what the agent picked, and what got charged. A merchant or payment network can verify all three line up before processing the charge.
What's the difference between AP2 and x402?
AP2 is the overall framework for agent-initiated purchases across existing payment rails, cards, bank transfers, real-time payment systems, and stablecoins. x402 is a specific extension built with Coinbase, the Ethereum Foundation, and MetaMask that handles one particular case well: an agent paying for API access using stablecoins, settled instantly onchain, without a signup flow or API key. Think of AP2 as the contract and audit layer, and x402 as one settlement rail plugged into it, purpose-built for machine-to-machine micropayments.
How does x402 actually work, technically?
It reuses HTTP status code 402, 'Payment Required,' which has existed in the HTTP spec since 1997 and was never implemented until now. An agent requests a resource, the server responds with 402 and machine-readable payment terms (price, accepted token, recipient address, network). The agent signs a payment authorization, retries the same request with that signature attached, a facilitator service verifies the payment onchain, and the server returns the resource. The whole cycle happens in seconds with no human in the loop.
Do I need blockchain infrastructure to use this?
For x402 specifically, yes, it settles in stablecoins like USDC onchain, so you need a wallet and a facilitator service that can verify payments on the relevant network. For AP2 more broadly, no, the protocol supports traditional card networks and bank rails as first-class Payment Mandate options, stablecoins are one option among several, not a requirement to participate.
Is this safe to put in front of a production agent today?
Treat it the way you'd treat any new capability that can move real money: start with hard spending caps at the mandate level, scope what a given agent is authorized to purchase as narrowly as the use case allows, and log every Mandate for audit before you rely on it. The protocols themselves are designed with verifiability in mind, but the reference implementations are still early (AP2's SDK hit v0.2.0 in April 2026), so the surrounding operational discipline matters more than the protocol's own guarantees right now.

Sources

Sponsored

Sponsored

Discussion

Join the conversation.

Comments are powered by GitHub Discussions. Sign in with your GitHub account to leave a comment.

Sponsored