Lightning
The Lightning API allows you to create invoices, decode and preview BOLT11 payment requests, and send payments over the Bitcoin Lightning Network. All amounts are in satoshis (1 BTC = 100,000,000 satoshis). Ideal for fast, low-fee Bitcoin transactions that settle in seconds. To confirm settlement for an incoming invoice, poll GET /api/lightning/invoices/:id — the presence of preimage and a status of paid is your cryptographic proof of payment.
Key Terms
The smallest unit of Bitcoin. 1 BTC = 100,000,000 satoshis. All Lightning amounts in this API are denominated in satoshis.
The standard encoding format for Lightning invoices. A BOLT11 string contains the destination, amount, description, and expiry — everything a wallet needs to make a payment.
A 64-character hex string that uniquely identifies a Lightning payment. It is derived from the payment preimage and is used to verify that a payment was completed.
A 64-character hex secret that proves a payment was successfully received. When a payment settles, the receiver reveals the preimage to the sender as proof of payment.
A payment request generated by the receiver. It encodes the amount, description, expiry, and destination so the sender knows exactly what to pay.
Whether the invoice is 'incoming' (you created it to receive payment) or 'outgoing' (you paid someone else's invoice).
A unique string you provide to ensure the same request is not processed twice. If you retry a request with the same reference, the API returns the original result instead of creating a duplicate.
Create Invoice
Use Case
Generate a Lightning invoice to receive a payment. The invoice encodes the amount, description, and expiry into a BOLT11 string that any Lightning wallet can pay.
Request Body
The customer UUID this invoice belongs to. Useful for associating payments with specific users in your system.
The invoice amount in satoshis. Must be between 1 and 20,000,000 sats (0.2 BTC). This is the exact amount the payer will be asked to send.
A human-readable description of what the payment is for (e.g., 'Payment for order #123'). This is displayed in the payer's wallet.
How long the invoice remains valid, in seconds. Default: 86400 (24 hours). After expiry, the invoice can no longer be paid.
A unique idempotency key for this request. If you send the same reference twice, the API returns the original invoice instead of creating a duplicate.
Response Body (201)
A unique UUID assigned to this invoice. Use this to retrieve or reference the invoice later.
A 64-character hex string that uniquely identifies this payment on the Lightning Network. Used to verify payment completion.
The BOLT11 invoice string. Share this with the payer — they paste it into their Lightning wallet to pay.
The invoice amount in satoshis, returned as a string to preserve precision on large values.
The description attached to the invoice.
Current state of the invoice: 'pending' (awaiting payment), 'paid' (settled), or 'expired' (no longer valid).
ISO 8601 timestamp when the invoice will expire and become unpayable.
ISO 8601 timestamp when the invoice was created.
Decode Payment Request
Use Case
Decode a BOLT11 invoice string to inspect its contents before paying. This reveals the amount, destination, description, and whether the invoice has expired — without sending any funds.
Request Body
A BOLT11-encoded Lightning invoice string. This is the payment request you want to inspect.
Response Body (200)
The unique hash identifying this payment. Used to track and verify the payment across the Lightning Network.
The public key of the Lightning node that will receive the payment. This is a 66-character hex string unique to each node.
The invoice amount in satoshis.
The invoice amount in millisatoshis (1 sat = 1000 msat). Used for more precise routing calculations.
The human-readable memo attached to the invoice by the creator.
Unix timestamp (seconds) when the invoice expires.
Whether the invoice has already expired. If true, the invoice can no longer be paid.
Initiate Payment
Use Case
Initiate a Lightning payment by submitting a BOLT11 invoice. This previews the payment details including the destination, amount, routing fee, and whether a valid route exists — before the payment is finalized.
Request Body
The BOLT11 invoice string to pay. Must be a valid Lightning invoice.
Response Body (200)
The hash that identifies this payment on the Lightning Network.
The public key of the destination node that will receive the payment.
The amount to be sent in satoshis.
The estimated routing fee in satoshis.
The total cost of the payment (amount + fee) in satoshis.
The description embedded in the Lightning invoice.
Unix timestamp when the invoice expires.
Whether the invoice has already expired.
Whether a valid route to the destination was found. If false, the payment cannot be completed.
Pay Invoice
Use Case
Pay a BOLT11 invoice. Deducts the invoice amount plus the routing fee from your wallet and settles over the Lightning Network. The payment is final once status is paid — Lightning settlements are irreversible. Idempotent on reference: retrying with the same reference returns the original payment instead of double-spending.
Request Body
The BOLT11 invoice string to pay. Must be valid and unexpired.
Unique idempotency key. Retrying with the same reference returns the original payment and will not debit the wallet twice.
Customer UUID that initiated this payment, for attribution on the transaction record.
Maximum routing fee you will tolerate, in satoshis. The payment aborts before sending if the estimated fee exceeds this value. Omit or set to 0 for no cap.
Response Body (201)
Top-level flag indicating the payment was sent successfully.
Human-readable status message.
Unique identifier for this payment record.
64-character hex hash identifying this payment on the Lightning Network.
The 64-character hex preimage — your cryptographic proof that the recipient received the funds. Store this for dispute resolution; it is unforgeable evidence of settlement.
Amount sent in satoshis, returned as a string.
Actual routing fee charged, in satoshis, returned as a string. Deducted from your wallet in addition to amount_sat.
Payment status: 'paid' (settled), 'pending' (in-flight), or 'failed' (could not route or settle).
RFC-3339 timestamp when the payment was created.
The idempotency key you supplied, echoed back.
Transaction record ID linking this payment to your ledger. Usually identical to data.id.
Unique request identifier for support and tracing.
Server time when the response was generated.
Once status returns paid, the payment has settled on-network and cannot be reversed. Always honour the idempotency contract — retry with the same reference on network errors so you never double-spend, and treat a 5xx without a response body as "unknown outcome" until you re-query with the same reference.
Get Invoice
Use Case
Retrieve a single Lightning invoice by its ID. Use this to check the current status of an invoice (pending, paid, or expired) and access its full details.
Response Body (200)
Top-level flag indicating the invoice was retrieved.
Human-readable status message.
The unique identifier of the invoice.
64-character hex hash uniquely identifying this payment on the Lightning Network.
The BOLT11 invoice string.
Payment preimage — proof of payment. Empty string while status is 'pending'; populated once the invoice settles.
Invoice amount in satoshis, returned as a string to preserve precision.
Invoice amount in millisatoshis (1 sat = 1000 msat), returned as a string.
Routing fee in satoshis. Always '0' for incoming invoices you created.
Routing fee in millisatoshis. Always '0' for incoming invoices you created.
The description attached to the invoice.
Current state: 'pending', 'paid', 'expired', or 'failed'.
'incoming' if you created this invoice to receive a payment, 'outgoing' if you paid someone else's invoice.
The ID of the company that owns this invoice.
The customer associated with the invoice, if provided during creation.
The idempotency key supplied at creation, echoed back.
Unix epoch seconds (as a string) when the invoice expires — e.g. '1774192723'. Differs from Create, which returns RFC-3339.
RFC-3339 timestamp when the invoice was created.
RFC-3339 timestamp of the last update (e.g. when status flipped to 'paid'). Empty string if the invoice has never been updated.
Unique request identifier for support and tracing.
Server time when the response was generated.
List Invoices
Use Case
Retrieve a paginated list of Lightning invoices. Filter by status or direction to find specific invoices.
Query Parameters
Page number to retrieve. Default: 1.
Number of results per page. Default: 20, maximum: 100.
Filter by invoice status. Accepted values: 'pending', 'paid', 'expired', 'failed'.
Filter by direction. 'incoming' for invoices you created to receive payment, 'outgoing' for invoices you paid.
Response Body (200)
Array of invoice records. Each entry carries the full Get Invoice shape plus the millisatoshi/fee fields: payment_hash, request, preimage, amount_sat, amount_msat, fee_sat, fee_msat, description, status, direction, company_id, customer_id, reference, expires_at, created_at, updated_at.
Total number of invoices matching the filters across all pages. Returned as a string.
Current page number (1-indexed).
Number of invoices returned per page.
Unique request identifier for support and tracing.
Server time when the response was generated.
On list responses, expires_at is returned as a Unix epoch seconds string (e.g. "1776527685") — not an RFC-3339 timestamp like you see on Create/Get. Parse accordingly when computing remaining validity.