Overview
x402 is an HTTP-native payment protocol that enables pay-per-request API access using USDC on Base Mainnet. With x402, you can access Messari endpoints without a Messari account or API key — simply pay per request with crypto. When to use x402:AI Agents
Autonomous agents that need to query Messari data without managing API keys or subscriptions
Automated Pipelines
Data pipelines that require one-off or sporadic queries billed directly on-chain
One-Off Queries
Quick queries without signing up for an account or committing to a subscription
Supported Endpoints
The following endpoints accept x402 payments:| Endpoint | Method | Price |
|---|---|---|
/ai/v2/chat/completions | POST | $0.25 / request |
Prerequisites
Before making a payment, ensure you have:- An EVM-compatible wallet (e.g. MetaMask, Coinbase Wallet)
- USDC on Base Mainnet — a minimum of ~$1 is recommended to start
- A small amount of ETH on Base Mainnet for gas fees
Bridge to Base
Use bridge.base.org to move USDC from Ethereum or another chain onto Base Mainnet.
How It Works
x402 follows a simple 3-step flow: Step 1: Make a request Send your request to the Messari API without an API key. The gateway responds withHTTP 402 Payment Required along with payment requirements (amount, currency, recipient address, network).
Step 2: Sign & pay
Your x402-enabled client signs a USDC TransferWithAuthorization EIP-3009 message using your wallet’s private key. No gas is required for the authorization itself — the gateway submits the on-chain transaction on your behalf.
Step 3: Request fulfilled
The gateway verifies the signed authorization, collects the USDC payment, and proxies your original request. The API response is returned as normal.
Quick Start (TypeScript)
Install the x402 fetch wrapper:Troubleshooting
“Payment verification failed” Your wallet does not have sufficient USDC on Base Mainnet. Check your balance and ensure you have enough USDC plus a small amount of ETH for gas. “Unsupported network” You must useeip155:8453 (Base Mainnet).
Payment sent but no response received
On-chain confirmation can take ~30 seconds. If you do not receive a response after 60 seconds, check the transaction status on Basescan. If the transaction is confirmed but you still received no response, contact api@messari.io.
