What Is the x402 Payment Protocol?
The protocol that turns HTTP 402 "Payment Required" into reality — letting AI agents pay for API calls with USDC, natively built into the web.
For decades, the HTTP status code 402 Payment Required was "reserved for future use." In 2025, Coinbase shipped the future: the x402 payment protocol, which lets any HTTP endpoint require a USDC payment before returning data.
This is the protocol powering the AI agent economy. Here's everything you need to know.
How x402 Works: The 60-Second Explanation
- An AI agent makes an HTTP request to an API endpoint
- The server responds with
HTTP 402and a payment requirement (e.g., "0.004 USDC on Base") - The agent's wallet signs a USDC transaction
- A facilitator (like AsterPay) verifies the payment and settles it
- The server returns the actual data
The entire flow happens in milliseconds. No API keys, no subscriptions, no invoices. Just pay-per-call.
# A real x402 request flow:
# 1. Agent makes request
GET /v1/market/price/BTC HTTP/1.1
Host: x402.asterpay.io
# 2. Server responds with 402 + payment details
HTTP/1.1 402 Payment Required
X-Payment: {"amount": "0.004", "currency": "USDC", "chain": "base"}
# 3. Agent pays and retries
GET /v1/market/price/BTC HTTP/1.1
X-Payment-Proof: {signed_transaction}
# 4. Server delivers data
HTTP/1.1 200 OK
{"price": "67234.50", "currency": "USD", ...}
Why x402 Matters for AI Agents
Traditional payment methods (Stripe, invoices, subscriptions) require a human in the loop. An AI agent can't fill out a Stripe checkout form. x402 solves this by making payments machine-native:
- No signup — the agent just needs a wallet with USDC
- No API keys — payment IS the authentication
- Micropayments — pay $0.001 per call, not $99/month
- Instant — no waiting for payment confirmation
- Composable — agents can chain API calls across multiple providers
x402 vs. Google AP2 vs. Traditional Payments
x402 isn't the only agent payment protocol. Google recently launched AP2 (Agent Payments Protocol). Here's how they compare:
- x402: Built on HTTP, uses USDC on-chain, fully decentralized. Best for: developer APIs, AI agent tools, micropayments.
- AP2: Google's approach, designed for agent-to-business commerce. Integrates with Google's AI ecosystem. Best for: commercial transactions, booking, purchasing.
- Traditional (Stripe/cards): Requires human authentication. Not suitable for autonomous agents.
AsterPay supports both x402 and AP2, giving your agents maximum interoperability.
How to Accept x402 Payments
If you're an API provider and want to monetize with x402:
Option 1: Use AsterPay as Your Facilitator
// In your Express/Fastify/Next.js API:
import { x402Middleware } from '@asterpay/x402-sdk';
app.use('/v1/*', x402Middleware({
facilitator: 'https://x402.asterpay.io',
price: '0.004', // USDC per call
currency: 'USDC',
chain: 'base'
}));
AsterPay handles payment verification, settlement, and compliance. You receive EUR via SEPA Instant.
Option 2: Self-Host
x402 is an open protocol. You can run your own facilitator, but you'll need to handle settlement, compliance, and multi-chain support yourself.
The EUR Settlement Gap
Here's the challenge most x402 providers don't solve: your AI agent pays in USDC on Base, but you — the European merchant or developer — want euros in your bank account.
AsterPay bridges this gap. Every USDC payment that flows through our facilitator can be automatically settled to EUR via SEPA Instant. No manual conversion, no exchange accounts, no delays.
Get Started with x402
- For AI agent developers: Install
npx @asterpay/mcp-serverorpip install asterpay - For API providers: Add x402 middleware to your endpoints — see docs
- For merchants: Apply for EUR settlement
Join the x402 Economy
The AI agent payment revolution is here. Start accepting or making x402 payments today.
Create Free Account Read the Docs