API Key Management
Your API key is the credential that authenticates your requests to the Lightning Enable API. This guide covers everything you need to know about API keys: how they work, where to find them, how to manage them, and security best practices.
Understanding API Keysβ
What Is Your API Key?β
Your Lightning Enable API key is a unique, randomly-generated credential that:
- Identifies your merchant account to the Lightning Enable API
- Authenticates all your API requests via the
X-API-Keyheader - Provides access to create invoices, check payment status, and manage your integration
Example API key format:
YOUR_API_KEY_HERE
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 API Key (Strike or OpenNode) | Connect Lightning Enable to your payment provider | From your provider dashboard | Lightning Enable β Strike or OpenNode |
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β
When you complete your subscription checkout:
- Stripe processes your payment
- Lightning Enable generates your API key
- Success page displays your key with copy button
The success page is the only place your key is shown at signup β it is not emailed to you. Save it to a secure location (password manager, environment variables, secret manager) before navigating away. If you lose it, view 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 current API key (masked by default)
- Reveal your full key with one click
- Regenerate your key if needed
- See when your key was last changed
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 '{
"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({ 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={'amount': 10.00, 'currency': 'USD'}
)
Managing Your API Keyβ
Viewing Your Keyβ
- Go to https://api.lightningenable.com/dashboard/settings
- Sign in to the dashboard (with your current API key or a magic link)
- In the API Key card, reveal the key
- Copy it to your clipboard
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
- Your old key is invalidated instantly
- Any application using the old key will receive
401 Unauthorized - You cannot recover the old key
- Plan your key rotation carefully to minimize downtime
Key Rotation Best Practicesβ
For production systems, follow this rotation procedure:
- Prepare - Have your deployment process ready
- Regenerate - Get the new key from the dashboard
- Update secrets - Deploy new key to all environments
- Verify - Test API calls with new key
- Monitor - Watch for any failed authentications
# Example: Updating Azure App Service
az webapp config appsettings set \
--name your-app \
--resource-group your-rg \
--settings "LIGHTNING_ENABLE_API_KEY=your-new-key"
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 |
| Use different keys per environment | Isolates dev/staging/prod |
| 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 |
| Use same key everywhere | Blast radius if compromised |
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"
Docker:
ENV LIGHTNING_ENABLE_API_KEY=${LIGHTNING_ENABLE_API_KEY}
.env file (local development only):
LIGHTNING_ENABLE_API_KEY=YOUR_API_KEY_HERE
Add .env to your .gitignore file.
Secret Managersβ
For production, use a proper secret manager:
| Platform | Service |
|---|---|
| Azure | Key Vault |
| AWS | Secrets Manager |
| Google Cloud | Secret Manager |
| Kubernetes | Secrets |
| HashiCorp | Vault |
Azure Key Vault Example:
# Store secret
az keyvault secret set \
--vault-name your-vault \
--name "LightningEnableApiKey" \
--value "YOUR_API_KEY_HERE"
# Retrieve in app
var secret = await secretClient.GetSecretAsync("LightningEnableApiKey");
var apiKey = secret.Value.Value;
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"β
{"error": "Invalid API key", "message": "The provided API key is invalid or inactive"}
Causes:
- Key was regenerated (old key no longer valid)
- Typo in the key
- Key from wrong environment (dev vs prod)
- Subscription expired or canceled
Fix:
- Check you're using the correct, current key
- Verify your subscription status
- Regenerate a new key if needed
"Subscription inactive"β
{"error": "Subscription inactive", "message": "Your subscription is not active"}
Cause: Stripe subscription is past_due, canceled, or expired
Fix:
- Check your Stripe subscription status
- Update payment method if needed
- Contact support if issue persists
API Key Lifecycleβ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Key Lifecycle β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β SIGNUP βββββΊβ ACTIVE βββββΊβ REGENERATEβββββΊβ ACTIVE β β
β β β β β β β β (new key) β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β β β β
β β β β β
β βΌ βΌ βΌ β
β Key shown on Key used for Old key New key β
β success page all API calls invalidated now active β
β + welcome email immediately β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Related Documentationβ
- Getting Started - Initial setup guide
- API Reference - Authentication details
- Payment Provider Setup - Configuring your provider API key
- Webhooks - Securing webhook endpoints
FAQβ
Can I have multiple API keys?β
Currently, each merchant account has one API key. If you need separate keys for different environments, consider separate subscriptions for dev/staging/prod.
How long is an API key valid?β
API keys don't expire based on time. They remain valid until:
- You regenerate the key
- Your subscription is canceled
- Your account is deactivated
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?β
- Log into the Key Management Dashboard
- Regenerate a new key
- Update all your applications
Is the API key transmitted securely?β
Yes. All API requests must use HTTPS, encrypting the key in transit. The key is stored encrypted at rest in our database.