https://l402kit.com
All responses are application/json. CORS is enabled for all origins.
Invoices
Create Invoice
POST /api/invoice
Creates a BOLT11 Lightning invoice. Called automatically by ManagedProvider — you rarely need to call this directly.
Request body
Response 200
Verify Token
POST /api/verify
Validates an L402 token server-side without the SDK.
Request body
Split & Payments
Execute Split
POST /api/split
Manually trigger a 99.7/0.3% split payment to a Lightning Address. Requires x-split-secret header.
In most cases the split is triggered automatically via the Blink webhook. Use this endpoint only for manual recovery or custom integrations.
Request body
Dashboard & Stats
Get Stats
GET /api/stats
Returns payment analytics. Requires LNURL-auth session token in Authorization header.
Response 200
Pro Tier
Check Pro Access
GET /api/pro-check?address=you@blink.sv
Returns whether a Lightning Address has an active Pro subscription.
Response 200
Subscribe to Pro
GET /api/dev-token?address=you@blink.sv
Returns a Lightning invoice to purchase a 30-day Pro subscription (~9,000 sats).
Response 200
POST /api/dev-token
Activate Pro after paying the invoice.
Request body
Authentication (LNURL-auth)
Initiate Login
GET /api/lnurl-auth
Returns a LNURL-auth challenge for dashboard login. Scan the QR in the dashboard.
LNURL-pay Endpoint
GET /.well-known/lnurlp/:username
Standard LNURL-pay metadata for Lightning Address resolution. Used internally by the split mechanism.
Demo
Demo Index
GET /api/demo
Returns info about the available demo endpoints.
BTC Price (paid)
GET /api/demo/btc-price
Returns live BTC price. Requires a valid L402 token (1 sat).
Returns 402 with invoice + macaroon on first call. Retry with Authorization: L402 <macaroon>:<preimage>.
Reveal Preimage
GET /api/demo/preimage?hash=<paymentHash>
After paying the demo invoice, call this endpoint with the paymentHash to retrieve your preimage and construct the L402 token.
Webhooks
Blink Webhook Receiver
POST /api/blink-webhook
Internal endpoint. Receives signed payment confirmations from Blink (Svix HMAC-SHA256). Triggers the split and logs the payment. Not intended for direct use.
API Directory
Register an API
POST /api/register
Register your L402-protected API in the public directory. Called automatically by ManagedProvider.fromAddress() when registerDirectory is provided. Idempotent — safe to call on every server start.
Request body
Response 200
List APIs
GET /api/apis.json
Returns all registered APIs. Machine-readable — designed for agents to discover paid APIs.
Query parameters
Response 200
Data Privacy
Delete My Data
POST /api/delete-data
Initiates a LNURL-auth challenge. After wallet verification, all payment records associated with the authenticated pubkey are permanently deleted (GDPR right-to-erasure).