402 Payment Required — a code in the HTTP spec since the 1990s, finally put to use. It lets agents pay for API access with stablecoins per-request, with no subscriptions or API keys required.
Payment flow
Your agent makes a request
Your agent sends a standard HTTP request to an API endpoint, just like any other API call.
The server responds with 402 Payment Required
Instead of returning data, the server responds with a
402 status code and includes payment requirements in the PAYMENT-REQUIRED header: how much it costs, which token, and on which network.Your agent pays
Your agent’s wallet constructs a signed payment payload and resubmits the request with a
PAYMENT-SIGNATURE header. No human approval needed.Making x402 requests
CDP Agentic Wallet
With the CDP Agentic Wallet skills installed, your agent handles x402 payments automatically:Terminal
search-for-service and pay-for-service skills handle discovery, payment, and retries.
CDP Agentic Wallet skills →
Sponge Wallet
Sponge Wallet has a built-in x402 proxy that discovers services and handles payment automatically: Step 1 — Discover a service:Terminal
Terminal
baseUrl, endpoint paths, parameters, and pricing.
Step 3 — Call the service (payment is automatic):
Terminal
402, pays in USDC from your wallet, and returns the API response.
Sponge Wallet docs →
Supported networks and tokens
| Network | Token | Notes |
|---|---|---|
| Base | USDC | Default — lowest fees |
| Base Sepolia | USDC | Testnet |
| Solana | USDC | Via CDP facilitator |
| Polygon | USDC | Via CDP facilitator |
Error handling and retries
| Status | Meaning | What to do |
|---|---|---|
402 | Payment required | Parse PAYMENT-REQUIRED header and pay |
402 with X-Payment-Error | Payment rejected | Check wallet balance and token approval |
408 | Payment timeout | Retry with same or higher payment |
429 | Rate limit | Back off and retry after the indicated delay |
pay-for-service skill and Sponge Wallet’s x402 proxy handle retries automatically. If you’re building a custom client, parse the PAYMENT-REQUIRED header, construct the signed payload, and retry with the PAYMENT-SIGNATURE header.
Related
Accepting payments
Gate your own endpoints and charge other agents per request.
Contract addresses
Facilitator endpoints and protocol addresses.