> ## Documentation Index
> Fetch the complete documentation index at: https://www.bitnob.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Bitnob has two APIs. The Business API (payouts, cards, trading, virtual accounts, stablecoin and bitcoin transfers) is at https://api.bitnob.com. The Enterprise API (non-custodial wallets) is at https://api.platform.bitnob.com.
> Business API auth: sign every request with HMAC-SHA256 and send four headers: `X-Auth-Client` (your client ID), `X-Auth-Timestamp` (Unix seconds), `X-Auth-Nonce` (16 random bytes, hex), and `X-Auth-Signature`, the hex HMAC-SHA256 of `CLIENT_ID:TIMESTAMP:NONCE:BODY` keyed with your client secret. BODY is the exact request body string you send, or an empty string. A missing header, a bad signature, or a timestamp more than about 5 minutes off returns `401`.
> Enterprise API auth: send your key in the `X-API-Key` header. Write requests such as creating a transaction also need an `Idempotency-Key` header, or they fail with `idempotency_key_required` before anything happens.
> Sandbox and production share the Business API base URL. The credentials you sign with select the environment, and `GET /api/whoami` returns it in `data.environment`. Use sandbox credentials in sample code and tests, and never put live credentials in code.
> Amounts are strings unless stated otherwise. Never parse them into floats. Balances, transactions, withdrawals (`POST /api/withdrawals`) and virtual accounts use integer strings in the smallest unit: satoshis for BTC, 6 decimals for USDT and USDC, kobo for NGN, and cents for KES and UGX (100 is 1 KES or 1 UGX). A mobile money collection takes `amount` as a JSON integer in cents.
> Payouts and trading use decimal strings in major units: a payout quote `amount` of `"1"` is 1 USDT, and a trading `quantity` of `"0.0001"` is 0.0001 BTC. Payout responses also carry `cent_amount`, the settlement amount in minor units.
> Card amounts are micro-units (1 USD = 1,000,000). Send them as JSON integers. Card responses return them as integer strings, and card webhooks as integers.
> Generate a unique `reference` for each money movement before the first attempt, and reuse it on retries. A reused reference returns `409` on payout quotes (`ALREADY_EXISTS`), withdrawals (`DUPLICATE_KEY_ERROR`) and card creation (`ALREADY_EXISTS`). It returns the existing record on NGN-pair trading orders, NGN virtual accounts and active mobile money collections. On a mobile money collection that has closed or failed it returns `409` `DUPLICATE_REFERENCE`. It isn't checked on crypto-pair trading orders, so look the order up with `GET /api/trading/orders/{reference}` before resending.
> Quotes expire at `expires_at`; read it from the response instead of assuming a window. An expired trading quote returns `422` `PRECONDITION_FAILED`, and an expired payout quote returns `400` `VALIDATION_ERROR`. Create a new quote rather than retrying. A payout quote can be initialized once, and a trading quote is consumed by the order that fills it.
> Webhooks: verify the `x-bitnob-signature` header, the hex HMAC-SHA512 of the raw request body keyed with your webhook secret, before parsing JSON. Compare in constant time and de-duplicate on `event_id`. A successful API response means accepted: confirm the outcome from the webhook, such as `payouts.withdrawal.success`.
> Errors return `status`, `code` and `detail`. Branch on `code`, never on `detail`. Since the November 5, 2026 response format change, each company gets either the current or the new error codes until its cutoff date, so handle both: `PROVIDER_ERROR` or `PROCESSING_ERROR`, and `BVN_PROVIDER_UNAVAILABLE` or `BVN_VERIFICATION_UNAVAILABLE`. A body that fails to parse returns `{"error": {"code": "BAD_REQUEST"}}`.

# LNURL and Lightning addresses

> LNURL links and email-style Lightning addresses let customers send and withdraw sats without copying invoices.

Bitnob supports LNURL and Lightning addresses to make Lightning Network usage more user-friendly. By integrating these flows, you can issue LNURL links for customers, enable them to receive or withdraw sats, and let them pay or be paid with email-style addresses (like [alice@company.com](mailto:alice@company.com)).

## What is LNURL?

LNURL is a set of open protocols that layer on top of Bitcoin’s Lightning Network. They aim to simplify workflows like receiving and paying with Lightning. LNURL can operate in two major directions:

LNURL-Pay: Customer pays a static link that auto-fetches the invoice.

LNURL-Withdraw: Customer scans a link to claim funds from a service.

Instead of manually generating an invoice for each transaction, LNURL allows a user’s wallet to request one on the fly. This makes recurring or unpredictable payments simpler because the user only has to scan a single QR or link once.

## Common LNURL use cases

1. Tipping: A content creator shares an LNURL to receive tips from fans instantly.
2. Withdraw: A user can withdraw earnings from a platform by scanning or clicking an LNURL that spawns an invoice behind the scenes.
3. Static Donations: Similar to tipping, but used for ongoing donation flows.

## Lightning addresses

