Skip to main content

L402 Microtransactions

L402 enables pay-per-request API monetization using the Lightning Network. Users pay a Lightning invoice to access your API - no accounts, no subscriptions, no credit cards required.

OpenNode KYC Required

L402 requires production OpenNode credentials because users pay real satoshis. Complete KYC verification before deploying L402 endpoints. Learn more

What is L402?

L402 (formerly LSAT) combines:

  • HTTP 402 Payment Required - The web's native payment status code
  • Lightning Network - Instant Bitcoin micropayments
  • Macaroons - Cryptographic bearer tokens with permissions

The Problem

Traditional API monetization requires:

  • User accounts and passwords
  • Credit cards on file
  • Monthly subscriptions (even for light usage)
  • Complex billing infrastructure
  • Fraud prevention systems

The Solution

With L402:

  • No accounts - Pay and access immediately
  • No credit cards - Bitcoin only
  • Pay-per-use - Only pay for what you consume
  • Instant access - Payment confirms in ~1 second
  • Global - Anyone with Bitcoin can access

How It Works

1. Client requests API                    2. Server returns 402
─────────────────────────────> <─────────────────────
GET /api/premium/data HTTP 402 Payment Required
Invoice: lnbc100n1p...
Macaroon: AgEL...

3. Client pays invoice 4. Client retries with proof
─────────────────────> ─────────────────────────>
Via Lightning wallet Authorization: L402 mac:preimage
(~1 second)
5. Server verifies, grants access
<─────────────────────────
HTTP 200 OK
{ "data": "..." }

Key Benefits

Traditional APIL402 API
Account requiredNo account needed
Credit card on fileNo payment method stored
Monthly subscriptionPay per request
Minimum $5-20 chargeAs low as 1 sat (~$0.0004)
Chargeback riskImpossible to reverse
KYC for usersPermissionless access

Use Cases

AI API Monetization

Charge per API call for AI services:

{
"endpoints": [
{ "path": "/api/ai/gpt4", "price": 500 },
{ "path": "/api/ai/dalle", "price": 1000 },
{ "path": "/api/ai/whisper", "price": 100 }
]
}

Premium Content

Unlock articles, reports, or media:

{
"endpoints": [
{ "path": "/api/articles/premium/*", "price": 50 },
{ "path": "/api/reports/*", "price": 500 }
]
}

Data APIs

Pay-per-query data access:

{
"endpoints": [
{ "path": "/api/market-data/*", "price": 10 },
{ "path": "/api/analytics/*", "price": 25 }
]
}

Proxy Monetization

Monetize third-party APIs you have access to:

{
"proxy": {
"name": "Premium Weather API",
"target": "https://api.weather.com",
"price": 5
}
}

Quick Example

Request Without Payment

curl https://api.yourservice.com/api/premium/data

Response: 402 Payment Required

{
"error": "Payment Required",
"l402": {
"macaroon": "AgELbGlnaHRuaW5nLWVuYWJsZQ...",
"invoice": "lnbc100n1p3...",
"amount_sats": 100,
"payment_hash": "abc123..."
}
}

Pay the Invoice

Use any Lightning wallet (Phoenix, Muun, Zeus, etc.) to pay. Get the preimage.

Request With Payment Proof

curl https://api.yourservice.com/api/premium/data \
-H "Authorization: L402 AgELbGlnaHRuaW5nLWVuYWJsZQ...:abc123def456..."

Response: 200 OK

{
"data": "Premium content here..."
}

Pricing

L402 Microtransactions: $299/month

Includes everything in Standalone API plus:

  • L402 protocol support
  • Pay-per-request billing
  • Usage metering dashboard
  • White-glove onboarding

OpenNode charges 1% per transaction for payment processing (paid directly to OpenNode).

For standalone REST API, see Standalone API ($199/mo). For Kentico sites, see Kentico Commerce ($249/mo).

Architecture

Lightning Enable handles the complexity:

+-----------------+
| Your API |
| (Protected) |
+--------+--------+
|
v
+--------+--------+ +------------------+ +-----------+
| L402 Middleware |----->| Lightning Enable |----->| OpenNode |
| (Auth Check) | | (Invoice/Verify) | | (Payment) |
+-----------------+ +------------------+ +-----------+
|
| If valid L402 credential
v
+-----------------+
| Your API Logic |
| (Execute) |
+-----------------+

Getting Started

  1. Enable L402 in your Lightning Enable configuration
  2. Configure protected paths that require payment
  3. Set pricing per endpoint
  4. Test with a Lightning wallet
  5. Deploy to production

Next Steps

Resources