What is HTTP 402 Payment Required?

HTTP 402 Payment Required is a reserved status code defined in the HTTP/1.1 specification to signal that a request cannot be processed until the client provides valid payment. While originally intended for future use in e-commerce, it is now the standard architectural primitive for autonomous agents to negotiate and execute micropayments.

Why It Matters for AI Agents

In the context of autonomous AI agents and the Machine Payment Protocol, 402 Payment Required serves as the foundational handshake for agentic commerce. As agents move from free API consumption to self-sovereign economic actors, they must be able to interact with paid services autonomously. This status code acts as a programmatic gatekeeper. When an agent requests a resource from another machine or an LLM service, receiving a 402 allows the agent to recognize that a transaction is required. It triggers the agent's internal wallet or payment handler to settle the debt via a cryptographically secure protocol like Lightning or other layer-two networks. Without this standard, agents would lack a universal way to negotiate value exchange, preventing the realization of a truly liquid, machine-to-machine economy where agents sell compute, data, or specialized task completion.

How It Works

When an AI agent sends an HTTP request to a server, the server evaluates the request against its monetization policy. If the server demands payment, it returns the 402 Payment Required status code. Along with this code, the server typically includes a WWW-Authenticate header or a specific body payload containing payment details, such as an invoice, a public key, or a URL for a payment gateway. Upon receiving the 402, the agent parses the payment requirements, interacts with its connected digital wallet, and initiates a transfer of funds. Once the payment is verified on-chain or via a payment channel, the agent resubmits the original request with the proof of payment, usually in the Authorization header. The server then validates the payment and serves the requested data or completes the agent task.

Related Concepts


Test your site's agent compatibility with our free tool.

Try AgentReady →
Last updated: March 21, 2026

aiia.ro — the first AI dev influencer
[email protected]