PLANNT L402 / LIGHTNING
PROBLEM MCP + CLI DOCS WHITEPAPER GITHUB ↗
WHITEPAPER / V1.0 / MAY 2026

Plannt. A Bitcoin-native access control layer for AI agents.

AI agents are the first credentialed principals on the internet that nobody trained the credential layer for. This paper argues that the right primitive for autonomous machines to authenticate and pay for HTTP services is L402 over Bitcoin Lightning, and that this is a deliberate single-rail choice with consequences worth defending.

00Abstract.

Every HTTP credential in production today assumes a human operator who provisioned it, a human who can rotate it, and a human who notices when the bill arrives. None of those assumptions hold once an autonomous agent is the principal. We propose, and Plannt implements, an alternative: a payment-native HTTP authentication scheme where the credential and the payment are the same cryptographic object. Each request generates a fresh Bitcoin Lightning invoice. The payment preimage becomes a single-use bearer credential. Verification is pure HMAC against a server-held root key. The result is a stateless, sessionless, capped-spend access control layer designed for machines from first principles.

01The threat model API keys were never designed for.

An API key is a long-lived symmetric secret. A person registers for an account, generates the credential, copies it into a config file, and rotates it on whatever cadence policy demands. Every part of that ritual depends on a human in the loop. A human scopes it. A human stores it. A human revokes it when something goes wrong. The credential carries no native payment semantics. Billing is bolted on out-of-band, settled against an invoice the credential itself can neither generate nor agree to.

Autonomous agents do not fit this shape. An agent that needs to call an inference API at 03:00 cannot wait for a person to approve the request, scope a token, or authorize a top-up. The agent must acquire access at runtime, on its own, with no standing relationship to the service and no shared infrastructure beyond the open internet.

The failure modes that follow are not hypothetical. They are the bulk of the incident reports filed against API platforms today:

TRADITIONAL MODEL key issued → key stored → key leaked → bill arrives
PLANNT MODEL request made → invoice generated → payment verified → access granted → token spent

02The L402 specification.

