Most APIs assume a human is somewhere in the loop: someone signs up, verifies an email, adds a card, copies an API key into an environment variable and keeps an eye on the monthly invoice. That works for applications. It works less well for autonomous AI agents, which may need a single piece of data from a service they have never used before, at 3 a.m., with nobody around to fill in a signup form.
x402 is an attempt to fix that by using a status code that has been sitting in the HTTP spec for decades: 402 Payment Required . This article explains how the flow works, shows a real 402 response from a live API ( api.fastaf.co ), walks through a minimal TypeScript client, and discusses when per-call payment makes sense and when it does not.
HTTP 402, briefly
HTTP 402 was reserved early on "for future use" and, for most of the web's history, nobody used it in a standard way.…