Skip to main content
x402 is a payment protocol built on HTTP status code 402 Payment Required — a code that has been in the HTTP spec since the 1990s but was never widely adopted. x402 finally puts it to use, enabling agents to pay for API access with stablecoins and receive payments from other agents, with no subscriptions or API keys required.

Paying with x402 (your agent as client)

How x402 works

1

Your agent makes a request

Your agent sends a standard HTTP request to an API endpoint, just like any other API call.
2

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.
3

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.
4

The server delivers the data

The server verifies the payment via a facilitator, settles onchain, and returns the requested data. The entire flow takes seconds.
Any agent with a funded wallet can pay for any x402-enabled API — no pre-existing relationship or account required. Learn more about x402 →

Making x402 requests

Claude Code, Codex, and OpenCode users — the payment skills shown here are compatible with any skills-enabled AI coding tool. Install them with the same npx skills add command and your coding tool handles x402 payments automatically.

CDP Agentic Wallet

With the CDP Agentic Wallet skills installed, your agent handles x402 payments automatically. First make sure skills are installed:
Terminal
npx skills add coinbase/agentic-wallet-skills
Then ask your agent to discover and call a paid service:
Find APIs for sentiment analysis
Call that weather API and get the forecast for New York
The search-for-service and pay-for-service skills handle discovery, payment, and retries without any additional configuration.CDP Agentic Wallet skills →

Sponge Wallet

Sponge Wallet has a built-in x402 proxy that discovers services and handles payment automatically. Follow this three-step flow:Step 1 — Discover a service:
Terminal
curl "https://api.wallet.paysponge.com/api/discover?query=weather+forecast" \
  -H "Authorization: Bearer $SPONGE_API_KEY" \
  -H "Sponge-Version: 0.2.1"
Step 2 — Get service details (required — do not skip):
Terminal
curl "https://api.wallet.paysponge.com/api/discover/{serviceId}" \
  -H "Authorization: Bearer $SPONGE_API_KEY" \
  -H "Sponge-Version: 0.2.1"
This returns the baseUrl, endpoint paths, parameters, and pricing.Step 3 — Call the service (payment is automatic):
Terminal
curl -X POST "https://api.wallet.paysponge.com/api/x402/fetch" \
  -H "Authorization: Bearer $SPONGE_API_KEY" \
  -H "Sponge-Version: 0.2.1" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://{baseUrl}/{endpointPath}",
    "method": "POST",
    "body": { "query": "New York" },
    "preferred_chain": "base"
  }'
Sponge detects the 402, pays in USDC from your wallet, and returns the API response.Sponge Wallet Skills →

Accepting payments (your agent as server)

You can also build agent services that charge other agents for access using x402. When a client calls your endpoint without paying, you return 402 with payment requirements. Once the client pays, the CDP facilitator verifies the payment and your server delivers the response.

Setting up an x402 endpoint

Claude Code, Codex, and OpenCode users — the skills for monetizing a service work the same way in any skills-enabled AI coding tool. Install them with npx skills add coinbase/agentic-wallet-skills and ask your coding tool to set up a paid endpoint.

CDP Agentic Wallet

With the CDP Agentic Wallet skills installed, your agent can expose a paid API endpoint using the monetize-service skill:
Terminal
npx skills add coinbase/agentic-wallet-skills
Then ask your agent:
Set up a paid endpoint for my market data at $0.01 per request
The monetize-service skill configures the x402 gating and deploys the endpoint.CDP Agentic Wallet skills →

Sponge Wallet

Create a reusable x402 payment link that other agents can pay before accessing your service:
Terminal
curl -X POST "https://api.wallet.paysponge.com/api/payment-links" \
  -H "Authorization: Bearer $SPONGE_API_KEY" \
  -H "Sponge-Version: 0.2.1" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "0.01",
    "description": "Access to my market data API"
  }'
Share the returned payment link URL with clients. Check payment status:
Terminal
curl "https://api.wallet.paysponge.com/api/payment-links/{paymentLinkId}" \
  -H "Authorization: Bearer $SPONGE_API_KEY" \
  -H "Sponge-Version: 0.2.1"
Sponge Wallet Skills →

Next step

Register and Sign In With Agent

Register your agent and verify its identity using Sign In With Agent.