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
1
Satoshi (sat)unit

The smallest unit of Bitcoin. 1 BTC = 100,000,000 satoshis. All Lightning amounts in this API are denominated in satoshis.

2
BOLT11format

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.

3
Payment Hashidentifier

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.

4
Preimageproof

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.

5
Invoicepayment request

A payment request generated by the receiver. It encodes the amount, description, expiry, and destination so the sender knows exactly what to pay.

6
Directionstring

Whether the invoice is 'incoming' (you created it to receive payment) or 'outgoing' (you paid someone else's invoice).

7
Idempotency Key (reference)string

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.

Lightning API Endpoints

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.

Endpoint

Request Body
1
customer_idUUIDOptional

The customer UUID this invoice belongs to. Useful for associating payments with specific users in your system.

2
amountnumberRequired

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.

3
descriptionstringRequired

A human-readable description of what the payment is for (e.g., 'Payment for order #123'). This is displayed in the payer's wallet.

4
expirynumberOptional

How long the invoice remains valid, in seconds. Default: 86400 (24 hours). After expiry, the invoice can no longer be paid.

5
referencestringRequired

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.

Example Request

Response Body (201)
1
idstringRequired

A unique UUID assigned to this invoice. Use this to retrieve or reference the invoice later.

2
payment_hashstringRequired

A 64-character hex string that uniquely identifies this payment on the Lightning Network. Used to verify payment completion.

3
requeststringRequired

The BOLT11 invoice string. Share this with the payer — they paste it into their Lightning wallet to pay.

4
amount_satStringRequired

The invoice amount in satoshis, returned as a string to preserve precision on large values.

5
descriptionstringRequired

The description attached to the invoice.

6
statusstringRequired

Current state of the invoice: 'pending' (awaiting payment), 'paid' (settled), or 'expired' (no longer valid).

7
expires_atstringRequired

ISO 8601 timestamp when the invoice will expire and become unpayable.

8
created_atstringRequired

ISO 8601 timestamp when the invoice was created.

Example Response (201)

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.

Endpoint

Request Body
1
requeststringRequired

A BOLT11-encoded Lightning invoice string. This is the payment request you want to inspect.

Example Request

Response Body (200)
1
payment_hashstringRequired

The unique hash identifying this payment. Used to track and verify the payment across the Lightning Network.

2
destinationstringRequired

The public key of the Lightning node that will receive the payment. This is a 66-character hex string unique to each node.

3
amount_satnumberRequired

The invoice amount in satoshis.

4
amount_msatnumberRequired

The invoice amount in millisatoshis (1 sat = 1000 msat). Used for more precise routing calculations.

5
descriptionstringRequired

The human-readable memo attached to the invoice by the creator.

6
expires_atnumberRequired

Unix timestamp (seconds) when the invoice expires.

7
is_expiredbooleanRequired

Whether the invoice has already expired. If true, the invoice can no longer be paid.

Example Response (200)

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.

Endpoint

Request Body
1
requeststringRequired

The BOLT11 invoice string to pay. Must be a valid Lightning invoice.

Example Request

Response Body (200)
1
payment_hashstringRequired

The hash that identifies this payment on the Lightning Network.

2
destinationstringRequired

The public key of the destination node that will receive the payment.

3
amount_satstringRequired

The amount to be sent in satoshis.

4
fee_satstringRequired

The estimated routing fee in satoshis.

5
total_satstringRequired

The total cost of the payment (amount + fee) in satoshis.

6
descriptionstringRequired

The description embedded in the Lightning invoice.

7
expires_atstringRequired

Unix timestamp when the invoice expires.

8
is_expiredbooleanRequired

Whether the invoice has already expired.

9
route_foundbooleanRequired

Whether a valid route to the destination was found. If false, the payment cannot be completed.

Example Response (200)

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.

Endpoint

Request Body
1
requestStringRequired

The BOLT11 invoice string to pay. Must be valid and unexpired.

2
referenceStringRequired

Unique idempotency key. Retrying with the same reference returns the original payment and will not debit the wallet twice.

3
customer_idUUIDOptional

Customer UUID that initiated this payment, for attribution on the transaction record.

4
max_feeNumberOptional

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.

Example Request

Response Body (201)
1
successBooleanRequired

Top-level flag indicating the payment was sent successfully.

2
messageStringRequired

Human-readable status message.

3
data.idUUIDRequired

Unique identifier for this payment record.

4
data.payment_hashStringRequired

64-character hex hash identifying this payment on the Lightning Network.

5
data.preimageStringRequired

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.

6
data.amount_satStringRequired

Amount sent in satoshis, returned as a string.

7
data.fee_satStringRequired

Actual routing fee charged, in satoshis, returned as a string. Deducted from your wallet in addition to amount_sat.

8
data.statusStringRequired

Payment status: 'paid' (settled), 'pending' (in-flight), or 'failed' (could not route or settle).

9
data.created_atDateRequired

RFC-3339 timestamp when the payment was created.

10
data.referenceStringRequired

The idempotency key you supplied, echoed back.

11
data.transaction_idUUIDRequired

Transaction record ID linking this payment to your ledger. Usually identical to data.id.

12
metadata.request_idStringRequired

Unique request identifier for support and tracing.

13
timestampDateRequired

Server time when the response was generated.

Lightning Settlements Are Final

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.

Example Response (201)

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.

Endpoint

Response Body (200)
1
successBooleanRequired

Top-level flag indicating the invoice was retrieved.

2
messageStringRequired

Human-readable status message.

3
data.idUUIDRequired

The unique identifier of the invoice.

4
data.payment_hashStringRequired

64-character hex hash uniquely identifying this payment on the Lightning Network.

5
data.requestStringRequired

The BOLT11 invoice string.

6
data.preimageStringRequired

Payment preimage — proof of payment. Empty string while status is 'pending'; populated once the invoice settles.

7
data.amount_satStringRequired

Invoice amount in satoshis, returned as a string to preserve precision.

8
data.amount_msatStringRequired

Invoice amount in millisatoshis (1 sat = 1000 msat), returned as a string.

9
data.fee_satStringRequired

Routing fee in satoshis. Always '0' for incoming invoices you created.

10
data.fee_msatStringRequired

Routing fee in millisatoshis. Always '0' for incoming invoices you created.

11
data.descriptionStringRequired

The description attached to the invoice.

12
data.statusStringRequired

Current state: 'pending', 'paid', 'expired', or 'failed'.

13
data.directionStringRequired

'incoming' if you created this invoice to receive a payment, 'outgoing' if you paid someone else's invoice.

14
data.company_idUUIDRequired

The ID of the company that owns this invoice.

15
data.customer_idUUIDRequired

The customer associated with the invoice, if provided during creation.

16
data.referenceStringRequired

The idempotency key supplied at creation, echoed back.

17
data.expires_atStringRequired

Unix epoch seconds (as a string) when the invoice expires — e.g. '1774192723'. Differs from Create, which returns RFC-3339.

18
data.created_atDateRequired

RFC-3339 timestamp when the invoice was created.

19
data.updated_atDateRequired

RFC-3339 timestamp of the last update (e.g. when status flipped to 'paid'). Empty string if the invoice has never been updated.

20
metadata.request_idStringRequired

Unique request identifier for support and tracing.

21
timestampDateRequired

Server time when the response was generated.

Example Response (200)

List Invoices

Use Case

Retrieve a paginated list of Lightning invoices. Filter by status or direction to find specific invoices.

Endpoint

Query Parameters
1
pageintegerOptional

Page number to retrieve. Default: 1.

2
page_sizeintegerOptional

Number of results per page. Default: 20, maximum: 100.

3
statusstringOptional

Filter by invoice status. Accepted values: 'pending', 'paid', 'expired', 'failed'.

4
directionstringOptional

Filter by direction. 'incoming' for invoices you created to receive payment, 'outgoing' for invoices you paid.

Example Query

Response Body (200)
1
data.invoicesArray<Invoice>Required

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.

2
data.total_countStringRequired

Total number of invoices matching the filters across all pages. Returned as a string.

3
data.pageIntegerRequired

Current page number (1-indexed).

4
data.page_sizeIntegerRequired

Number of invoices returned per page.

5
metadata.request_idStringRequired

Unique request identifier for support and tracing.

6
timestampDateRequired

Server time when the response was generated.

expires_at on List

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.

Example Response (200)
Did you find this page useful?