x402 Protocol: The HTTP Payment Standard for AI Agents
The internet has always been missing a native payment layer. HTTP defines status codes for everything from success (200) to redirection (301) to server errors (500) — but 402 Payment Required has sat largely unused since 1991. x402 changes that.
What Is the x402 Protocol?
x402 is an open standard that uses the 402 Payment Required HTTP status code to create a universal machine-readable payment flow. When a resource requires payment, the server returns a 402 response with structured headers describing:
- Amount: how much to pay (in USDC, stablecoins, or other currencies)
- Recipient: where to send the payment
- Network: which blockchain or payment rail to use
- Proof requirements: what the client must include with the paid request
The client — whether a human browser, an AI agent, or an automated script — pays, attaches proof, and retries the request. The server verifies and responds with the resource.
Why HTTP-Native Payments Matter
Traditional payment flows assume humans: redirect to a checkout page, enter card details, complete 2FA. This is fundamentally incompatible with automated systems.
AI agents, MCP servers, and API-consuming scripts can’t:
- Click “Buy Now” buttons
- Fill out payment forms
- Complete CAPTCHA challenges
- Wait for email confirmations
x402 makes payments a first-class HTTP primitive — as simple as following a redirect. Any HTTP client can be payment-capable with a few lines of code.
The x402 Request/Response Flow
Client Server
| |
| GET /premium-data |
|------------------------>|
| |
| 402 Payment Required |
| X-Payment-Details: ... |
|<------------------------|
| |
| (client pays on-chain) |
| |
| GET /premium-data |
| X-Payment-Proof: ... |
|------------------------>|
| |
| 200 OK + data |
|<------------------------|
The entire flow happens programmatically. No redirects. No human interaction required.
x402 vs. Traditional API Monetization
| Approach | Setup Time | Human Required | Micropayments | AI-Compatible |
|---|---|---|---|---|
| Stripe API keys | Days | Yes (KYC) | ❌ (fees too high) | Partial |
| OAuth + billing | Weeks | Yes | ❌ | ❌ |
| Crypto wallets | Hours | Partial | ✅ | Partial |
| x402 protocol | Minutes | No | ✅ | ✅ |
Implementing x402 with mpp.best
mpp.best is the hosted implementation of x402 for API builders. Instead of running your own payment infrastructure, you protect any endpoint with a single @require_payment decorator:
from mpp import require_payment
@require_payment(amount="0.001", currency="USDC")
async def get_premium_analysis(request):
data = await expensive_computation()
return {"result": data}
mpp.best handles:
- x402 response generation (correct
402headers) - Payment verification on-chain
- Proof validation
- Analytics and revenue tracking
AI Agent Use Cases
Autonomous Research Agents
A research agent needs real-time data from 50 different APIs. With x402, it pays each one automatically as requests are made — no pre-negotiated contracts, no API keys to manage.
MCP Tool Servers
Model Context Protocol tools can expose paid capabilities: analyze_document($0.05), generate_image($0.10), run_code($0.02). Any MCP client (Claude, GPT, etc.) can consume these tools without human payment intervention.
Multi-Agent Systems
In a CrewAI or LangGraph workflow with 10 specialized agents, each agent can independently pay for the resources it needs. The orchestrator doesn’t need to pre-fund a central wallet.
Technical Implementation Details
Server-Side (Python)
from mpp import MPPClient
client = MPPClient(api_key="your-key")
@app.route("/api/data")
async def protected_data():
payment = await client.verify_payment(request.headers)
if not payment.valid:
return client.payment_required_response(amount="0.01")
return {"data": "premium content"}
Client-Side (AI Agent)
from mpp import PaymentAgent
agent = PaymentAgent(wallet_key=os.environ["WALLET_KEY"])
# Automatically handles 402 responses
response = await agent.get("https://api.example.com/data")
print(response.json()) # Payment happened transparently
The x402 Ecosystem
x402 is gaining adoption across the AI infrastructure stack:
- Coinbase has contributed open-source x402 libraries for Python, TypeScript, and Go
- Anthropic Claude can use x402-enabled MCP servers natively
- Infrastructure providers including mpp.best offer hosted x402 middleware
Get Started
Ready to monetize your API or data service using x402?
- Sign up for mpp.best — free during beta
- Protect your first endpoint in under 5 minutes
- Start receiving programmatic payments from AI agents worldwide
The 402 status code has waited 35 years. Its time has finally come.