x402 Protocol Explained: The Payment Standard Built for AI Agents
A technical breakdown of how the x402 open standard activates HTTP 402 for autonomous machine-to-machine API and MCP payments—plus how to factor paid tool calls into agent budgets.
Why Traditional Payment Rails Break for AI Agents
Modern web APIs rely on human-centric onboarding: create a developer account, verify an email address, store a credit card, generate an API key, and subscribe to a monthly tier. That model breaks down when an autonomous research or procurement agent needs one-off access to a specialized data feed, compute sandbox, or paywalled endpoint for $0.005 per call.
Originally created by Coinbase and now governed by the independent x402 Foundation under the Linux Foundation (with official documentation at x402.org and Coinbase Developer Docs, verified 2026-11-12), the x402 protocol solves this by activating the long-reserved HTTP 402 Payment Required status code as a standardized, machine-readable handshake.
The Four-Step x402 Payment Handshake
According to the official x402 specification (x402-specification-v2.md), a paid tool or API call follows four stateless HTTP steps:
- Initial Request: An AI agent, script, or MCP client sends a standard HTTP request (such as
GETorPOST) to a protected endpoint without prior subscription credentials. - HTTP 402 Challenge: The resource server responds with status
402 Payment Requiredand structured payment metadata specifying the price, acceptable asset (commonly stablecoins like USDC), supported blockchain network(s), payment scheme, and recipient wallet address (payTo). - Signed Payment Payload: The client's agent wallet constructs and cryptographically signs a payment authorization matching one of the server's accepted configurations, then retries the identical HTTP request with the signed payment header attached.
- Verification & Settlement: A designated Facilitator (such as the Coinbase Developer Platform Facilitator or another compatible verifier) validates the signature and settles the on-chain transfer. Once verified, the resource server fulfills the request and returns HTTP
200 OKwith the requested payload.
Supported Payment Schemes & Networks
To cover different AI workload shapes, the x402 specification defines multiple payment schemes rather than forcing one billing pattern:
exact: Transfers a fixed, predetermined unit price per API call—ideal for deterministic lookups such as a single search query, enrichment call, or document fetch.upto: Authorizes up to a maximum spending ceiling before execution, with final settlement based on actual metered consumption (such as output tokens generated or compute seconds consumed).batch-settlement: Aggregates high-frequency micro-transactions to minimize per-call overhead when an agent executes dozens of rapid requests against the same provider.
The standard is network- and token-agnostic, with production specifications supporting EVM-compatible chains (such as Base) as well as Solana via SVM specifications.
MCP Integration for Tool-Calling Agents
While HTTP is the primary transport, modern AI agents increasingly invoke tools through the Model Context Protocol (MCP). The x402 specification extends beyond raw REST endpoints to cover MCP transports, allowing an MCP server to advertise per-tool pricing and verify signed client authorizations inline without breaking the agent's tool-calling loop.
Budgeting Paid x402 Tool Calls Inside Agent Economics
Even with sub-cent micro-payments, per-call tool fees change your agent's cost curve when combined with multi-step loops and retries. If an agent invokes four paid x402 endpoints at $0.005 each per research task across 500 tasks per day, external tool fees alone add $10/day ($300/month) on top of LLM token spend.
To prevent runaway spending when an agent holds signing authority:
- Enforce Per-Task & Daily Caps: Bound the wallet's maximum allowance per task and per 24-hour window—similar to how enterprise retail and banking deployments isolate agent spending profiles.
- Model External Fees Alongside Tokens: Plug your expected paid tool calls into the External Tool / API Cost fields of our AI Agent Cost Calculator or Research Agent Cost Calculator, and read How AI Agent Costs Work to account for failed attempts that still incur API charges.
Primary Sources
- x402 Official Protocol Portal (verified 2026-11-12)
- x402 Foundation GitHub Repository & v2 Specification (verified 2026-11-12)
- Coinbase Developer Docs — x402 Payment Protocol (verified 2026-11-12)