Who this is for
The x402 API is purpose-built for three categories of developer: Autonomous AI agents that need to interact with prediction markets without human involvement in the authentication flow. An agent can hold a private key, fund the wallet with USDC, and call the API indefinitely — no key rotation, no session management. Automated systems and bots where the overhead of the standard API key flow (signing in a browser, storing a key, handling key expiry) adds friction that doesn’t make sense for a machine actor. Developers who want pay-as-you-go pricing for low-frequency queries — rather than maintaining an integration just to query the oracle feed occasionally, you pay $0.001 per call only when you need it.How the x402 protocol works
x402 is a lightweight HTTP extension built by Coinbase for the AI agent ecosystem. When you make a request to an x402-gated endpoint without a payment header, the server returns402 Payment Required with a JSON body describing the payment requirements. Your client constructs a USDC transfer authorization (using EIP-3009 transferWithAuthorization), signs it with your wallet’s private key, and retries the request with the signed payload in the X-PAYMENT header. The server forwards the payload to the Coinbase CDP facilitator for settlement, and if valid, executes the request.
The full protocol flow:
Available endpoints
| Endpoint | Price | Description |
|---|---|---|
GET /api/v2/x402/info | Free | Lists all x402 endpoints, their prices, and the current payment requirements. Discovery endpoint — no payment needed. |
GET /api/v2/x402/feed | $0.001 | Real-time market data feed snapshot — prices, volume, and active market list. |
GET /api/v2/x402/oracle/resolve | $0.05 | Query the AI oracle for its current consensus on a given question. Returns probability and citations. |
POST /api/v2/x402/markets | $1.00 | Create a new prediction market. Requires creator approval (one-time, per wallet). |
info, feed, oracle/resolve) are open to any wallet with USDC on Base. Only POST /x402/markets requires creator approval.
x402 vs the standard API key
| Standard API key | x402 Agent API | |
|---|---|---|
| Authentication | X-API-Key header (persistent key) | X-PAYMENT signed USDC transfer |
| Identity | Wallet that signed the key issuance request | Wallet that signs each payment |
| Cost model | Rate-limited (60 req/min default), no per-request charge | Pay per request, no burst limit |
| Signup required | Wallet signature only (one-time) | None for read endpoints |
| Creator approval | Required to POST /public/markets | Required to POST /x402/markets |
| Best for | Bots, dashboards, trading integrations hitting the API repeatedly | AI agents, one-off queries, data pipelines |
The 4-step build
Getting an agent to the point of creating markets involves four steps:Get an EVM wallet for your agent
Generate a wallet programmatically with
viem or use any EVM-compatible wallet (MetaMask, Coinbase Wallet, a hardware wallet). Your agent needs to hold the private key to sign payments at runtime. Store the key in a secrets manager.Fund the wallet with USDC on Base
Send USDC on Base mainnet to the agent’s address. $5 covers gas plus several market creations. Bridge from Ethereum via the official Base bridge or send directly from Coinbase.
Apply for creator access
Visit blockforecast.io/apply, connect with the agent wallet address, and submit the form. Approval lands within 24 hours. This is a one-time step — the same wallet can create markets via the web, the public API, and x402 forever after.
Call POST /api/v2/x402/markets
Use an x402 client (e.g.
x402-fetch from Coinbase) to handle the payment flow automatically. See Create a market via x402 for the full implementation.Why we built this
Prediction markets are particularly well-suited to autonomous AI agents: agents are good at probability estimation, they can identify gaps in market coverage faster than humans, and they have a natural incentive to create markets — every trade on a creator-owned market sends 0.5% back to the creator’s wallet in real time. An agent that creates markets can become self-funding. x402 removes the last friction in that loop: the need for a human to approve an API key or complete an OAuth flow. The wallet that signs the payment is the authenticated identity. No persistent state, no session, no dashboard.Next steps
Create a market via x402
Full step-by-step guide with working TypeScript code for the complete wallet → fund → approve → create flow.
Apply for creator access
Submit your creator application — reviewed within 24 hours and valid across all BlockForecast surfaces.