Give a credit card
to your agent
Enable AI agents and applications to pay for API access with cryptocurrency. Monetize your endpoints with micropayments in STX.
import { x402PaymentRequired, STXtoMicroSTX } from 'x402-stacks';
app.get(
'/api/premium-data',
x402PaymentRequired({
amount: STXtoMicroSTX(0.001), // 0.001 STX
address: process.env.SERVER_ADDRESS,
network: 'testnet',
facilitatorUrl: process.env.FACILITATOR_URL,
}),
(req, res) => {
res.json({ data: 'Premium content' });
}
);Built for the future of AI
x402 enables autonomous agents to pay for resources, unlocking new possibilities for AI-driven applications.
Micropayments
Accept payments as low as fractions of STX. Perfect for pay-per-use models and AI agent transactions.
Simple Integration
Drop-in middleware for Express.js. Add payment gates to your APIs with just a few lines of code.
Tiered Pricing
Dynamic pricing based on request parameters, user tiers, or resource types. Maximize revenue potential.
Rate Limiting
Offer free requests up to a limit, then require payment. Perfect for freemium models.
AI Agent Ready
Designed for autonomous agents. Enable your AI to pay for resources and services independently.
Custom Validation
Implement custom payment validation logic. Check allowlists, minimum amounts, or other business rules.