Agent-native payments · x402

How can an AI agent pay for an API on its own, with no account?

With x402, an agent pays per call in USDC on Base — no signup, no card, no human in the loop. The server says how much; the agent signs a stablecoin payment and retries; a facilitator settles it on-chain. Here is exactly how the loop works.

x402 · USDC · Base mainnet

Try free — no signup Read the docs

TL;DR

With x402, an agent pays per call in USDC on Base — no signup, no human in the loop. The server replies 402 with payment requirements; the agent signs a USDC payment (EIP-3009) and retries with an X-PAYMENT header; a facilitator settles it on-chain and the call goes through. patternfetch implements this on Base mainnet with real USDC.

The flow, step by step

x402 takes the long-dormant HTTP 402 Payment Required status code and turns it into a real, machine-to-machine handshake. The whole exchange happens inside one ordinary HTTP round trip the agent already knows how to make:

  1. The agent calls the endpoint and gets a 402. The server answers with HTTP 402 and an x402 body describing the payment requirements — asset = USDC, the amount, the payTo address, and network = base.
  2. The agent signs the USDC transfer authorization. Using its own wallet, the agent signs an EIP-3009 transferWithAuthorization — a gasless, off-chain signature that authorizes exactly the required amount of USDC to the payTo address. No on-chain action yet, just a signed message.
  3. The agent retries the request with an X-PAYMENT header. It re-sends the identical request, now carrying the signed payment payload in the X-PAYMENT header.
  4. A facilitator verifies and settles on-chain. The server hands the payment to an x402 facilitator, which verifies the signature and submits the USDC transfer on Base. This is where the money actually moves.
  5. The server credits and returns the result. Once settlement confirms, the server fulfills the original request and returns the data — often with an X-PAYMENT-RESPONSE header confirming what settled.

This is the same model the "x402 Bazaar" indexes — a directory of x402-payable endpoints that agents can discover and pay automatically. patternfetch advertises its own x402 endpoint for discovery at /.well-known/x402.json.

Why it matters for agents

Traditional API access assumes a human: someone signs up, gets an API key, enters a credit card, and clicks through a billing portal. None of that is something an autonomous agent can do mid-loop. x402 removes every one of those steps:

no API-key provisioning no credit card no human approval no billing portal pay exactly per request

An agent can discover an endpoint, pay for it, and use it in a single loop — pricing comes from the 402 response, payment comes from its own wallet, and the result comes back in the same exchange. Pair x402 with MCP + one-click OAuth and onboarding drops to zero friction: an agent connects, and if it ever needs more than the free tier, it just pays.

How patternfetch implements it

patternfetch is an agent-first crypto market-data API and MCP server, and it is payable two ways:

1 USDC = $1 of credit. Once you hold credit, calls are metered — a market-state brief is $0.01. And you do not have to pay to find out whether it is useful:

Try before you pay:

There is a free no-signup demo (POST /v1/demo returns a real brief with no key) and a free key with starter credit (POST /v1/keys, no card). So an agent can prove the data is worth paying for before it ever signs a USDC payment. See pricing →

What the 402 challenge looks like

When a paid endpoint needs payment, the server returns HTTP 402 with a body roughly like this — the agent reads it, picks an entry it can satisfy, and signs:

Server → 402 (payment required)
HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "x402Version": 1,
  "accepts": [
    {
      "scheme": "exact",
      "network": "base",
      "asset": "<USDC contract on Base>",
      "payTo": "0xPatternfetchReceivingAddress",
      "maxAmountRequired": "10000",
      "resource": "https://patternfetch.com/v1/topup",
      "description": "Top up patternfetch credit (USDC)"
    }
  ]
}
Agent → retry with payment
POST /v1/topup HTTP/1.1
Host: patternfetch.com
X-PAYMENT: <base64 signed USDC
            authorization (EIP-3009)>

# Client libs like x402-fetch build the
# X-PAYMENT header for you: they read the
# 402, sign the USDC transfer with your
# wallet, and re-send the request — no
# manual signing, no account, no human.

# → 200 OK
# X-PAYMENT-RESPONSE: <settlement proof>

maxAmountRequired is in USDC base units (6 decimals), so 10000 = 0.01 USDC. Libraries such as x402-fetch (or x402-axios) wrap your normal HTTP client: you make the request as usual, and on a 402 they handle reading the requirements, signing with your wallet, and retrying — transparently.

Honesty about what this is

A few things worth stating plainly:

FAQ

What is x402?

An open protocol that revives HTTP 402 Payment Required for machines. A server that wants payment answers with 402 plus a JSON description of what to pay (asset, amount, recipient, network); the client signs a stablecoin payment, retries with an X-PAYMENT header, and a facilitator verifies and settles it on-chain. It lets software pay per request with no account and no human.

Does the agent need an account?

No. There is no signup and no card. The agent just needs a wallet holding USDC on Base. It reads the price from the 402, signs a USDC authorization, and retries. patternfetch also offers a free no-signup demo and a free key, so an agent can try before paying.

What network and asset?

USDC on Base mainnet. The 402 challenge specifies scheme exact, network base, the USDC asset address, the payTo address, and the amount. Because it is mainnet, payments are real and irreversible.

Can humans pay another way?

Yes. Humans can top up patternfetch credit with a Stripe card via /v1/checkout. Agents use x402 (USDC on Base) via /v1/topup. 1 USDC = $1 credit; calls are then metered ($0.01 per brief). See pricing.

Next

Try free — no signup Read the docs

More: Pricing · Docs · How-to · Try it live · discovery at /.well-known/x402.json