AGENTWALLETS · INDEPENDENT PERSPECTIVES
L402 explained: Lightning payments and API access credentials
Understand L402 payment challenges, Lightning invoices, tokens and preimages, and distinguish access proof from fulfillment and x402 compatibility.
Quick answer
Understand L402 payment challenges, Lightning invoices, tokens and preimages, and distinguish access proof from fulfillment and x402 compatibility.
What proves paid API access?
Imagine a weather API selling access without a conventional subscription key. L402 connects an HTTP payment challenge, a Lightning payment and an access credential. Sharing HTTP status 402 with x402 does not make the two protocols interchangeable.
Invoice, token and preimage
The Lightning Labs documentation describes an initial request followed by HTTP 402 with a token and Lightning invoice in the authentication header. After checking the terms, the client pays the invoice and obtains a preimage. It then presents the token together with that preimage to access the resource.
The preimage is a secret corresponding to the payment hash. The token binds access conditions to the invoice. The service verifies the relationship rather than accepting any object called a payment receipt.
The documentation recommends Macaroons as a token format and describes restricting and delegating their permissions. A bearer credential needs protection: someone who obtains it may gain access within its permitted scope.
Compare payment machinery, not status codes
In this flow, payment proof comes from a Lightning invoice. x402 defines a different payment-requirements and payload system. Clients, verification logic and settlement environments need the appropriate implementation. Changing an endpoint does not make a stablecoin wallet capable of paying a Lightning invoice.
Aperture is a related proxy implementation that separates payment gating from backend resources. It does not eliminate application work around pricing, access scope, observability and errors.
Trace a weather request into verifiable access
Continue the weather example from a client with no credential. The server supplies payment requirements; the client checks the resource, terms and budget before paying. It retains the relevant token and proof, then requests the permitted resource. Obtaining access conditions is distinct from receiving a useful API response.
An application can correlate the resource, authority, payment reference and response in its own audit record. Do not place reusable bearer credentials in public logs. This is a client-design recommendation, not a mandatory L402 order database or an observed transaction.
If the access purchase covers several requests, evaluate that scope before assuming every network retry requires another payment.
How restrictions help delegation
The Macaroon guide describes attenuation: a bearer can add restrictions before passing a credential onward. Think of narrowing what may be done rather than arbitrarily expanding authority. A research helper needing one resource category should use conditions the issuer and verifier actually understand.
Cryptographic validity and compliance of the current request are separate checks. Verifying that a token was not altered is insufficient if the verifier ignores the relevant restrictions. No universal amount or directory field is asserted here; the implementation defines its supported conditions.
Delegating access is also different from authorizing the original wallet payment. One controls buying access, the other constrains use of what was bought.
Stateless verification still needs operations
L402 describes validating access without consulting a payment database for every request. That does not make the whole commercial product record-free. Merchants may still need incident investigation, dispute handling and abuse controls; clients need to know which authority they already obtained.
The Macaroon documentation also discusses distributed revocation difficulties. Stopping a client does not establish that every verifier immediately rejects its old credential. Deleting a shared root key can affect other users. Scope, expiry and revocation need explicit deployment decisions.
If the business requires per-request metering, immediate suspension or precise cost attribution, confirm those capabilities in the implementation. Stateless access verification alone does not provide them.
Separate proxy features from protocol compatibility
The current Aperture overview describes L402 and MPP implementations and proxy capabilities. One proxy supporting several flows does not imply identical credentials or default interoperability. Check the deployed version, payment method, verification path and backend configuration.
A desk review can cover unpaid requests, valid credentials, out-of-scope access, lost responses and revoked access. For each, identify the payment approver, verifier, backend behavior and whether existing proof may be reused. This defines a test scope; it is not an interoperability result observed for this article.
Payment is not fulfillment
After a timeout, determine whether an existing token and proof can be reused before paying again. Resource scope, duration and number of permitted requests depend on the service’s conditions. Do not assume either one request per payment or unlimited access.
A valid credential does not establish that the response arrived or that its data is useful. Refunds, disputes and client budgets need additional mechanisms. An agent should check its authority before paying, not rely on the resource server to enforce its overall budget.
No Lightning node was run and no invoice was paid for this article. Read the x402 explainer and duplicate-payment guide for related integration questions.
Sources reviewed November 5, 2026. Desk research only; no accounts, API calls or real payments were executed.
FOLLOW THE SOURCES