> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blockforecast.io/llms.txt
> Use this file to discover all available pages before exploring further.

# x402 Agent API: Micropayment-Native Market Access

> The x402 Agent API lets AI agents create markets and query data by paying USDC directly — no API key, no OAuth, no signup. Payment is the authentication.

The x402 Agent API is a micropayment-native API surface built on the [HTTP 402 Payment Required](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402) protocol. Instead of issuing a long-lived API key, the server gates each request behind a USDC micropayment on Base L2. Your agent signs a payment authorization, includes it in the request header, and the server verifies and settles the payment before executing the call. For market creation specifically, it costs exactly \$1 USDC per market — no subscription, no quota, no dashboard required.

## 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 returns `402 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:

```
Client                          BlockForecast API              Coinbase CDP
  │                                    │                            │
  │── GET /api/v2/x402/feed ──────────►│                            │
  │                                    │                            │
  │◄── 402 Payment Required ───────────│                            │
  │    { amount, currency, payTo,      │                            │
  │      network, nonce }              │                            │
  │                                    │                            │
  │  [sign USDC transferWithAuth]      │                            │
  │                                    │                            │
  │── GET /api/v2/x402/feed ──────────►│                            │
  │   X-PAYMENT: <signed-payload>      │                            │
  │                                    │── verify + settle ────────►│
  │                                    │◄── settlement confirmed ───│
  │◄── 200 OK + response body ─────────│                            │
```

The entire round-trip typically completes in 3–5 seconds.

## 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).                                     |

Read-only endpoints (`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 |

<Tip>
  Both APIs run in parallel — you can use an API key for high-frequency reads and x402 for pay-per-query oracle resolution, all from the same agent wallet.
</Tip>

## The 4-step build

Getting an agent to the point of creating markets involves four steps:

<Steps>
  <Step title="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.
  </Step>

  <Step title="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](https://bridge.base.org) or send directly from Coinbase.
  </Step>

  <Step title="Apply for creator access">
    Visit [blockforecast.io/apply](/creators/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.
  </Step>

  <Step title="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](/developers/x402-create-market) for the full implementation.
  </Step>
</Steps>

## 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

<CardGroup cols={2}>
  <Card title="Create a market via x402" icon="bolt" href="/developers/x402-create-market">
    Full step-by-step guide with working TypeScript code for the complete wallet → fund → approve → create flow.
  </Card>

  <Card title="Apply for creator access" icon="user-check" href="/creators/apply">
    Submit your creator application — reviewed within 24 hours and valid across all BlockForecast surfaces.
  </Card>
</CardGroup>
