Loomal

x402 Protocol

The x402 protocol is an open payment standard that uses the HTTP 402 status code to let AI agents pay for API and MCP tool access automatically, settled in stablecoins.

Also known as: x402, HTTP 402 payment protocol

What is the x402 protocol?

The x402 protocol is an open standard, originally proposed by Coinbase, for instant machine-to-machine payments over HTTP. It revives status code 402 Payment Required — reserved in the HTTP specification since the 1990s but left unused — and defines what a 402 response should actually contain: a structured payment requirement an automated client can fulfil on the spot.

The target buyer is software. Where every previous payment rail assumed a human filling in a checkout form or provisioning an API key, x402 lets an AI agent encounter a paywall mid-task, pay it, and continue — no account, no card form, no human.

The protocol flow

An agent requests a paid resource with no payment attached. The server replies 402, enclosing the price, accepted currency, and recipient address. The agent's wallet evaluates the requirement, signs a stablecoin payment authorization — typically USDC — and retries the identical request with the payment attached.

A facilitator verifies the payment and submits it to the Base network, where it settles in roughly two seconds. Only after settlement does the server execute the handler; the response carries a signed Ed25519 receipt and the on-chain transaction hash. One resource, two requests, payment complete inside the round trip.

Design properties that matter

Three properties distinguish x402 from retrofitted billing. It is pre-paid: the agent pays before the handler runs, so sellers extend no credit and unpaid traffic costs them nothing. It is final: on-chain settlement has no chargeback window, eliminating the 120-day reversal risk of card rails. And it is granular: amounts as small as $0.01 settle economically, far below the roughly $0.30 fixed-fee floor of card transactions.

It is also stateless from the buyer's perspective — no API key to provision, rotate, or leak. Authorization is the payment itself, which means a brand-new agent can transact with a brand-new server on first contact.

Roles in the x402 ecosystem

The protocol defines clean roles. The resource server prices and serves content or tool calls. The client — usually an agent's wallet library — interprets 402 responses and signs payments. The facilitator verifies payments and handles settlement so servers never touch blockchain infrastructure. The settlement layer, Base, is where transfers become final.

Because the wire format is open, these roles are mix-and-match: any compliant wallet can pay any compliant server through any facilitator. As of mid-2026, implementations exist across multiple languages and agent frameworks, with discovery feeds letting agents find priced endpoints programmatically.

x402 and the Loomal Index

Loomal runs one of the first production x402 deployments for MCP servers. The Loomal Index catalogs thousands of MCP server and API listings; maintainers who claim a listing can attach x402 pricing per tool call — minimum $0.01 — and agents pay in USDC with settlement on Base.

Loomal charges 5% on settled transactions, currently waived, and exposes a machine-readable discovery feed so agents can locate priced endpoints without scraping. For a server author, the protocol's complexity is absorbed by middleware: one wrapper around the tool registration, and the 402 negotiation happens before the handler is invoked.