x402 revives HTTP 402 "Payment Required": an agent requests a paid resource, your server answers with payment terms (USDC on Base), the agent pays on-chain and retries with a payment header. No accounts, no API keys for the buyer. Here is the minimal setup.
Step 1 — Advertise what you sell (2 min)
Create /.well-known/x402.json:
{
"accepts": [{
"scheme": "gateway",
"network": "8453",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"payTo": "0xYourWalletAddress",
"maxAmountRequired": "0.01",
"resource": "https://your-site.com/api/your-tool",
"description": "What one call buys",
"mimeType": "application/json"
}]
}
Step 2 — Enforce on your endpoint (5 min)
Your API route checks for an X-PAYMENT header. Without it: return 402 with the same terms. With it: verify the transfer settled to your wallet for at least maxAmountRequired, then serve the result. Verification means reading the transaction from a Base RPC — never trust the header alone.
Step 3 — Test without paying yourself (2 min)
curl -i "https://your-site.com/api/your-tool?arg=x" # expect: HTTP/2 402 + payment terms curl -i -H "X-PAYMENT: garbage" "...&" # expect: still 402 / payment_not_verified
Both failing paths prove enforcement works. A real paid call then comes from any x402-capable agent.
Pricing sanity (1 min)
$0.001–$0.05 per call is the working range for data/utility endpoints. Below that, gas-free facilitator economics get tight; above it, agents comparison-shop.
Check whether agents can already pay you
Free audit — includes .well-known/x402 checkSee it live: our own pay-per-call audit runs this exact stack at /api/agent-audit