Transactions
Create Lightning invoices and send payments to BOLT11 invoices or Lightning Addresses with the Amboss Payments SDK, including live progress and sandbox testing.
The transactions resource is where money moves. createReceive mints an invoice; send pays one. Both are fully typed and work against sandbox and live wallets.
Receiving
transactions.createReceive generates a Lightning invoice for a wallet. The backend mints the invoice on the node itself, so there is no vault password or macaroon involved, and it behaves identically in sandbox and live.
const transaction = await payments.transactions.createReceive({
wallet_id: walletId,
amount: "1000", // base units (sats for BTC)
description: "Order #1234", // optional
expires_in_seconds: 3600, // optional
idempotency_key: "order-1234-attempt-1", // optional
metadata: { order_id: "1234" }, // optional, comes back on the webhook
});
transaction.payment_request; // the BOLT11 invoice to share with the payer
transaction.payment_hash;Render payment_request as a QR code or a lightning: link. Track settlement via webhooks. For the field reference and lifecycle diagram, see Receive Payments.
Checkout links
To send your customer to a hosted payment page instead of showing the invoice yourself, add checkout to the same call. The page shows the amount and a QR code, updates when they pay, and sends them back to your site.
const transaction = await payments.transactions.createReceive({
wallet_id: walletId,
amount: "21000",
description: "Order #42",
expires_in_seconds: 3600,
idempotency_key: "order-42-attempt-1",
checkout: {
success_url: "https://shop.example.com/orders/42/thanks", // optional
return_url: "https://shop.example.com/cart", // optional
style_id: brandingId, // optional
},
});
transaction.checkout?.url; // https://ambosspay.com/checkout/<id>| Field | Type | Required | Notes |
|---|---|---|---|
checkout.success_url | string | no | https URL to send the customer to after they pay. |
checkout.return_url | string | no | https URL for the Back to shop button. |
checkout.style_id | string | no | One of your team's brandings. |
Set up brandings in the dashboard: go to Checkout in the sidebar and click Create branding. Open a branding to get its ID, which is the last part of the page URL. You can also list them with the API.
Pass checkout: {} for a page with no URLs or branding. Send checkout.url to your customer, then wait for payment.completed on your webhook before you ship the order. Don't rely on the customer reaching your success_url: they might close the tab.
findOne and findMany also return checkout, with id, url, success_url, return_url and style_id. It's null for receives made without a checkout.
For what the customer sees and how long a link lives, see Checkout Links.
Sending
transactions.send mirrors the dashboard send flow. Every call requires a
non-empty password. Live sends require the real vault password; sandbox sends
accept any non-empty value such as Password123 because it is not used. For a
live wallet, the SDK derives the master key, decrypts the team symmetric key and node admin macaroon
in-process, then executes the payment directly against the node's REST
endpoint and resolves with the terminal result. The plaintext password never
leaves your process.
A live send needs all of the following, or it fails at the node-permissions lookup:
- The real vault password (see Get Started → Try sending). Sandbox still requires the argument, but any non-empty value works there.
- An API key with
WALLETS: READandWALLET_CREDENTIALS: READ, scoped to the wallet'swallet_id. The default create-key examples in API Keys don't grant this — mint a wallet-scoped credentials key instead. - Outbound HTTPS from your server to the node's REST endpoint.
Sandbox sends need no credential permission or node connectivity — see Sandbox sends below.
Base-asset wallets (BTC) pay over LND; Taproot Asset wallets pay over litd. The SDK picks the right endpoint automatically from the wallet's asset.
const { transaction, payment } = await payments.transactions.send({
walletId,
password, // vault password, decrypts the node macaroon locally
destination: { bolt11: "lnbc1..." },
// zero-amount invoice: destination: { bolt11: "lnbc1...", amountSats: "1000" },
onUpdate: ({ status }) => console.log(status), // 'IN_FLIGHT' | ...
});
payment.status; // 'SUCCEEDED' | 'FAILED'
payment.paymentHash;
payment.feeSat;Set amountSats only for a zero-amount invoice. The API rejects it for an invoice that encodes an amount. amountSats is in sats for every wallet. A Taproot Asset wallet pays it in the asset at the current exchange rate.
const { transaction, payment } = await payments.transactions.send({
walletId,
password,
destination: {
lightningAddress: "[email protected]",
amountSats: "1000",
},
});Send parameters
| Field | Type | Required | Notes |
|---|---|---|---|
walletId | string | yes | The wallet the funds come from. |
destination | SendDestination | yes | { bolt11, amountSats? } or { lightningAddress, amountSats }. |
password | string | yes | Real vault password for live sends. Any non-empty value works in sandbox because it is not used. Never sent to the API. |
teamId | string | no | Argon2 salt for macaroon decryption. Resolved automatically from the wallet; pass it only to override the resolved value. |
idempotencyKey | string | no | Replays return the original transaction. Strongly recommended for sends. |
metadata | Record<string, string> | no | Arbitrary annotation. In sandbox, set amb_sandbox_behavior. |
timeoutSeconds | number | no | Defaults to 60. |
onUpdate | (progress) => void | no | Fires on each lifecycle transition (INITIATED, IN_FLIGHT, SUCCEEDED, FAILED). |
signal | AbortSignal | no | Abort an in-flight payment. |
allowSelfPayment | boolean | no | Set to true to pay an invoice that one of your team's wallets issued, for example your Taproot Asset wallet's invoice from your BTC wallet. Defaults to false. See Paying your own invoice. |
feeLimitSats | string | no | Most the node may spend on routing fees, as a whole number of sats (e.g. "50"). Anything else throws before the send is created. Unset, the node gets no practical limit; set a cap for production payouts. retryPayment takes the same option. |
A wrong password throws DecryptionError; a node-side failure throws PaymentSendError. A send to a blocked destination throws ApiError before anything is paid, with err.graphqlErrors[0]?.extensions?.code === "PAYMENT_DESTINATION_BLOCKED". See Errors.
Sandbox sends
Sandbox wallets need no node or macaroon, but a non-empty password is still
required so the same call shape works in production. Any value such as
Password123 works because sandbox does not use it. The backend settles the transaction for you and payment comes back
null; observe the outcome via webhooks or by polling the transaction status.
Settlement follows the amb_sandbox_behavior metadata (complete, fail, or
expire; default expire). Set it to blocked to get the blocked-destination
ApiError instead.
const { transaction, payment } = await payments.transactions.send({
walletId, // a sandbox wallet
password: "Password123", // any non-empty value works in sandbox
destination: { bolt11: "lnbc1..." },
metadata: { amb_sandbox_behavior: "complete" }, // force success in sandbox
});
payment; // null, settlement happens server-sideFor network constraints, idempotency semantics, and how to inspect a failed send, see Send Payments.