TL;DR
AI agents need to spend money. Operators don't want to manage API keys for every agent. HTTP 402 Payment Required + Coinbase x402 facilitator = agent pays once, gets api_key + balance, spends down on real services. Here's how I wired it on our SMS verification API, with working Python code.
What is x402?
HTTP 402 has been a "reserved for future use" status code in the spec since 1997. In 2025, Coinbase (with Cloudflare and others) built the x402 protocol on top of it β a standard way to settle USDC micropayments inline with HTTP requests.
The flow is dead simple from an agent's perspective:
Agent makes a normal POST to your endpoint
Server returns 402 Payment Required with a JSON manifest listing accepted networks (Base / Solana / Polygon), token (USDC / USDT), amount, and recipient address
Agent (using x402-fetch or a similar SDK) signs an EIP-3009 authorization, retries with the X-PAYMENT header
Server verifies via the Coinbase facilitator, settles on-chain, returns 200 OK with whatever theβ¦