L402 Producer API Reference
The producer API is what you call to sell: mint a challenge, verify the credential the payer brings back, read what you have minted, and get told when a challenge is paid. Everything an integrator needs is on this page. If you're on Node or .NET, the SDKs and middleware wrap these endpoints with idiomatic ergonomics — you can use them instead. This page is for direct integrators on stacks we don't ship a package for yet, or for understanding what the SDK is doing under the hood.
| Endpoint | What it does |
|---|---|
POST /api/l402/challenges | Mint an invoice + macaroon for a resource |
GET /api/l402/challenges | List what you have minted, with payment status |
GET /api/l402/challenges/{paymentHash} | Look up one challenge |
POST /api/l402/challenges/verify | Verify a macaroon + preimage |
POST /api/l402/challenges/verify-credential | Verify a modern Payment bearer token (single-use) |
Base URL
https://api.lightningenable.com
Authentication
Every request requires your Lightning Enable merchant API key in the X-API-Key header. Generate one at Dashboard → Settings → API Keys.
X-API-Key: <your-merchant-api-key>
The key is tied to your merchant account and to an Agentic Commerce subscription (Agentic Commerce at $49/mo, or Business — contact us). L402 must be enabled on your plan — Native mode is included with both Agentic Commerce tiers.
POST /api/l402/challenges
Mint a Lightning invoice and macaroon for a given resource. Returns the components of a 402 Payment Required challenge that you present to the caller.
Request
POST /api/l402/challenges HTTP/1.1
Host: api.lightningenable.com
X-API-Key: <your-merchant-api-key>
Content-Type: application/json
Idempotency-Key: <optional, retry-safe key>
{
"resource": "/api/premium/weather",
"priceSats": 100,
"description": "Premium weather forecast"
}
Body:
| Field | Type | Required | Notes |
|---|---|---|---|
resource | string (≤ 848 chars) | yes | The path/resource the challenge is for. Bound as a caveat in the macaroon — the resulting token is only valid for this resource. Longer values are rejected with 400 before any invoice is created. |
priceSats | integer (≥ 1) | yes | Price in satoshis. |
description | string (≤ 500 chars) | no | Embedded in the Lightning invoice; visible to the payer in their wallet UI. Longer values are rejected with 400. The string that reaches the invoice is truncated to 200 UTF-8 bytes, ending in …, to stay inside the BOLT11 description field and the payment providers' own limits — so keep anything the payer needs to read at the front. Omit the field, or send a blank one, and you get L402 access: {resource}, truncated the same way. |
idempotencyKey | string (≤ 200 chars) | no | Same meaning as the Idempotency-Key header, for clients that can't set headers. The header wins if you send both. See Idempotency. |
Headers:
| Header | Required | Notes |
|---|---|---|
X-API-Key | yes | Merchant API key |
Content-Type | yes | application/json |
Idempotency-Key | no | If supplied, the same challenge is returned for repeat calls with the same key for the life of that invoice. At most 200 characters — a longer key is a 400, never a truncation. See Idempotency. |
X-Idempotency-Key | no | The spelling this API shipped with. Still accepted and identical in behaviour; Idempotency-Key wins if you send both. |