Agent payments

What is HTTP 402 (Payment Required)?

Definition: HTTP 402 "Payment Required" is a status code reserved in the HTTP spec since the 1990s but never standardized — until the AI-agent era. Protocols like x402 and products like Cloudflare's Pay Per Crawl now use a 402 response to tell a machine caller exactly what a resource costs and how to pay for it programmatically.

A 402 response turns a paywall into an API: instead of a human-oriented checkout page, the server returns machine-readable payment terms; the client (often an AI agent) pays and retries. x402 standardizes this exchange — in its HTTP transport, payment terms and proofs travel in headers such as PAYMENT-REQUIRED, PAYMENT-SIGNATURE and PAYMENT-RESPONSE.

The code went from curiosity to infrastructure fast: Cloudflare's Pay Per Crawl answers unpaid AI crawlers with 402s at network scale, and its Monetization Gateway extends the same model to APIs, datasets and MCP tools.

Why was HTTP 402 never used before?

It was explicitly "reserved for future use" — there was no standard way for a machine to pay. Programmatic stablecoin payments and AI agents that need to buy access finally supplied both the rails and the demand.

Put it into practice

Call a real 402-gated API →

Related terms