API Key Management
Your merchant API key authenticates your requests to the Lightning Enable API. This page covers where to find it, how to rotate it, and how to keep it safe.
Understanding API Keys
Send it in the X-API-Key header on every authenticated request. It identifies your merchant account, so anyone holding it can act as you.
API Key vs Provider API Key
You have two different keys - don't confuse them:
| Key | Purpose | Source | Used By |
|---|---|---|---|
| Lightning Enable API Key | Authenticate to Lightning Enable | Generated at signup | Your application → Lightning Enable |
| Provider credential (Strike key, OpenNode key, or NWC connection string) | Connect Lightning Enable to your payment provider or wallet | Your provider dashboard or wallet app | Lightning Enable → your provider |
Your App Lightning Enable Strike or OpenNode
│ │ │
│ X-API-Key: abc123... │ │
├───── ────────────────────────►│ │
│ (Lightning Enable API Key) │ │
│ │ Authorization: xyz789... │
│ ├─────────────────────────►│
│ │ (Provider API Key) │
Getting Your API Key
At Signup
You receive your key once, when your account is created:
- Free Producer Sandbox: after you open the confirmation link in your signup email, type the email address you signed up with on the page it opens, and press Confirm and create my account. Opening the link alone doesn't create the account.
- L402 Fast Lane: in the response to the paid
POST /api/signup/l402call (the MCPcreate_lightning_enable_accounttool saves it for you). - Stripe checkout: on the success page after payment.
The key is not emailed to you. Save it in a password manager or secret manager before you navigate away. If you lose it, reveal or regenerate it in the dashboard.
Key Management Dashboard
Access your key anytime at: https://api.lightningenable.com/dashboard/settings
The dashboard allows you to:
- View your key (masked by default) and reveal or copy it
- Regenerate it
Using Your API Key
In API Requests
Include your API key in the X-API-Key header:
curl -X POST https://api.lightningenable.com/api/payments \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY_HERE" \
-d '{
"orderId": "ORDER-1001",
"amount": 10.00,
"currency": "USD",
"description": "Product purchase"
}'
In Application Code
.NET / C#
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", Environment.GetEnvironmentVariable("LIGHTNING_ENABLE_API_KEY"));
var response = await client.PostAsync("https://api.lightningenable.com/api/payments", content);
Node.js / JavaScript
const response = await fetch('https://api.lightningenable.com/api/payments', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.LIGHTNING_ENABLE_API_KEY
},
body: JSON.stringify({ orderId: 'ORDER-1001', amount: 10.00, currency: 'USD' })
});
Python
import os
import requests
response = requests.post(
'https://api.lightningenable.com/api/payments',
headers={
'Content-Type': 'application/json',
'X-API-Key': os.environ['LIGHTNING_ENABLE_API_KEY']
},
json={'orderId': 'ORDER-1001', 'amount': 10.00, 'currency': 'USD'}
)
Managing Your API Key
Viewing Your Key
- Sign in at https://api.lightningenable.com/dashboard/settings (with your API key or a magic link).
- In the API Key card, reveal or copy the key.
Regenerating Your Key
If your key is compromised or you want to rotate it for security:
- Go to https://api.lightningenable.com/dashboard/settings
- In the API Key card, click "Regenerate API key"
- Confirm the action in the dialog
- Copy your new key immediately
- Update all your applications with the new key
You can also regenerate with POST /api/merchant/regenerate-key; the response carries the new key once.
- Your old key is invalidated instantly
- Any application using the old key will receive
401 Unauthorized - You cannot recover the old key
- Each account has one key, so there is no overlap window. Have the new value ready to deploy before you regenerate.
Security Best Practices
Do's
| Practice | Why |
|---|---|
| Store in environment variables | Keeps keys out of code |
| Use a secret manager | Centralized, audited secret storage |
| Rotate keys periodically | Limits exposure if compromised |
| Monitor for unauthorized use | Detect compromises early |
Don'ts
| Anti-Pattern | Risk |
|---|---|
| Hardcode in source code | Keys in git history forever |
| Commit to version control | Public exposure |
| Share via email/chat | Keys in searchable logs |
| Log API keys | Exposure in log aggregators |
Environment Variable Examples
Linux/macOS:
export LIGHTNING_ENABLE_API_KEY="YOUR_API_KEY_HERE"
Windows PowerShell:
$env:LIGHTNING_ENABLE_API_KEY = "YOUR_API_KEY_HERE"
.env file (local development only):
LIGHTNING_ENABLE_API_KEY=YOUR_API_KEY_HERE
Add .env to your .gitignore file.
Secret Managers
In production, keep the key in a secret manager (Azure Key Vault, AWS Secrets Manager, Google Cloud Secret Manager, HashiCorp Vault, or Kubernetes Secrets) and inject it at runtime.
Troubleshooting
"API key required"
{"error": "API key required", "message": "Please provide API key in X-API-Key header"}
Cause: Missing X-API-Key header
Fix: Add the header to your request:
-H "X-API-Key: YOUR_KEY_HERE"
"Invalid API key" (401)
{"error": "Invalid API key", "message": "The provided API key is invalid or inactive"}
Causes: the key was regenerated, mistyped, or the account is deactivated.
Fix: use the current key from the dashboard, or regenerate it.
"Subscription not active" (403)
{"error": "Subscription not active", "message": "...", "subscription_status": "past_due", "action_required": "update_payment_method"}
Cause: your key is valid, but your paid plan's Stripe subscription is past_due, canceled, or otherwise not active. Related 403s are Subscription required and Subscription period expired. Route on action_required (subscribe, update_payment_method, or renew_subscription). See Errors.
Too many failed attempts (429)
Repeated failed authentications from one IP are throttled. Wait for the Retry-After seconds, then retry with the correct key.
Related Documentation
- Getting Started - Initial setup guide
- API Reference - Authentication details
- Strike API Keys - Configuring your payment provider key
- Webhooks - Securing webhook endpoints
FAQ
Can I have multiple API keys?
No. Each merchant account has one API key. For a separate test environment, use a separate account; a Free Producer Sandbox account costs nothing.
How long is an API key valid?
API keys don't expire. A key works until you regenerate it or the account is deactivated. A lapsed subscription does not invalidate the key, but paid features answer 403 until you renew.
Can I see my old API key?
No. When you regenerate, the old key is permanently invalidated and cannot be retrieved. This is a security feature.
What if I lose my API key?
Sign in to the dashboard with a magic link, then reveal or regenerate the key.
Is the API key transmitted securely?
Yes. The API is HTTPS-only, and the key is stored encrypted at rest.