Get paywalled content running in under 2 minutes.
Create an account at /signup. You'll receive an API key like l402_sk_abc123...
Place this before the closing </body> tag:
<script src="https://l402-gateway.yf-ae7.workers.dev/js/l402.js"
data-api-key="YOUR_API_KEY"></script>
Wrap any content you want to paywall with data-l402-price (in satoshis):
<div data-l402-price="10" data-l402-resource="article-1">
<h2>Premium Article</h2>
<p>This content is hidden until the visitor pays 10 sats.</p>
</div>
That's it! Visitors will see a paywall overlay. After paying, the content unlocks and a token is stored in their browser.
| Attribute | Required | Description |
|---|---|---|
data-l402-price | Yes | Price in satoshis (1 sat ≈ $0.001) |
data-l402-resource | No | Unique ID for this content (default: "default"). Used for token caching. |
| Attribute | Required | Description |
|---|---|---|
data-api-key | Yes | Your tenant API key |
Base URL: https://l402-gateway.yf-ae7.workers.dev
Create an L402 invoice challenge.
curl -X POST /api/v1/invoice \
-H "X-L402-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"amount_sats": 10, "memo": "Premium article", "resource_id": "art-1"}'
Response (402):
{
"payment_request": "lnbc100n1p...",
"payment_hash": "abc123...",
"macaroon": "eyJ...",
"amount_sats": 10,
"fee_sats": 1,
"total_sats": 11
}
Verify an L402 token after payment.
curl /api/v1/verify \
-H "Authorization: L402 <macaroon>:<preimage>"
Response (200):
{
"valid": true,
"resource_id": "art-1",
"amount_sats": 10
}
Check if an invoice has been paid. Requires X-L402-Key header.
curl /api/v1/status/abc123... \
-H "X-L402-Key: YOUR_API_KEY"
List your payments. Supports ?status=paid&limit=50&offset=0.
Get payment statistics for your account.
Get your tenant info (email, verification status, fee rate).
All API calls require your API key in the X-L402-Key header:
X-L402-Key: l402_sk_your_key_here
Keep your API key secret. It provides full access to your tenant's invoices and payment data.
The L402 protocol works in 4 steps:
Authorization: L402 macaroon:preimage → content unlockedThe macaroon is HMAC-signed and contains the tenant ID, payment hash, resource ID, amount, and expiry. It cannot be forged without the server's secret key.