Tools · Agent-integration primitives

L402

The HTTP-native payment protocol — pay a Lightning invoice to unlock an API, with a reusable credential proving you paid.

protocol Lightning Labs MIT Links verified 2026-06-02

What it is

L402 (formerly LSAT) is an open protocol for paying for API access over plain HTTP, using the long-dormant 402 Payment Required status code. The server answers a request for a paid resource with a macaroon (a bearer credential that carries its own embedded rules) and a Lightning invoice. The client pays the invoice; the payment preimage authenticates the macaroon; the client retries with an Authorization: L402 <macaroon>:<preimage> header and gets the resource. Because the macaroon’s caveats can encode expiry, rate limits, and spend scope, an agent can pay once and reuse the credential across many calls.

It is the layer an autonomous agent touches first when it buys a service — no account, no card, no human pressing approve.

L402 is the Bitcoin-native member of the agent-payment-protocol family. Where x402 settles in a stablecoin (USDC) and Stripe/Tempo’s MPP (Machine Payments Protocol) is a multi-rail standard with Lightning as one optional method, L402 settles in Bitcoin over Lightning, with no issuer or processor in the trust path — the lowest censorship surface of the three. See Field Notes for the MPP comparison.

The same 402-style gate reappears one layer up: ContextVM’s CEP-8 applies it to an MCP tool call instead of an HTTP resource. L402 gates the resource; CEP-8 gates the call.

When to use it

  • Gating any HTTP or gRPC API behind pay-per-call or pay-per-session access.
  • Letting agents purchase compute, data feeds, or inference without a pre-provisioned account.
  • Metering access with scoped, expiring credentials rather than long-lived API keys.

Dependencies

A funded Lightning wallet to pay invoices and an L402-aware HTTP client to handle the 402 and reattach the credential; to sell access, an implementation like Aperture in front of your service, backed by a funded Lightning node. Lightning is the payment rail.

Quick start

L402 is a protocol, so you deploy an implementation. The reference proxy is Aperture (Lightning Labs) — it sits in front of any HTTP/gRPC service and handles the 402 challenge, invoice issuance, and verification, backed by a funded Lightning node. On the client side, lnget (part of lightning-agent-tools) is an L402-aware HTTP client that pays and retries automatically. The protocol spec lives in the L402 repo and is also being standardized as bLIP-0026.

Gotchas

  • It is a spec, not a product — you run an implementation (Aperture, or a third-party kit) and still need a funded Lightning node behind it to issue and settle invoices.
  • The macaroon is a bearer token: anyone holding the macaroon + preimage can use the credential within its caveats. Scope it tightly and treat it as a secret.
  • Caveats are only as good as the verifier that enforces them — the gating service is responsible for checking expiry, rate, and spend limits on every request.

For agents — connect

Catalogued for agents in the marketplace directory.

In the marketplace directory: call get_tool with slug l402 at /mcp · this card as markdown.