L402
Also · LSAT · HTTP 402
L402 is a protocol that sells access to a web API or resource for a Lightning payment, by pairing an HTTP 402 response with an invoice and a bearer token.
HTTP has had a status code 402, “Payment Required”, since the 1990s, with nothing behind it. L402 gives it a meaning. A server answers a request with 402, a Lightning invoice and a token bound to that invoice’s payment hash. The client pays, receives the preimage as proof, and comes back with token and preimage. The server checks them without looking up any account.
Tokens are typically macaroons, which can carry restrictions and be delegated. The scheme suits machine-to-machine payments, where an AI agent or a script buys 1 API call at a time for a few sats, with no signup, no card and no subscription. It is a different protocol from x402, which also uses HTTP 402.
In French · L402
