x402 Protocol
HTTP-native micropayments for APIs. Return a 402, get paid in USDC, deliver data. No subscriptions, no API keys to manage — just pay-per-request built into HTTP.
How It Works
Three HTTP round-trips. No out-of-band negotiation, no payment SDKs, no webhooks to configure.
Request Resource
Client sends a standard HTTP request to a monetized endpoint.
402 + Payment Info
Server responds with payment requirements in standard HTTP headers.
Pay & Receive Data
Client signs payment, retries with proof. Server settles and delivers.
Core Capabilities
Everything you need to monetize APIs with HTTP-native payments, from middleware to AI agent integration.
Payment Gate Middleware
Protect any Laravel route with a single middleware declaration. Configurable pricing per endpoint with automatic 402 response generation and settlement verification before data delivery.
- Route-level price configuration
- Automatic 402 response generation
- Settlement verification before delivery
AI Agent Payments
Autonomous AI agents can pay for API access using the MCP tool integration. Budget limits and approval thresholds keep spending under control without human intervention.
- MCP tool for Claude/GPT agents
- Per-agent budget management
- Approval required above threshold
Spending Limits
Granular spending controls with daily caps, per-transaction limits, and per-agent budgets. Configurable approval thresholds trigger manual review above set amounts.
- Daily and per-transaction caps
- Per-agent spending budgets
- Configurable approval thresholds
Multi-Network Settlement
Settle payments on Base (primary, low fees), Ethereum, or Avalanche using USDC. Each endpoint can be independently configured with its preferred network.
- Base as primary (low fees)
- Ethereum and Avalanche supported
- Per-endpoint network configuration
Facilitator Integration
Leverage the x402.org facilitator for trustless payment verification and settlement, or run your own self-hosted facilitator for full control over the payment pipeline.
- Self-hosted or x402.org facilitator
- Payment signature verification
- Automatic settlement confirmation
GraphQL & REST APIs
Full CRUD for monetized endpoints, payment history, and spending reports. Choose REST or GraphQL for managing your x402-protected resources programmatically.
- 15+ REST endpoints
- Complete GraphQL schema
- Real-time payment webhooks
Built For
From API monetization to autonomous AI agents, x402 handles payment at the protocol level so you can focus on delivering value.
API Monetization
Charge per-request for premium data, analytics, or AI inference endpoints. No subscription management, no billing integration — clients pay at the HTTP layer and get instant access.
Autonomous AI Agents
Let Claude, GPT, and other AI agents pay for API access autonomously. MCP tool integration with budget controls ensures agents operate within defined spending limits.
Premium Data Feeds
Real-time market data, research reports, and compliance feeds with instant USDC settlement on Base. Consumers pay only for the data they actually consume.
Developer Integration
Protect any Laravel route with x402 middleware in one line. Handle 402 responses client-side with a few lines of JavaScript.
S Server — Laravel Middleware
// routes/api.php
// Simple: protect a route for $0.10
Route::get('/premium/market-data', [MarketDataController::class, 'index'])
->middleware('x402:100000'); // micro-USDC
// Full config: price, network, asset
Route::get('/premium/analytics', [AnalyticsController::class, 'show'])
->middleware('x402:500000,eip155:8453,USDC');
// Group multiple endpoints
Route::middleware(['x402:250000'])->group(function () {
Route::get('/data/trades', [TradeController::class, 'index']);
Route::get('/data/orderbook', [OrderBookController::class, 'show']);
});
C Client — Handle 402 Response
const res = await fetch('/v2/premium/data');
if (res.status === 402) {
// Read payment requirements from headers
const amount = res.headers.get('X-Payment-Amount');
const network = res.headers.get('X-Payment-Network');
const receiver = res.headers.get('X-Payment-Receiver');
// Sign and send USDC payment
const txHash = await sendUSDC(receiver, amount, network);
// Retry with payment proof
const data = await fetch('/v2/premium/data', {
headers: { 'X-Payment-Proof': txHash }
});
}
Quick Start
Configure Facilitator
Set X402_FACILITATOR_URL and X402_RECEIVER_ADDRESS in your .env
Add Middleware
Attach x402:price middleware to any route you want to monetize
Start Earning
Clients receive 402 responses with payment info and pay in USDC automatically
Supported Networks
Settle payments on the network that best fits your use case. Base offers the lowest fees for high-frequency micropayments.
| Network | Chain ID | Asset | Status |
|---|---|---|---|
| Base | eip155:8453 | USDC | Primary |
| Ethereum | eip155:1 | USDC | Supported |
| Avalanche | eip155:43114 | USDC | Supported |
Networks are configurable per-endpoint via middleware parameters or the management API.
Start Monetizing Your APIs
Add x402 payment gates to your endpoints and get paid per request. No subscriptions, no billing integrations — just HTTP.
Building a mobile wallet? See Mobile Payments →