Towards AIblog

HTTP's 402 Error Sat Dead for 29 Years — It Just Became a Cash Register for AI Agents

Thursday, July 16, 2026Chew Loong Nian - AI ENGINEERView original
Author(s): Chew Loong Nian – AI ENGINEER Originally published on Towards AI. There’s a status code in the HTTP spec that has been reserved since 1997 and almost never used: 402 Payment Required. For 29 years it sat there as a placeholder, a joke among backend developers, the "we'll figure out internet money later" IOU of HTTP/1.1. In recent weeks, major cloud providers have turned the long-idle HTTP 402 into working “agent payments” infrastructure at the network edge: AWS CloudFront/WAF added x402 support and Cloudflare opened a Monetization Gateway for the same protocol. The article explains why this shift is happening now—agents disrupt advertising, subscriptions, and traditional checkout flows—and why older approaches like blocking and pay-per-crawl don’t solve the revenue problem for machine traffic. It details how the x402 handshake works as an in-band, two-request HTTP exchange where the server returns a price (typically in USDC), the client signs and retries with a payment signature header, and a facilitator verifies/settles on-chain before the server returns the requested resource. It also covers practical deployment on both hyperscalers, a quick “20 lines” example for charging an API with an x402-express middleware, and how agent wrappers can automatically handle the 402→pay→retry loop. Finally, it weighs concerns raised by skeptics—bot impersonation, invoicing/accounting for anonymous machine buyers, routing around paid content, and edge power concentration—before concluding with recommendations on which users should adopt x402 now and how to get started on testnets in minutes. Read the full blog for free on Medium. Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor. Published via Towards AI