x402
ProductionHTTP 402 Payment Required — Coinbase
Overview
x402 is Coinbase's open protocol for machine-to-machine payments using the HTTP 402 status code. When an AI agent hits a paid endpoint, it receives a 402 response with on-chain payment instructions. The agent pays with USDC, and the server verifies the payment before serving the response. SettleGrid is the first x402 facilitator that adds metering, budgets, and analytics on top.
How It Works
The x402 flow begins when an AI agent sends a request to a paid endpoint without a payment header. The server responds with HTTP 402 and a JSON body specifying the price, accepted tokens (USDC, USDT), chain IDs, and a payment address. The agent constructs an on-chain transaction, signs it, and resends the request with the payment proof in a custom header.
The server verifies the on-chain payment (checking amount, recipient, and confirmation status) before processing the request. This creates a trustless, permissionless payment channel between any two machines on the internet.
SettleGrid extends x402 with credit-based budgets, rate limiting, and analytics. Instead of raw on-chain verification on every call, consumers can pre-fund a credit balance with USDC and SettleGrid handles the metering. This reduces gas costs and latency while maintaining the crypto-native payment model.
How SettleGrid Integrates
SettleGrid supports x402 natively. When a consumer's agent sends an x402 payment header, SettleGrid verifies the on-chain transaction, credits the developer's balance, and meters the invocation. Developers receive payouts in fiat via Stripe Connect or in USDC — regardless of how the consumer paid. Three API endpoints handle the flow: /api/x402/verify, /api/x402/settle, and /api/x402/supported.
Key Specs
| Protocol | x402 — HTTP 402 Payment Required |
| Backer | Coinbase |
| Detection Header | X-402-Payment / X-Payment-* |
| Identity Type | wallet-address |
| Payment Type | on-chain (USDC/USDT) |
| Status | Production |
Code Example
Here is how a developer's tool works with x402 via SettleGrid:
import { settlegrid } from '@settlegrid/mcp'
const sg = settlegrid.init({
toolSlug: 'blockchain-analytics',
pricing: { defaultCostCents: 25 },
// x402 payments are verified automatically
// Consumer agents pay with USDC on-chain
})
const analyze = sg.wrap(async (args: { address: string }) => {
const analysis = await analyzeWallet(args.address)
return { content: [{ type: 'text', text: JSON.stringify(analysis) }] }
}, { method: 'analyze-wallet' })Start monetizing with SettleGrid
Free forever — 50,000 ops/month, progressive take rate. Add billing to your x402 tool in under 5 minutes.
Get Started Free