Skip to main content

Authentication

Authenticated endpoints take your merchant API key in the X-API-Key header. One key covers payments, the L402 producer API, and the merchant self-service endpoints.

curl https://api.lightningenable.com/api/merchant/me \
-H "X-API-Key: YOUR_API_KEY"

A few endpoints are public and need no key: /health, GET /api/payments/{invoiceId}/status, the hosted checkout page at /pay/{token}, L402-gated proxy routes (/l402/proxy/*, which take an L402 credential instead), and the signup endpoints.

API key format​

Treat your API key as an opaque string. Store it exactly as issued and send it back verbatim. Some keys start with lgw_ and some don't; both are valid, and the format may change, so don't validate a prefix or a length.

Getting your API key​

You get a key when you create an account:

  • Free Producer Sandbox: sign up with your email at /dashboard/signup; open the confirmation link in your email, type the email address you signed up with, and press Confirm and create my account; the key is shown after you confirm. Opening the link alone doesn't create the account.
  • L402 Fast Lane: pay a small Lightning invoice; the key is in the response. See Activate with Lightning.
  • Card checkout: the key is shown on the success page.

View or regenerate it any time at Dashboard → Settings (/dashboard/settings).

Keeping your key safe​

  • Keep it out of version control. Load it from an environment variable or a secret manager.
  • Never put it in browser code. For client-side payment polling, use the public GET /api/payments/{invoiceId}/status.
  • Rotate it if it may have leaked, or when someone with access leaves.

Key rotation​

Regenerate the key at Dashboard → Settings → API Key → Regenerate, or with POST /api/merchant/regenerate-key. The old key stops working immediately, so have the new one ready to deploy before you rotate.

Error responses​

Missing API key​

HTTP/1.1 401 Unauthorized

{
"error": "API key required",
"message": "Please provide API key in X-API-Key header"
}

Invalid API key​

HTTP/1.1 401 Unauthorized

{
"error": "Invalid API key",
"message": "The provided API key is invalid or inactive"
}

You also get this if the account was deactivated. A request that authenticates but hits a subscription or feature gate gets a 403 instead; see the Error Reference.

Failed-authentication throttling​

Failed authentications are counted per IP address. More than 20 failures (missing or invalid key) in a 60-second window blocks authenticated requests from that IP until the window ends:

HTTP/1.1 429 Too Many Requests
Retry-After: 42

{
"error": "Too many failed authentication attempts",
"message": "Slow down and try again in 42 seconds"
}

This means your integration keeps sending a wrong or stale key. Fix the key; don't retry with it, because each retry records another failure. The general rate limiter's 429 says "Too many requests" instead; see Rate Limiting.

Test your key​

curl https://api.lightningenable.com/api/merchant/me \
-H "X-API-Key: YOUR_API_KEY"

200 means the key works; 401 means it's missing or invalid. /health needs no key, so use it to tell an outage from a key problem.

Code examples​

JavaScript​

const response = await fetch('https://api.lightningenable.com/api/merchant/me', {
headers: { 'X-API-Key': process.env.LIGHTNING_ENABLE_API_KEY }
});
if (response.status === 401) throw new Error('Invalid API key');
const account = await response.json();

C#​

var client = new HttpClient { BaseAddress = new Uri("https://api.lightningenable.com") };
client.DefaultRequestHeaders.Add("X-API-Key", config["LightningEnable:ApiKey"]);
var account = await client.GetFromJsonAsync<JsonElement>("/api/merchant/me");

Python​

import os
import requests

response = requests.get(
'https://api.lightningenable.com/api/merchant/me',
headers={'X-API-Key': os.environ['LIGHTNING_ENABLE_API_KEY']},
)
response.raise_for_status()

Next steps​