21 BTC

L402

Updated Reviewed articleRandom article
In plain words

L402 is a protocol for paying for web resources with Lightning inside an ordinary HTTP request. The server replies 402 "Payment Required" with an invoice and a token; the client pays, retries with the proof and gets access. It needs no account or API key, which suits software agents.

How a request is paid

  • The client asks for a paid resource.
  • The server answers 402 with a Lightning invoice and a macaroon (a bearer token that can carry limits such as expiry or scope).
  • The client pays; the payment reveals a secret (the preimage) that proves it paid.
  • The client repeats the request with the macaroon and the preimage, and the server lets it in without looking anyone up.

Who uses it

Lightning Labs' Aperture proxy puts an L402 paywall in front of an existing API; its Lightning Agent Tools (2026) add lnget, a downloader that pays L402 invoices automatically with a spending cap, so AI agents can buy data per request. Coinbase's x402 applies the same 402 idea to stablecoins.

L402 in the Bitcoin-for-AI catalog L402 on our Lightning page Explainer: when AI agents pay in bitcoin

See also

References

  1. Lightning Labs: L402 protocol documentation docs.lightning.engineering
  2. Aperture: L402 reverse proxy (GitHub) github.com
  3. Lightning Labs: Lightning Agent Tools (Feb 2026) lightning.engineering
  4. MDN: 402 Payment Required developer.mozilla.org

Built from 21 BTC's checked data and the sources listed. Spotted an error? Trust the source over us.