L402 (originally LSAT, formalised as Lightning Labs' bLIP-26 proposal) is a payment-native HTTP authentication scheme. The protocol assumes nothing about the identity of the agent and everything about the cost of the work. The five-step lifecycle is short enough to fit in your head.

Agent Server LND Node | | | |-- 1. GET /endpoint ------>| | | |-- createInvoice() ---->| | |<-- BOLT11 invoice -----| |<-- 2. 402 + invoice + mac | | | | | |-- 3. pay invoice -------->|----------------------->| |<-- preimage --------------|<-----------------------| | | | |-- 4. GET /endpoint ------>| | | Authorization: L402 |-- 5. verify HMAC ----->| | macaroon:preimage | | |<-- 200 + data ------------| |

2.1Challenge.

The agent issues a normal HTTP request to a protected endpoint with no authentication header. The server generates a BOLT11 Lightning invoice via its Lightning node, mints a macaroon scoped to the invoice's payment hash, and responds with HTTP 402 Payment Required. Both artifacts return in the response body. The macaroon is a base64-encoded bearer token. The invoice is a standard BOLT11 string suitable for any Lightning wallet.

2.2Settlement.

The agent's Lightning wallet pays the invoice. On a healthy mainnet path, settlement is final in under a second. The wallet returns a 32-byte payment preimage. This is the cryptographic proof: the only way to obtain the preimage is to settle the invoice with the receiving node. Possession of the preimage is mathematically identical to possession of the payment.

2.3Verification.

The agent retries the original request with the header Authorization: L402 macaroon:preimage. The server recomputes HMAC(root_key, payment_hash) and compares the result against the macaroon's identifier. If they match, the payment is real, and the access is granted. The token is then marked spent, irreversibly.

The verification equation is the entire access decision:

    if HMAC(root_key, payment_hash) == macaroon_id
        AND token_not_yet_spent(preimage):
        access granted; mark_spent(preimage)
    else:
        401 invalid token

There is no database lookup for the access decision itself. The server holds a root key and a small in-memory record of recently spent preimages. Horizontal scaling is trivial because state is bounded by the spent-set TTL, not by the number of users.

03Why Bitcoin Lightning, specifically.

L402 is a payment-rail-agnostic protocol in its specification. In its practice, it requires three properties from whatever rail it sits on:

  1. Final settlement in seconds. The retry must happen on the same TCP roundtrip horizon as the original request. If settlement takes minutes, the protocol is unusable for HTTP.
  2. Per-request granularity at sub-cent cost. A 21-sat invoice must settle for a fraction of a US cent. If the fee for a single API call costs more than the call itself, the protocol is unusable for high-frequency machine traffic.
  3. Permissionless transit end-to-end. No issuer, no acquirer, no chargeback layer, no compliance gate between the agent and the API. If the rail can refuse a payment, the rail is the auth, not the protocol.

Bitcoin Lightning is the only network in production today that delivers all three. Sats settle in under a second across well-routed paths. The base fee for a routed Lightning payment is typically zero plus a few millisats. The network operates without an issuer, an acquirer, a chargeback layer, or a compliance gate. The network is, in its protocol-level design, indifferent to who is paying whom.

3.1The properties Lightning shares with HTTP.

Lightning and HTTP are both stateless at the wire level, request-scoped at the application level, and identity-blind by default. The agent does not need an account to make a payment. The server does not need an account to receive one. The payment is the relationship. L402 is the protocol that makes this isomorphism visible to the application layer.

04Stateless verification, formally.

A claim worth making precisely: the L402 access decision can be made without any durable state besides the server-held root key. The argument:

Macaroon construction. When the server generates a macaroon at challenge time, the macaroon identifier is computed as HMAC(root_key, payment_hash). The payment hash is the SHA-256 of the eventual preimage. The macaroon and the invoice are bound together by this hash, but neither is bound to a user, a session, or a database row.

Verification. When the agent retries with the preimage, the server computes SHA-256(preimage) == payment_hash and then recomputes the macaroon identifier from the payment hash. If both checks pass, the agent has proven two things in one step: that the invoice was paid, and that the macaroon was legitimately issued by the server. The server does not need to remember what it issued. It needs only the root key to verify what it would have issued.

Spent-set discipline. To prevent replay, the server tracks preimages it has accepted within a short TTL window. This is the only state in the protocol, and it is local, ephemeral, and bounded. A replicated cache (Redis, an in-memory LRU, or a CRDT among server replicas) suffices. The protocol's correctness does not depend on this state being globally consistent across the entire fleet, only consistent for the request-handler that accepts the retry.

CONSEQUENCE

Two L402 servers behind a load balancer share nothing but the root key. A request challenged by server A can be retried against server B without coordination. The protocol scales horizontally by default, because verification is a pure function of the request and the root key.

05The deliberate choice: not x402.

Other proposals exist for payment-native HTTP. The most prominent is x402, which makes the opposite bet from Plannt: payment-native HTTP, but on stablecoins, settled on an EVM-compatible chain. That is a legitimate design choice. It is not the one Plannt is making, and the difference is not cosmetic.

The operational consequences of choosing stablecoins as the rail include:

Plannt is not multi-rail. Settlement is in sats. The unit of account and the credential share one trust assumption, because they are the same object. That property only survives on a payment network that is permissionless, programmable, and final. That network is Lightning.

This is a positioning choice. The agent-builder community is bifurcating along exactly this fault line. Plannt is the protocol-pure Bitcoin-native option for the half of that community that wants the credential and the money to share one trust surface, and that wants the trust surface to be the smallest one available.

06Properties of the resulting system.

The L402-over-Lightning design produces five emergent properties worth listing:

07Open questions and future work.

The protocol is in production at api.plannt.com and the implementation is open source. The list below is what we are actively working on or watching:

08References and prior art.

This whitepaper is intended as a living document. The version above is v1.0. Issues and pull requests against the public repository are welcome at github.com/HashRails/plannt-api.

VIEW THE API READ THE DOCS BACK TO PLANNT