HTTP's 402 Error Sat Dead for 29 Years — It Just Became a Cash Register for AI Agents
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
Towards AI Academy
We Build Enterprise-Grade AI. We'll Teach You to Master It Too.
15 engineers. 100,000+ students. Towards AI Academy teaches what actually survives production.
Start free — no commitment:
→ 6-Day Agentic AI Engineering Email Guide — one practical lesson per day
→ Agents Architecture Cheatsheet — 3 years of architecture decisions in 6 pages
Our courses:
→ AI Engineering Certification — 90+ lessons from project selection to deployed product. The most comprehensive practical LLM course out there.
→ Agent Engineering Course — Hands on with production agent architectures, memory, routing, and eval frameworks — built from real enterprise engagements.
→ AI for Work — Understand, evaluate, and apply AI for complex work tasks.
Note: Article content contains the views of the contributing authors and not Towards AI.