Skip to main content

API Reference

The Lightning Enable API is a RESTful web service for integrating Bitcoin Lightning payments into your platform.

Base URL

https://api.lightningenable.com

Authentication

All API requests require authentication via the X-API-Key header:

curl -X GET https://api.lightningenable.com/api/payments \
-H "X-API-Key: le_merchant_your-api-key"

See Authentication for details.

API Endpoints

Payments

MethodEndpointDescription
POST/api/paymentsCreate payment invoice
GET/api/payments/{invoiceId}Get payment by ID
GET/api/payments/order/{orderId}Get payment by order ID
POST/api/payments/{invoiceId}/syncSync status from OpenNode

Refunds

MethodEndpointDescription
POST/api/refundsCreate refund
GET/api/refunds/{refundId}Get refund status
GET/api/refundsList all refunds
GET/api/refunds/invoice/{invoiceId}Get refunds for invoice

Exchange Rates

MethodEndpointDescription
GET/api/ratesGet current BTC exchange rates
GET/api/rates/{currency}Get rate for specific currency

L402 Protocol

MethodEndpointDescription
GET/api/l402/pricingGet L402 endpoint pricing
GET/api/l402/statusCheck L402 auth status
*/l402/proxy/{proxyId}/*L402-protected proxy

Webhooks

MethodEndpointDescription
POST/api/webhooks/opennodeOpenNode webhook receiver

Merchant Settings (Self-Service)

MethodEndpointDescription
GET/api/merchant/meGet account info and onboarding status
PUT/api/merchant/opennode-keyUpdate OpenNode API key
PUT/api/merchant/webhook-urlUpdate webhook URL
GET/api/merchant/subscriptionGet subscription details
POST/api/merchant/validate-opennodeValidate OpenNode API key
GET/api/merchant/quickstartGet onboarding guide

Health Check

MethodEndpointDescription
GET/healthStructured health check (public, no auth required)

Admin (Requires Admin Key)

MethodEndpointDescription
GET/api/admin/merchantsList merchants
POST/api/admin/merchantsCreate merchant
GET/api/admin/merchants/{id}Get merchant
PUT/api/admin/merchants/{id}Update merchant

Request Format

Headers

HeaderRequiredDescription
X-API-KeyYesYour merchant API key
Content-TypeYes (POST/PUT)application/json
X-Idempotency-KeyNoPrevents duplicate payments/refunds (UUID recommended)
X-Correlation-IdNoRequest tracing ID (auto-generated if not provided)

See Request Headers for full details on idempotency, correlation IDs, and API versioning.

Request Body

POST and PUT requests accept JSON bodies:

{
"orderId": "ORDER-12345",
"amount": 99.99,
"currency": "USD"
}

Response Format

Success Response

{
"invoiceId": "inv_abc123",
"status": "unpaid",
"amount": 99.99,
"currency": "USD"
}

Error Response

{
"error": "Bad Request",
"message": "Amount is required",
"code": "INVALID_REQUEST"
}

HTTP Status Codes

CodeDescription
200Success
201Created
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
402Payment Required - L402 payment needed
403Forbidden - Access denied
404Not Found - Resource doesn't exist
429Too Many Requests - Rate limited
500Server Error

Pagination

List endpoints support pagination using skip and take parameters:

GET /api/refunds?skip=0&take=20
ParameterDefaultDescription
skip0Number of records to skip
take50Number of records to return (max 100)

Example - get second page of 20 results:

GET /api/refunds?skip=20&take=20

Rate Limiting

PolicyLimitApplied To
Global100/minAll authenticated requests (per API key)
Read200/minGET operations
Payment Create10/minPOST /api/payments, POST /api/refunds
Admin30/min/api/admin/* endpoints

See Rate Limiting for details.

SDKs and Libraries

Official SDKs (coming soon):

  • .NET / C#
  • JavaScript / TypeScript
  • Python

Quick Examples

Create Payment

curl -X POST https://api.lightningenable.com/api/payments \
-H "X-API-Key: le_merchant_abc123" \
-H "Content-Type: application/json" \
-d '{
"orderId": "ORDER-12345",
"amount": 49.99,
"currency": "USD",
"description": "Premium Subscription"
}'

Check Payment Status

curl https://api.lightningenable.com/api/payments/inv_abc123 \
-H "X-API-Key: le_merchant_abc123"

Create Refund

curl -X POST https://api.lightningenable.com/api/refunds \
-H "X-API-Key: le_merchant_abc123" \
-H "Content-Type: application/json" \
-d '{
"invoiceId": "inv_abc123",
"amount": 49.99,
"lightningInvoice": "lnbc499900n1p..."
}'

Health Check Endpoint

The /health endpoint returns structured JSON describing the status of the API and its dependencies. It is public and does not require authentication, making it suitable for external monitoring and infrastructure health probes.

Request

curl https://api.lightningenable.com/health

Response

{
"status": "Healthy",
"totalDuration": 42.15,
"checks": [
{
"name": "database",
"status": "Healthy",
"duration": 38.72,
"description": null,
"exception": null,
"tags": ["db", "sql"]
}
]
}

Response Fields

FieldTypeDescription
statusstringOverall health: Healthy, Degraded, or Unhealthy
totalDurationnumberTotal time to run all checks (milliseconds)
checksarrayIndividual health check results
checks[].namestringName of the check (e.g., database)
checks[].statusstringCheck result: Healthy, Degraded, or Unhealthy
checks[].durationnumberTime for this check (milliseconds)
checks[].descriptionstring|nullOptional description from the check
checks[].exceptionstring|nullError message if the check failed
checks[].tagsarrayTags for categorizing checks (e.g., ["db", "sql"])

HTTP Status Codes

CodeMeaning
200All checks passed (Healthy)
503One or more checks failed (Unhealthy)

Current Checks

CheckTagsWhat It Verifies
databasedb, sqlSQL Server connectivity via EF Core CanConnectAsync

Unhealthy Response Example

When the database is unreachable, the endpoint returns HTTP 503:

{
"status": "Unhealthy",
"totalDuration": 5023.41,
"checks": [
{
"name": "database",
"status": "Unhealthy",
"duration": 5001.88,
"description": null,
"exception": "A network-related or instance-specific error occurred while establishing a connection to SQL Server.",
"tags": ["db", "sql"]
}
]
}

Using with Monitoring Tools

Azure App Service Health Probes:

Configure in the Azure portal under Monitoring > Health check:

  • Path: /health
  • The probe will automatically mark the instance as unhealthy after consecutive failures.

UptimeRobot / Pingdom / External Monitors:

Point your uptime monitor at:

https://api.lightningenable.com/health
  • Alert on HTTP status code other than 200
  • Recommended check interval: 1 minute
  • Parse the JSON response to alert on specific check failures (e.g., checks[0].status != "Healthy")

curl Quick Check:

# Check overall status
curl -s https://api.lightningenable.com/health | jq '.status'

# Check database specifically
curl -s https://api.lightningenable.com/health | jq '.checks[] | select(.name == "database") | .status'

Next Steps