Skip to main content

Monetize Your API in 10 Minutes

Lightning Enable's L402 proxy sits between your users and your API. Every request either includes a valid payment token or gets a Lightning invoice. No middleware. No libraries. No code changes to your API.

How It Works

Client request
→ Lightning Enable L402 Proxy
→ No payment token? Return 402 + Lightning invoice
→ Client pays invoice, gets preimage
→ Client retries with token
→ Valid token? Forward request to your API
→ Return your API's response

Your API never knows payments are happening. It receives normal HTTP requests from the proxy.

Prerequisites

  • Lightning Enable account with Agentic Commerce — Individual ($99/mo) or Agentic Commerce — Business plan ($299/mo)
  • Your API key (from dashboard after subscribing)
  • An OpenNode account (dev for testing, production after KYB)

Step 1: Configure OpenNode (Minutes 1-3)

For Testing (No KYB Required)

Create a dev account at dev.opennode.com, generate an API key, and add it to Lightning Enable:

curl -X PUT https://api.lightningenable.com/api/merchants/me \
-H "X-API-Key: YOUR_LE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"openNodeApiKey": "your-opennode-dev-key", "openNodeEnvironment": "dev"}'

For Production

Same flow at opennode.com. KYB verification takes 2-4 business days. Use testnet in the meantime.

Step 2: Create a Proxy (Minutes 4-5)

Point Lightning Enable at your API:

curl -X POST https://api.lightningenable.com/api/proxy \
-H "X-API-Key: YOUR_LE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My Weather API",
"targetBaseUrl": "https://api.myweatherapp.com/v1",
"defaultPriceSats": 10,
"description": "Weather data via Lightning micropayments"
}'

Response:

{
"proxyId": "my-weather-api-a1b2",
"proxyUrl": "/l402/proxy/my-weather-api-a1b2",
"defaultPriceSats": 10,
"isActive": true
}

Your monetized API is now live at:

https://api.lightningenable.com/l402/proxy/my-weather-api-a1b2/

Step 3: Set Endpoint Pricing (Minutes 6-7)

Different endpoints can cost different amounts:

# Current weather: cheap, high volume
curl -X POST https://api.lightningenable.com/api/proxy/my-weather-api-a1b2/pricing \
-H "X-API-Key: YOUR_LE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pathPattern": "/current/*", "priceSats": 5, "description": "Current weather"}'

# 7-day forecast: more valuable
curl -X POST https://api.lightningenable.com/api/proxy/my-weather-api-a1b2/pricing \
-H "X-API-Key: YOUR_LE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pathPattern": "/forecast/7day", "priceSats": 50, "description": "Weekly forecast"}'

# Historical data: premium
curl -X POST https://api.lightningenable.com/api/proxy/my-weather-api-a1b2/pricing \
-H "X-API-Key: YOUR_LE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pathPattern": "/historical/*", "priceSats": 100, "description": "Historical data"}'

Endpoints without specific pricing use the default (10 sats in this example).

Step 4: Test It (Minutes 8-9)

Verify your target is reachable

curl -X POST https://api.lightningenable.com/api/proxy/my-weather-api-a1b2/test \
-H "X-API-Key: YOUR_LE_API_KEY"
{
"success": true,
"targetUrl": "https://api.myweatherapp.com/v1",
"statusCode": 200,
"responseTimeMs": 234
}

Try an unpaid request

curl -i https://api.lightningenable.com/l402/proxy/my-weather-api-a1b2/current/nyc

You'll get:

HTTP/1.1 402 Payment Required
WWW-Authenticate: L402 macaroon="AgEL...", invoice="lnbc..."
{
"l402": {
"macaroon": "AgEL...",
"invoice": "lnbc50n1p...",
"amount_sats": 5,
"payment_hash": "abc123...",
"expires_at": "2026-01-15T12:10:00Z"
},
"instructions": {
"step1": "Pay the Lightning invoice using any Lightning wallet",
"step2": "Copy the preimage (proof of payment) from your wallet",
"step3": "Include in request: Authorization: L402 <macaroon>:<preimage>"
}
}

Pay and access

# After paying the invoice and getting the preimage:
curl https://api.lightningenable.com/l402/proxy/my-weather-api-a1b2/current/nyc \
-H "Authorization: L402 AgEL...:abc123def456..."

# 200 OK — your API's response, passed through

Step 5: Share Your Proxy URL (Minute 10)

Give your users (or their AI agents) the proxy URL:

https://api.lightningenable.com/l402/proxy/my-weather-api-a1b2/

That's it. Your API now accepts Lightning payments per request.

What Your Users Experience

Humans (with a Lightning wallet)

  1. Hit the endpoint, get 402 with a Lightning invoice
  2. Scan/pay with wallet (Phoenix, Alby, Breez, etc.)
  3. Get preimage, retry with Authorization: L402 header
  4. Access the data

AI Agents (with L402 support)

  1. Agent hits endpoint, gets 402
  2. Agent pays invoice automatically (via MCP, NWC, or LND)
  3. Agent accesses the data
  4. No human involved

This is the real unlock. AI agents can pay for your API without human approval loops.

Monitor Revenue

curl https://api.lightningenable.com/api/proxy/my-weather-api-a1b2/analytics \
-H "X-API-Key: YOUR_LE_API_KEY"
{
"proxyId": "my-weather-api-a1b2",
"name": "My Weather API",
"totalRequests": 5234,
"totalSatsEarned": 52340,
"averageRevenuePerRequest": 10.00
}

Manage Your Proxy

Update pricing

curl -X PUT https://api.lightningenable.com/api/proxy/my-weather-api-a1b2 \
-H "X-API-Key: YOUR_LE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"defaultPriceSats": 20}'

Disable temporarily

curl -X PUT https://api.lightningenable.com/api/proxy/my-weather-api-a1b2 \
-H "X-API-Key: YOUR_LE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"isActive": false}'

Delete

curl -X DELETE https://api.lightningenable.com/api/proxy/my-weather-api-a1b2 \
-H "X-API-Key: YOUR_LE_API_KEY"

What Lightning Enable Handles

ConcernHandled automatically
Invoice creationCreates Lightning invoices via your OpenNode account
Payment verificationVerifies preimage against payment hash cryptographically
Token managementIssues and validates macaroon tokens with caveats
Replay protectionTokens bound to path, merchant, and amount
SSRF protectionBlocks private IPs, validates target URLs
Request forwardingProxies authenticated requests to your API
AnalyticsTracks requests, revenue, and endpoint usage

Next Steps