WebSocket
Create Lightning Invoice
Creates a Lightning Network invoice.
Auth:API Key
Tags:
Lightning
Command Name
CreateLightningInvoiceCommand Arguments
| Field | Type | Required | Description |
|---|---|---|---|
ClientId | string | Required | Custom client ID (max 36 characters) Example: "my-invoice-123" |
AmountBtc | decimal | Required | Amount of BTC to be invoiced Example: 0.001 |
Memo | string | null | Required | Optional memo for the invoice Example: "Payment for services" |
ExpiryHours | number | null | Required | Expiry time in hours (default: 24 (if null), max: 720) Example: 24 |
ClientIdRequired
Type:
string
Description:
Custom client ID (max 36 characters)
Example:
"my-invoice-123"AmountBtcRequired
Type:
decimal
Description:
Amount of BTC to be invoiced
Example:
0.001MemoRequired
Type:
string | null
Description:
Optional memo for the invoice
Example:
"Payment for services"ExpiryHoursRequired
Type:
number | null
Description:
Expiry time in hours (default: 24 (if null), max: 720)
Example:
24Command Invocation
Command Arguments Example:
[
"my-invoice-123",
0.001,
"Payment for services",
24
]Invocation Example:
connection.invoke('CreateLightningInvoice', ['my-invoice-123', 0.001, 'Payment for services', 24])Response Event
Event Name
executionEventsSubject
execution.invoice.createdResponse containing the created Lightning invoice details
| Field | Type | Description |
|---|---|---|
httpStatusCode | number | HTTP status code of the invoice creation response |
id | string | Unique identifier for the created invoice |
expiresAt | string | ISO 8601 timestamp when the invoice expires |
message | string | Response message |
encodedPaymentRequest | string | Encoded Lightning payment request |
Example Response
{
"data": {
"httpStatusCode": 201,
"id": "inv_abc123def456",
"expiresAt": "2024-03-28T16:03:12.456Z",
"message": "Lightning invoice created successfully",
"encodedPaymentRequest": "lnbc10u1p3xnhl2pp5jmxtqn235tkjzf..."
}
}Code Examples
const signalR = require('@microsoft/signalr');
const apiKey = 'YOUR_API_KEY_HERE';
const connection = new signalR.HubConnectionBuilder()
.withUrl('https://publicapi.sandbox.hercle.financial/ExecutionLiveServer/v1', {
accessTokenFactory: () => apiKey,
})
.build();
connection.start()
.then(() => {
console.log('Connected to WebSocket');
// Invoke command
connection.invoke('CreateLightningInvoice', "my-invoice-123", 0.001, "Payment for services", 24)
.then(() => {
console.log('Command sent successfully');
})
.catch(err => {
console.error('Command failed:', err);
});
})
.catch(err => {
console.error('Connection failed:', err);
});
// Listen for events
connection.on('executionEvents', (data) => {
console.log('Received event:', data);
});SignalR API Tester
Test this command in the sandbox environment
Disconnected
Your API key is only used locally and never stored