What is x402? How AI agents pay for APIs over HTTP

HTTP has had a status code for payments since 1997. Code 402, Payment Required, was reserved in the original HTTP/1.1 spec with a note that it was intended "for future use." The future took almost thirty years to arrive. x402 is the protocol that finally put 402 to work, and it arrived at exactly the moment it was needed: the moment software agents started making their own purchasing decisions.

The problem x402 solves

Every API monetization model before x402 assumed a human in the loop. Someone visits a pricing page, creates an account, verifies an email, enters a credit card, generates an API key, stores that key in a secrets manager, and monitors a usage dashboard. That flow is fine for a company integrating one vendor. It is a dead end for an AI agent that decides at runtime that it needs a piece of data from a service it has never seen before.

Agents cannot fill out signup forms. They should never hold your credit card. And provisioning an API key for every service an agent might conceivably touch defeats the purpose of autonomy. What agents need is a way to pay for exactly one request, at the moment of the request, using money they already control.

That is x402: an open protocol, originally developed by Coinbase and now maintained as an open standard with a growing ecosystem of facilitators and client libraries, that lets any HTTP server charge for any HTTP request, and lets any client pay inline with stablecoins.

The request cycle, step by step

x402 needs no new transport and no sidecar service. It is regular HTTP with two extra headers and a well defined JSON body. Here is the full cycle against a live endpoint, our own Social Stats API:

Step 1: the client asks, unpaid

curl -i "https://x402.findclout.com/api/v1/post?url=https://www.tiktok.com/@nflstreetmoments/video/7401882236711"

Step 2: the server answers 402 with an offer

Instead of data, the server returns 402 Payment Required and a machine readable price sheet in the accepts array:

{
  "x402Version": 2,
  "error": "Payment required",
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:8453",
      "maxAmountRequired": "10000",
      "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "payTo": "0xD5997d52769Fc6abd86B0E6d0f0e85F31F118bd8",
      "resource": "https://x402.findclout.com/api/v1/post",
      "description": "Social post stats lookup",
      "mimeType": "application/json",
      "maxTimeoutSeconds": 60
    }
  ]
}

Read it like a receipt before the fact. The exact scheme means a fixed price. The network is eip155:8453, which is Base mainnet in CAIP-2 notation. The asset is the USDC contract on Base. The amount is 10000 atomic units, and since USDC has six decimals, that is one cent. The payTo address is where the money goes. Everything a client needs to decide and pay is in one JSON object.

Step 3: the client signs a payment

The client does not send a transaction. It signs an EIP-3009 transfer authorization: a typed message that says "I authorize moving 10000 units of my USDC to this address, valid for the next 60 seconds." Signing is free, instant, and happens locally. The signed payload is attached to a retry of the original request in a payment header.

Step 4: the facilitator verifies and settles

The server hands the signed payment to a facilitator, a neutral service (ours defaults to https://facilitator.payai.network) that verifies the signature, checks the balance, and submits the transfer on Base. Because the facilitator submits the transaction, the client pays no gas and needs zero ETH. USDC on Base settles in a couple of seconds for a fraction of a cent in network cost, which is what makes one cent prices economically sane.

Step 5: data, plus a receipt

With payment settled, the server executes the request and responds 200 with the JSON the client wanted. A settlement receipt, including the transaction reference, comes back in the PAYMENT-RESPONSE header. The client has cryptographic proof it paid and the server has cryptographic proof it was paid. No invoices, no reconciliation, no chargebacks.

What this looks like in code

In practice nobody implements the cycle by hand. The @x402/fetch package wraps the standard fetch and handles steps 2 through 5 automatically:

import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY);

const fetchWithPay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

const res = await fetchWithPay(
  "https://x402.findclout.com/api/v1/instagram/user?username=nba"
);
console.log(await res.json());

From the calling code's perspective, a paid API is indistinguishable from a free one. That single property is why x402 matters for agents: any tool that can make an HTTP request can now buy things, safely, within whatever budget its wallet holds.

Why stablecoins, why Base

Micropayments failed for decades because the rails were wrong. Card networks charge roughly thirty cents fixed per transaction, so a one cent purchase is impossible. Invoicing has human overhead. Prepaid credit systems just recreate accounts and keys with extra steps.

USDC on Base breaks the deadlock. It is a dollar denominated asset, so prices are stable and legible ($0.01 means $0.01). Base is a low cost Ethereum L2 where settlement costs are small enough that a one cent payment still makes sense. And EIP-3009 authorizations mean the paying wallet holds only USDC, with no native token juggling. A developer or an agent can be funded with five dollars and make five hundred API calls.

A live x402 API example you can hit right now

Theory is cheap, so we shipped a production example. The x402 Social Stats API is, to our knowledge, the first x402 native social media analytics API. Five endpoints return views, likes, comments, shares, and follower counts for Instagram, TikTok, and X posts by URL. Every request costs one cent. There is no API key, no signup, and no credit card, and 4xx responses are never charged.

Try the unpaid request from any terminal right now; the 402 challenge above is exactly what you will get back. When you are ready to pay it, the agent wallet tutorial walks through wallet creation, funding, and the full paying client in about ten minutes.

Where x402 is heading

The protocol is young but the direction is obvious. Agent frameworks are adding native x402 support so tools can declare prices. Indexes of x402 services are emerging so agents can discover paid APIs the way browsers discover websites. And service operators like us are learning that removing the signup wall does something surprising: it makes your API legible to machines, and machines are becoming the biggest consumers of APIs on the internet.

If you are choosing between shipping an API behind keys or behind x402, we wrote up the tradeoffs honestly in x402 vs API keys. And if you just want social stats, the quickstart gets you your first paid response in under a minute.

Want the views, not just the numbers?

FindClout runs the biggest independently owned American meme page network, with sports, finance, entrepreneurship, movie, TV, and music pages reaching real American audiences. We place brands natively inside viral clips people already love: not ads next to content, your product inside it.

Book a call at findclout.com