Lightning addresses provide an even simpler approach: users have an “email-like” identifier (e.g., [joe@example.com](mailto:joe@example.com)). When someone wants to send them sats, they type or paste that address into a Lightning wallet that supports LNURL behind the scenes, automatically retrieving an invoice.

Receive: The payer’s wallet queries [joe@example.com](mailto:joe@example.com), obtains the invoice, and completes the payment.

Send: Similarly, you can pay another user’s Lightning address by letting your system generate the appropriate LNURL flow under the hood.

## Why Lightning addresses?

Familiar experience: Email or username style format.

Great for real-time micropayments or user handles.

No manual copying of BOLT11 invoice strings.

## LNURL + Bitnob integration

With Bitnob, you can:

1. Issue LNURLs to customers (for receiving or withdrawal flows).
2. Issue or manage Lightning addresses for each user.
3. Use the same underlying Lightning accounts you already have in Bitnob.
4. Listen for LNURL or address-based payments via webhooks.

### LNURL setup flows

#### LNURL-Pay

1. User sees a static QR or link (the LNURL).
2. Their wallet decodes the LNURL, fetches the invoice, and pays.
3. Payment arrives in your Bitnob balance, and Bitnob sends a deposit.success webhook.

#### LNURL-Withdraw

1. Your app shows a user an LNURL code that references your “custody.”
2. The user’s wallet scans it, reads the withdrawal limits, and sends Bitnob an invoice it created.
3. Payment flows from your side (e.g., a payout) to the user’s LN wallet.

#### Lightning address setup

1. You assign an address to each user (e.g., [username@yourdomain.com](mailto:username@yourdomain.com)).
2. This domain or subdomain is LNURL-enabled with the help of Bitnob’s API or your own LNURL server.
3. When someone pays [username@yourdomain.com](mailto:username@yourdomain.com), Bitnob automatically generates an invoice and forwards the payment to that user’s wallet.

## Creating LNURLs and Lightning addresses via API

1. Register your domain or subdomain with `POST /api/lnurl/domains`, add the DNS records it returns, then call `POST /api/lnurl/domains/{id}/verify`.
2. LNURL-Withdraw: Issue a link with `POST /api/lnurl/withdrawals`, setting `domain_id`, `min_withdraw_sat`, `max_withdraw_sat`, and optionally `ttl_seconds`.
3. LNURL-Pay and Lightning addresses: Create [name@yourdomain.com](mailto:name@yourdomain.com) with `POST /api/lnurl/addresses`, setting `domain_id`, `identifier`, `min_sendable_sat`, `max_sendable_sat`, and optionally `comment_max`. You can also run your own LNURL server and create invoices through the Lightning API.

### Key fields to note

| Field | Definition |
| - | - |
| Callback URLs | LNURL relies on endpoints that return invoice data upon request. |
| Min/Max Sats | LNURL-Pay can define ranges. |
| Expiry | LNURL or invoice expires after a certain time for security. |
| IDs | For each Lightning address or withdraw request you create, store the returned `id` to track user identity. |

## Handling payment notifications

Whenever a LNURL-based or Lightning address-based payment arrives:

Webhook: You receive an event like deposit.success from Bitnob, containing the paid invoice details.

Idempotency: As always, mark the payment as processed in your DB using a unique reference.

Optional Extra Steps: If the LNURL was for a withdrawal, you can automatically finalize the user’s request. If it was a LNURL pay link, you can credit them once confirmed.

## Security and best practices

1. Use unique addresses/LNURLs: Assign a new address or LNURL per user to keep transactions separate.
2. Validate domain ownership: If you run your own LNURL domain.
3. Set Sane Limits: LNURL withdraw flows can specify maximum amounts to avoid large accidental payouts.
4. Track usage: Track each LNURL’s usage so a user can’t keep re-withdrawing if your logic only expects one usage.
5. Handle Rate Limits: LNURL-compatible wallets might re-poll your callback. Include some caching or a short TTL.

## Edge cases

User scans LNURL but never completes: Their wallet might time out or show an error. LNURL sees no invoice request, so no funds move.

Underpay: LNURL flows typically define an exact invoice. Underpayment is less common unless your system supports flexible amounts.

Lightning Address DNS issues: If your domain is offline or misconfigured, payers can’t retrieve an invoice. Provide fallback (like a direct LNURL link).

## FAQ

Q:Do I need a separate Lightning node to issue LNURL?

A:

Bitnob can handle LN node operations. You just need an account, or you can integrate your own LN node behind LNURL if you want full control.

Q: Can LNURL/Lightning addresses be used on mobile?

A:

Yes. Most Lightning wallets support scanning LNURL QR codes or typing in an address, so the user never handles a raw invoice.

Q:What about LNURL or Lightning addresses for stablecoins?

A:

LNURL and addresses are specifically for Bitcoin’s Lightning. For stablecoin flows, use the stablecoin endpoints and references in the docs.

With LNURL and Lightning addresses, you can drastically improve your user’s payment experience, no more copying long BOLT11 invoices or manual invoice generation. Everything happens dynamically, behind easy-to-share links or email-style addresses.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.