x402 Protocol
On this page
The x402 protocol lets an HTTP client pay for a resource in the same request cycle. The server answers with status 402 Payment Required and lists the price. It also names the accepted network and the asset to pay in. The client signs a payment and retries the request with proof attached. The server verifies the payment, then returns the response.
How the x402 request cycle works
The client sends a normal HTTP request. The server replies with status 402 when the resource costs money. The response body describes what the client must pay.
- The client reads the price, the accepted network, and the payee address.
- The client signs a payment authorization with a wallet key.
- The client retries the same request and attaches the signed payment.
- The server checks the payment, settles it, and returns the resource.
The public specification and examples live at https://www.x402.org. Read them before you write a client, because field names can change between versions.
Test a 402 response by hand
Send a request to a paid endpoint without any payment attached. Read the status line of the response. A 402 status confirms that the endpoint requires payment.
Then read the body. The body names the price, the network, and the payee. Compare those fields with your expectations before you write any signing code.
Why agents need x402 for paid tools
An agent that calls a paid API stops at the first 402 response. The agent code then needs a wallet, a signer, and retry logic. Each team builds these parts again.
A gateway moves that work out of the agent. The agent calls one MCP tool. The gateway handles the 402 handshake with the upstream provider and returns the result. The agent receives a normal tool response.
Give your agent paid MCP tools for research, data lookup, and code search. Each call carries a price, so the agent needs a spend limit.
Set spend limits before the first paid call
Set limits in code, not in the prompt. A model can ignore a rule written in text, but a client check always runs.
- Cap the amount per call and per session.
- Allow only known payee addresses.
- Compare the amount in the 402 body with your cap before signing.
- Log each payment next to the request ID.
A single call costs between 0 and 29.99 in USD terms, depending on the tool. Prices vary by provider, so read the price from the 402 response instead of a cached table.
What x402 does not cover
x402 handles payment for one request. It does not authenticate the user, authorize the action, or limit how often a provider gets called. Pair it with API keys or OAuth where those controls matter.
Settlement speed and fees depend on the network the server chooses. Check each network before you accept a payment.
This guide does not cover refunds. Plan for paid calls where the payment settles but the upstream request fails afterward.
Start with a paid tool call
Connect your agent to the gateway and choose a tool. The first call that returns 402 shows the exact price. Get the endpoint and keys from the connect page.
Keep the first run small. One call with a low cap shows the full cycle from the 402 response to the final result.
Live pricing — developer
Data source: live tool catalog snapshot, fetched 2026-11-16.
Chart data as a table
| Tool | Price per call | Cache-hit price |
|---|---|---|
| Usage Time Series | $0.0 | $0.0 |
| Per-Tool Usage Breakdown | $0.0 | $0.0 |
| Usage Summary | $0.0 | $0.0 |
| Discover Tools | $0.0 | $0.0 |
| Batch Tool Calls | $0.0 | $0.0 |
| Tool Quality Metrics | $0.0 | $0.0 |
| Tool Quality Rankings | $0.0 | $0.0 |
| List Programming Languages | $0.001 | $0.0001 |
| Check CVE ID Reservation Status | $0.001 | $0.0001 |
| Security Advisories (deps.dev) | $0.001 | $0.0001 |
| Dependency Tree (deps.dev) | $0.001 | $0.0001 |
| Package Info (deps.dev) | $0.001 | $0.0001 |
| Tool | Provider | Price/call | Cache-hit |
|---|---|---|---|
| Usage Time Series | account | $0 | $0 |
| Per-Tool Usage Breakdown | account | $0 | $0 |
| Usage Summary | account | $0 | $0 |
| Discover Tools | apibase | $0 | $0 |
| Batch Tool Calls | platform | $0 | $0 |
| Tool Quality Metrics | platform | $0 | $0 |
| Tool Quality Rankings | platform | $0 | $0 |
| List Programming Languages | judge0 | $0.001 | $0.0001 |
| Check CVE ID Reservation Status | cve-mitre | $0.001 | $0.0001 |
| Security Advisories (deps.dev) | depsdev | $0.001 | $0.0001 |
| Dependency Tree (deps.dev) | depsdev | $0.001 | $0.0001 |
| Package Info (deps.dev) | depsdev | $0.001 | $0.0001 |
Connect via MCP
Data source: gateway design, no measured values.
$ curl -X POST https://apibase.pro/api/v1/tools/account.timeseries/call \
-H "Content-Type: application/json" -d '{"params": {}}'FAQ
Is x402 the same as an API key?
No. An API key identifies the caller to the service. x402 attaches a payment to a single request. Many setups use both, so the service knows who calls and gets paid for each call.
What does the server return when payment is missing?
The server returns HTTP status 402 Payment Required. The response body lists the price, the accepted network, and the payee address that the client must use.
Which currency does x402 use?
The 402 body names the asset the server accepts, such as USDC. Check https://www.x402.org for the current rules on supported assets.
Does an agent need a wallet to use x402?
The paying side needs a wallet key that can sign the payment. A gateway can hold that key and run the handshake, so the agent code stays free of signing logic.
Recommended next step
- STEP 1/2 Connect your MCP client
- STEP 2/2 Browse the full catalog
Related guides
- unvetted ai agents are accessing u.s. bank accounts
- mcp server roblox_studio command cmd.exe args
- usdc crypto
- ai agents for beginners
Written with AI assistance from APIbase's published documentation and public data; checked automatically against them. Corrections: https://apibase.pro/
Published: 2026-11-16Source: live apibase.pro catalog snapshot