x402 Payments: a facilitator for paid APIs and AI agents
x402 lets an app or AI agent pay for one API call at a time in USDC, with no account or checkout form. The server answers "402 Payment Required" with a price; the client pays and retries. Crypto APIs runs a facilitator (the service that checks and settles payments) for sellers, and agent wallets with spending limits for buyers.
What is HTTP 402 Payment Required?
HTTP 402 is a status code the web reserved for payments long ago and rarely used. x402 gives it a job: the server says what a request costs, the client pays, and the same request goes through.
No account, no checkout form, no invoice. That makes it a fit for AI agents and for apps that sell data or compute by the call.
How do sellers and buyers use x402?
Use one side or both. One API key works for both.
Accept payments through our x402 facilitator
Put a price on any API route. We verify each payment and settle it on-chain to your own address.
- Middleware for Express, Hono and Next.js
- Set your own price per endpoint, paid in USDC
- Zero-dependency, non-custodial merchant SDK
- Payments settle on Base or Solana
Agent wallets with spending limits
Give an AI agent or app a wallet it can pay from, with limits you set. It signs every payment locally.
- Per-transaction, daily and monthly limits
- Buyer SDK, an MCP tool or the agent plugin
- No signing endpoint: keys stay with you
- Pays any x402 API, not only ours
How do I add x402 to my API or agent?
A few lines on the seller side. One fetch wrapper on the buyer side. Pick a tab.
- Unpaid requests get a 402 with the price
- Paid requests carry an X-PAYMENT header
- Receipts come back in X-PAYMENT-RESPONSE
import express from "express"; import { paymentMiddleware } from "@cryptoapis-io/x402-merchant-sdk/express"; const app = express(); const pay = paymentMiddleware({ apiKey: process.env.CRYPTOAPIS_API_KEY, payTo: "0xYourBaseAddress", // paid to you in USDC }); const USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"; // Unpaid calls get 402 Payment Required with the price: $0.01. app.get("/api/forecast", pay({ network: "eip155:8453", asset: USDC_BASE, amount: "10000" }), (req, res) => res.json({ forecast: "sunny", payer: req.x402.payer }));
import { createX402Fetch } from "@cryptoapis-io/x402-buyer-sdk"; import { Wallet } from "ethers"; // The key is yours. It never leaves your process. const wallet = new Wallet(process.env.PRIVATE_KEY); const fetch402 = createX402Fetch({ apiKey: process.env.CRYPTOAPIS_API_KEY, walletId: process.env.X402_WALLET_ID, // has spending limits signer: { signTypedData: (td) => wallet.signTypedData(td.domain, td.types, td.message) }, }); // Pays the 402 challenge, then retries. const res = await fetch402("https://api.example.com/api/forecast");
// Your MCP client config { "mcpServers": { "x402-pay": { "command": "npx", "args": ["-y", "@cryptoapis-io/mcp-x402-pay"], "env": { "X402_WALLET_ID": "YOUR_AGENT_WALLET_ID", "X402_ALLOWED_HOSTS": "api.example.com" } } } } // The agent can now call x402_pay (signs locally) // and x402_discover (finds paid APIs and their prices).
Watch how x402 works
How do I pay for x402?
Today, x402 runs on a paid Crypto APIs subscription. Soon, its fees will come from your Crypto Balance, a prepaid balance you fill with USDT on Tron.
- Pick a subscription x402 runs on a paid Crypto APIs subscription.
- Turn on x402 Seller middleware, buyer wallet, or both.
- Payments settle in USDC On Base or Solana, to the seller's own address.
- Coming soon Crypto Balance Fees from a prepaid balance you fill with USDT on Tron.
x402 questions
What is HTTP 402?
HTTP 402 Payment Required is a status code reserved in the HTTP standard for payments. x402 gives it a meaning: the server answers 402 with a price and payment details, and the client pays and retries the same request.
What is x402?
x402 is an open protocol for paying per request over HTTP in stablecoins. It lets apps and AI agents pay for an API call in USDC without accounts or checkout forms.
Is Crypto APIs x402 custodial?
No. Buyers sign every payment locally with their own key; there is no signing endpoint. Sellers get paid to their own address. Our facilitator only verifies and settles the signed payment on-chain.
Which networks does x402 support?
Base and Solana are live, with payments in USDC. More networks will follow.
How do I pay for x402?
Today, x402 runs on a paid Crypto APIs subscription. Soon, x402 fees will be taken from your Crypto Balance, a prepaid balance in USD that you fill with USDT on Tron.
Can I limit what an agent spends?
Yes. Each agent wallet has per-transaction, daily and monthly spending limits. A payment over a limit is refused before it is signed.
Charge per request, or pay per request
Create an account, pick a subscription and turn on x402 in minutes.