The Internet-Native Payment Layer for Agentic Commerce
Learn how AI agents and businesses are revolutionizing payments with instant, frictionless microtransactions
x402 is an open payment standard that enables instant, autonomous payments for APIs, AI agents, and digital services. It activates the dormant HTTP 402 "Payment Required" status code to create seamless, pay-per-use transactions.
Transactions settle in 2 seconds using stablecoins like USDC
Built for autonomous AI agents to pay for services independently
Works with any blockchain network supporting smart contracts
Enable transactions under 1 cent with minimal fees
The x402 protocol transforms the forgotten HTTP 402 status code into a powerful payment mechanism.
AI agent or client requests a resource from a server
Server responds with "Payment Required" and payment details
Client pays with cryptocurrency (USDC) on blockchain
Server verifies payment and delivers the requested resource
Experience how x402 payments work in real-time
Click the button above to see x402 in action!
// Server Implementation (One line of code!)
paymentMiddleware("0.01", {"/api/data": "$0.01"});
// Client receives HTTP 402 response:
{
"amount": "0.01",
"currency": "USDC",
"network": "base",
"recipient": "0x742d35Cc6634C0532925a3b8D6Ac6841..."
}
Discover how x402 is revolutionizing various industries with frictionless payments.
In-game purchases, virtual assets, and metaverse transactions
Click to learn moreNewsletter subscriptions, articles, and exclusive content access
Click to learn morePay-per-inference AI models, data analysis, and automation
Click to learn moreWeather data, financial APIs, and real-time information services
Click to learn moreDevice-to-device payments and autonomous system transactions
Click to learn morePay-per-gigabyte storage and computational resources
Click to learn moreIntegrate x402 into your application with minimal code changes.
// Express.js Example
const express = require('express');
const { x402Middleware } = require('@x402/middleware');
const app = express();
// Add x402 payment requirement
app.use('/api/premium', x402Middleware({
amount: '0.05',
currency: 'USDC',
network: 'base',
recipient: '0x742d35Cc6634C0532925a3b8D6Ac6841...'
}));
app.get('/api/premium/data', (req, res) => {
res.json({ data: 'Premium content here!' });
});
// JavaScript Client Example
async function accessPremiumAPI() {
try {
// First request - will receive 402
const response = await fetch('/api/premium/data');
if (response.status === 402) {
const paymentInfo = await response.json();
// Make payment using web3 wallet
const payment = await makePayment(paymentInfo);
// Retry request with payment proof
const finalResponse = await fetch('/api/premium/data', {
headers: {
'X-Payment': payment.transactionHash
}
});
return await finalResponse.json();
}
} catch (error) {
console.error('Payment failed:', error);
}
}
Base, Ethereum, Polygon, Solana
USDC, USDT, ETH, SOL
Express, FastAPI, Django, Rails
MetaMask, Coinbase Wallet, WalletConnect
Ready to implement frictionless payments in your application?
npm install @x402/middleware
Set up your receiving wallet address on supported networks
app.use(x402Middleware(options))
Your API now accepts instant crypto payments!