Protocols
L402
L402 is Lightning Labs' protocol for paid APIs. A server answers with HTTP 402, a macaroon, and a BOLT 11 Lightning invoice. The client pays the invoice, receives the preimage, and retries with the macaroon and preimage in the Authorization header. The server checks the preimage against the payment hash inside the macaroon.
Explanation
The challenge header is WWW-Authenticate: L402 macaroon="…", invoice="ln…". The credential is an Authorization header whose scheme is L402, then the base64 macaroon, a colon, and the hex preimage. The macaroon is an HMAC-chained bearer token that commits to the invoice payment hash, so verification can be stateless: the hash of the preimage must match, and the macaroon signature must still be valid. The Lightning Labs specification uses 402 when no credential is present and 401 when a credential is present but invalid.
L402 was previously discussed as LSAT. The receipt is a Lightning preimage, not an ERC-20 transfer. Invoices settle across many Lightning nodes. There is no single public chain of those invoices for this index to scan the way it scans a USDC log. L402 is a metadata protocol here. Payments that instead settle as x402 USDC are counted in x402, not duplicated into an L402 series.
Live data
Related terms
Sources
- L402 protocol specification — Lightning Labs
- L402 — Lightning Labs
- BOLT 11: Invoice Protocol for Lightning Payments — Lightning Network
- Agent GDP methodology — Agent GDP