Services - x402: the payment layer for APIs and AI agents
x402 turns the long-reserved HTTP 402 status code into a working payment rail: any API endpoint can charge stablecoins per request, and any client, human or AI agent, can pay in one round-trip. We integrate it end to end, from gating your endpoints to equipping your agents to spend.
The protocol - Payments as a native part of HTTP
The HTTP status code 402 Payment Required has been reserved since 1997 and never put to work. x402 finally activates it: an open standard, created at Coinbase and now stewarded by the x402 Foundation under the Linux Foundation, that lets any HTTP server charge for a request and any HTTP client pay for it, in stablecoins, within a single round-trip.
A server that wants to charge simply answers an unpaid request with 402 Payment Required and a machine-readable list of accepted payments: the price, the token (typically USDC), the network, and the receiving address. The client signs a payment authorization, retries the same request with a payment header, and gets the resource back together with the onchain transaction hash. No checkout page, no account creation, no API-key provisioning.
Because the whole exchange is plain HTTP, it works for humans, backends, and, most importantly, for AI agents, which can hold a wallet and buy exactly the data or compute they need, per request, without a human filling in a card form. Settlement is onchain (Base, Solana, and other networks), takes seconds, and carries zero protocol fees.
- Protocol fees on every payment
- $0
- Accounts, API keys, or card forms
- 0
- HTTP round-trip to get paid in USDC
- 1
Under the hood - One request, one payment, one response
Three parties are involved: the buyer (a user, a backend, or an AI agent), your API server, and a facilitator, a stateless service that verifies signed payments and settles them onchain so your server never touches a blockchain node or holds keys.
The buyer's signature is an authorization to move exactly the advertised amount of USDC (via EIP-3009 transferWithAuthorization), so funds only move if your server delivers, the buyer pays no gas, and the facilitator never has custody of anything.
Use cases - What you can build with it
x402 makes any priced HTTP call a product. It shines wherever subscriptions, invoicing, or card fees make small or machine-driven purchases impractical.
- API monetization. Charge per call instead of selling seats and quotas. A weather lookup for $0.001, an inference call for $0.01, with no billing infrastructure to run.
- Agentic commerce. Give AI agents a wallet and they can buy data, tools, and compute autonomously. x402 is the payment rail behind agent frameworks and MCP-based tool servers.
- Paywalled content. Sell a single article, dataset, or video for cents, to anonymous readers worldwide, without forcing an account or a monthly plan.
- Usage-based services. Meter compute, storage, or bandwidth and charge for exactly what was consumed using the protocol's upto scheme.
- Machine-to-machine billing. Microservices that pay each other per request across company boundaries, with settlement in seconds instead of net-30 invoices.
- Proxies and aggregators. Wrap upstream paid APIs, add your margin, and resell them through one x402 endpoint that agents can discover and pay programmatically.
Why it matters - What x402 changes
Traditional payment rails were designed for humans buying at checkout. x402 redesigns the transaction around the request itself.
- No onboarding. Buyers need a funded wallet, nothing else. No sign-up, no KYC form for a $0.005 purchase, no API key to provision, rotate, and leak.
- True micropayments. Card rails make anything under ~$1 uneconomical. With fee-free USDC transfers, fraction-of-a-cent prices are viable business models.
- Instant, final settlement. Funds arrive in your wallet in seconds and cannot be charged back. No 30-day payout cycles, no rolling reserve, no dispute overhead.
- Global by default. A stablecoin payment works the same from every country, without local acquirers, currency conversion, or region-gated payment providers.
- Built for machines. The 402 response is machine-readable, so software negotiates and pays without a human in the loop. That is the missing primitive for the agent economy.
- Open and neutral. An open Linux Foundation standard with multiple facilitators, SDKs in TypeScript, Go, and Python, and no vendor lock-in or protocol rent.
Integration - A taste of both sides
Selling means one middleware on your existing server. Buying means wrapping your HTTP client with a wallet. Everything else, the 402 handshake, the signature, the retry, the settlement, is handled by the protocol SDKs.
Selling: gate an endpoint
import express from 'express'
import { paymentMiddleware, x402ResourceServer } from '@x402/express'
import { ExactEvmScheme } from '@x402/evm/exact/server'
import { HTTPFacilitatorClient } from '@x402/core/server'
const app = express()
const facilitator = new HTTPFacilitatorClient({ url: 'https://x402.org/facilitator' })
app.use(
paymentMiddleware(
{
'GET /api/report': {
accepts: [
{ scheme: 'exact', price: '$0.01', network: 'eip155:8453', payTo: '0xYourAddress' },
],
description: 'Market report, paid per request',
},
},
new x402ResourceServer(facilitator).register('eip155:8453', new ExactEvmScheme()),
),
)
app.get('/api/report', (req, res) => res.json({ report: '...' }))Buying: pay per request
import { wrapFetchWithPayment } from '@x402/fetch'
import { x402Client } from '@x402/core/client'
import { ExactEvmScheme } from '@x402/evm/exact/client'
import { privateKeyToAccount } from 'viem/accounts'
const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY)
const client = new x402Client()
client.register('eip155:*', new ExactEvmScheme(signer))
const fetchWithPayment = wrapFetchWithPayment(fetch, client)
// The 402 response, USDC authorization, and retry are handled for you
const response = await fetchWithPayment('https://api.example.com/api/report')