Guides

Markdown

Integrate your POS

Lightning payments in an Android, desktop or web POS: ring up a sale, show the invoice, confirm the payment.

On this page

What you build#

Your POS asks SatsRail for an invoice, shows it as a QR code, and asks whether it was paid until it is. The invoice comes from the merchant's own wallet provider, and the customer pays the merchant directly: SatsRail never holds the money.

  1. Get an API key (two ways).
  2. Ask for an invoice: POST /api/v1/m/orders with the items sold, or POST /api/v1/m/payment_requests with an amount.
  3. Show the invoice's payment_request string as a QR code.
  4. Ask GET /api/v1/m/invoices/:id/status every 2 to 3 seconds until paid is true, then print the receipt.

Requests go to https://app.satsrail.com, send and receive JSON, and carry the key as Authorization: Bearer <key>. Amounts are whole numbers in the smallest unit of the merchant's currency: for a USD merchant, 2500 is $25.00. The currency is currency on GET /api/v1/m/merchant.

Two ways to connect#

A. Your POS has a backend

Your backend holds one of the merchant's secret keys. Terminals talk to your backend only, and your POS keeps the cart, taxes and receipts.

For a POS product sold to many merchants. Nobody signs in to your app.

B. A cashier signs in on the device

The app shows a code; the person approves it on satsrail.com/device, signed in there with their passkey or an emailed link, and the app gets a key for that device. No backend is needed, and the app can sell from the merchant's catalog.

For a merchant's own app, or any app a merchant chooses to sign its staff in on.

SatsRail has no passwords. With B your app never sees a password or a code: the person approves the device on SatsRail's own page, as a TV or a command line is signed in.

In a browser. Every endpoint here answers any origin, authorized by the Bearer key alone, never a cookie. Pages can read ETag, Retry-After, X-Request-Id, X-Idempotency-Replayed and the rate limit headers. Any script on the page can read the key, so a browser POS signs the cashier in (B) and never holds a secret key from Settings.

Before you start#

  • The merchant finishes setup in the dashboard first: business details, the agreements and a Lightning Address. A device signs in once it has; a test key from Settings works before that.
  • Live keys work on every plan once the account is approved. Until then, while it is set up or reviewed, a live key answers 403 merchant_not_operational. Test keys work on every plan: see Test mode.
  • A publishable key (pk_...) reads the catalog and products on sale and opens checkout sessions. It can't make an order, an invoice or a payment request.

A. Payments from your backend#

The merchant makes a secret key in Settings → API Keys and gives it to your backend:

  • sk_live_... takes real payments; sk_test_... takes none and works on every plan.
  • Its security group must manage payment requests and read invoices. The owner's group does.
  • It ends after 90 days unless the merchant picks a longer lifetime, up to a year. Read expires_at from GET /api/v1/m/api_token and warn the merchant before then; a new key is made in the same place.
  • Keep it on your server. Never put it in an app bundle or a web page.

Request a payment#

Work out the total in your POS, tax and tip included, and send it:

Shell
curl -X POST https://app.satsrail.com/api/v1/m/payment_requests \
  -H "Authorization: Bearer $SATSRAIL_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: sale-1043" \
  -d '{
    "payment_request": {
      "amount_cents": 2500,
      "description": "Sale 1043",
      "metadata": { "pos_sale_id": "1043" }
    }
  }'
  • amount_cents is required and is in the merchant's currency. There is no currency field.
  • payment_method is lightning unless you send onchain, where the merchant has it: then payment_request is a bitcoin: URI for the QR code, with address, min_payment_sats and required_confirmations.
  • description is the sale's one line on the receipt ("Payment" without it).
  • metadata is yours: put your sale's id there. It comes back on the order and in the payment.received webhook. See metadata for its rules.
  • An amount larger than any of the merchant's Lightning wallets takes in one payment answers 422 amount_exceeds_wallet_limits, and no order is made.

The answer is 201:

JSON
{
  "object": "payment_request",
  "id": "d56efcec-9a7c-46d4-a319-2e69bba34fb5",
  "order_id": "f17eea27-c453-424d-983c-4cecac8fada5",
  "livemode": false,
  "status": "pending",
  "payment_method": "lightning",
  "amount_cents": 2500,
  "currency": "usd",
  "amount_sats": 25000,
  "description": "Sale 1043",
  "metadata": { "pos_sale_id": "1043" },
  "created_at": "2026-11-16T19:11:19.117Z",
  "expires_at": "2026-11-16T20:11:19.117Z",
  "payment_request": "lntb25000n1test_d8b14c4d71bafba8de635f...",
  "payment_hash": "test_d8b14c4d71bafba8de63521371ee97b2fae52dcc4cbda8f0e33303d2fccb"
}

id is the invoice's id: ask GET /api/v1/m/invoices/:id/status (or GET /api/v1/m/payment_requests/:id/status, the same answer). order_id is the order SatsRail made for it. Save both against your sale, then show the invoice and wait for the payment. Everything below about an order's invoice applies to a payment request's. To send the items sold instead of an amount, use POST /api/v1/m/orders, which works with a secret key too.

B. Sign a cashier in on the device#

Three calls with no key make the device's key: one asks for a code, one asks whether the person approved it, and the last makes the key for the merchant they choose. It is OAuth's device authorization grant (RFC 8628).

1. Ask for a code#

Shell
curl -X POST https://app.satsrail.com/api/v1/m/sessions \
  -H "Content-Type: application/json" \
  -d '{ "device_name": "Front counter iPad" }'
JSON
{
  "device_code": "Hn0p3Wq7...",
  "user_code": "BCDF-GHJK",
  "verification_uri": "https://www.satsrail.com/device",
  "verification_uri_complete": "https://www.satsrail.com/device?code=BCDF-GHJK",
  "expires_in": 600,
  "interval": 5
}
  • Show user_code and verification_uri on the screen, and verification_uri_complete as a QR code the person can scan.
  • Keep device_code in memory and never show it. The codes last 10 minutes.
  • The person opens the page on their phone or computer, signs in to SatsRail as they always do, sees your device_name and where the request came from, and approves it.

2. Wait for the approval#

Shell
curl -X POST https://app.satsrail.com/api/v1/m/sessions/token \
  -H "Content-Type: application/json" \
  -d '{ "device_code": "Hn0p3Wq7..." }'

Ask every interval seconds. Until the person approves, the answer is 400 authorization_pending; asked sooner, slow_down. Approved, it answers once:

JSON
{
  "session_token": "eyJfcmFpbHMiOnsiZGF0YSI6...",
  "expires_in": 600,
  "merchants": [
    {
      "id": "29171108-4c61-478b-af1a-44e3e9acf56c",
      "name": "Corner Coffee",
      "logo_url": null,
      "currency": "usd",
      "role": "member",
      "live_available": true,
      "live_needs_two_factor": false
    }
  ]
}
  • access_denied: the person refused it. expired_token: the 10 minutes are over, or this approval was used. Start again from step 1.
  • session_token lasts 10 minutes and makes one key. Keep it in memory only.
  • merchants lists where this person may run a POS. live_available says whether a live key works there (the merchant is approved); live_needs_two_factor says whether a live key waits on the person adding a passkey (step 3).
  • An empty list means the person has POS access nowhere: no merchant that has finished setup gives them the POS, or each has turned device sign-in off (Settings → Orders → Devices).

3. Get the device's key#

Shell
curl -X POST https://app.satsrail.com/api/v1/m/sessions/activate \
  -H "Content-Type: application/json" \
  -d '{
    "session_token": "eyJfcmFpbHMiOnsiZGF0YSI6...",
    "merchant_id": "29171108-4c61-478b-af1a-44e3e9acf56c",
    "mode": "test",
    "device_name": "Front counter iPad"
  }'
JSON
{
  "api_key": "sk_test_...",
  "livemode": false,
  "expires_at": "2026-12-16T19:11:17.956Z",
  "renewable_until": "2027-02-14T19:11:17.957Z",
  "device_name": "Front counter iPad",
  "merchant": { "id": "29171108-4c61-478b-af1a-44e3e9acf56c", "name": "Corner Coffee", "currency": "usd" },
  "location": { "id": "812f16a8-8817-45a6-9fa2-5a6f5ba7dccb", "name": "Corner Coffee" }
}
  • mode is "live" (the default) or "test". device_name (up to 60 characters) is what the merchant sees beside the key.
  • location is where the device sells: the location the merchant set for this person, or its main one. Its orders are placed there and it reads that location's catalog.
  • Each sign-in makes a new key for that device alone. Keep it in secure storage (Keychain, Keystore). A person keeps up to 10 live and 10 test keys at one merchant; an eleventh ends the oldest of its mode.
  • A live key for anyone above a cashier needs a passkey. An owner, a manager, or anyone whose group grants more than the Cashier group gets 403 two_factor_setup_required until they add one in Account settings. Cashiers, and anyone in "mode": "test", sign in without it.
  • A refused call makes no key, so the same session token can be sent again (with "mode": "test" after merchant_not_operational, for instance).

4. Keep the key#

A device's key lasts 30 days. Renew it so a device in daily use never signs out mid-shift:

Shell
curl -X POST https://app.satsrail.com/api/v1/m/sessions/renew \
  -H "Authorization: Bearer $SATSRAIL_KEY"

It is the same key with a later end: expires_at moves to 30 days from now, never past renewable_until (90 days after sign-in). The answer is GET /api/v1/m/api_token's. Renewing twice is harmless. Call it once a day; when expires_at reaches renewable_until, ask the person to sign in again at the start of a day.

5. Sign out#

Shell
curl -X DELETE https://app.satsrail.com/api/v1/m/sessions \
  -H "Authorization: Bearer $SATSRAIL_KEY"

The answer is 204 and the key stops working at once.

When a device's key ends#

Besides signing out and running out, a key ends when the person's email changes or they remove their last passkey, when the merchant revokes it, or when the person is removed or their group stops managing the POS and orders. Every ended key answers 401 (token_expired, token_revoked or invalid_token): forget it and show the sign-in screen. An open sale is not lost; the new key reads it. 403 location_archived means the device's location was archived: sign in again.

What a device's key reaches#

The endpoints a counter needs, and of orders, invoices and payments only its own location's. It changes and cancels only orders a POS rang up; another channel's (a website's, a backend's) it reads, and a change answers 403 not_a_counter_order. Anything else answers 403 forbidden. Within this list the person's security group decides; the last column is the Cashier group as a store is first set up.

EndpointsWhat forCashier
GET /api/v1/m/api_tokenThe key: its permissions, endpoints, location and endYes
GET /api/v1/m/merchantName, currency, time zone, tip options, logoYes
GET /api/v1/m/catalog
GET /api/v1/m/catalog/version
The catalog at the key's locationYes
GET /api/v1/m/products
GET /api/v1/m/products/:id
Products, one by oneYes
GET /api/v1/m/product_types, GET /api/v1/m/locations (and /:id)Product types, locationsNo: both are in the catalog and on the key
GET, POST /api/v1/m/orders
GET, PATCH, DELETE /api/v1/m/orders/:id
Orders: list, make, read, change, cancelYes
GET /api/v1/m/invoices/:id, /status, /qr
POST /api/v1/m/invoices/generate
POST /api/v1/m/invoices/:id/simulate_payment, /simulate_expiry
Invoices, and in test mode a payment or an expiryYes
POST /api/v1/m/payment_requests, GET /api/v1/m/payment_requests/:id (and /status)An amount with no itemsNo: make an order
GET /api/v1/m/payments (and /:id)Payments receivedYes
POST /api/v1/m/sessions/renew, DELETE /api/v1/m/sessionsRenew, sign outYes

Ask the key what it may do (GET /api/v1/m/api_token), so your app can hide what it can't. The answer also carries the key's location and when it ends:

JSON
{
  "object": "api_token",
  "permissions": { "orders": "manage", "invoices": "manage", "payments": "read", "products": "read", "...": "..." },
  "endpoints": [
    "orders#index", "orders#show", "orders#create", "orders#update", "orders#destroy",
    "invoices#generate", "invoices#status", "invoices#qr", "..."
  ]
}

endpoints lists the calls this key may make (orders#create is POST /api/v1/m/orders; merchants#show, api_tokens#current and api_tokens#renew are GET /merchant, GET /api_token and POST /sessions/renew). Anything else answers 403 forbidden. When the person's security group is what refused, details names the missing resource and access; an endpoint outside the POS's list has no details.

Read the catalog#

To sell the merchant's own products, read its catalog once and keep it. A device's key reads its location's catalog, in test mode too; a secret key reads the main location's. A backend's test key (sk_test_ from Settings) reads only products made with a test key, so it starts empty: make a few with POST /api/v1/m/products using that key, each with the product_type_id of one of the merchant's product types (GET /api/v1/m/product_types) so it takes that type's taxes: {"product": {"name": "Latte", "price_cents": 450, "product_type_id": "…"}}. Without one it goes under an untaxed Default type.

Shell
curl https://app.satsrail.com/api/v1/m/catalog \
  -H "Authorization: Bearer $SATSRAIL_KEY"
JSON
{
  "object": "catalog",
  "location": { "id": "812f16a8-8817-45a6-9fa2-5a6f5ba7dccb", "name": "Corner Coffee", "time_zone": "Etc/UTC" },
  "catalog_version": "2026-11-16T19:11:17.759120Z",
  "catalog_refresh_minutes": 30,
  "product_types": [
    {
      "id": "38b69e61-283d-4c2f-bad3-f4355aeb393f",
      "name": "Drinks",
      "tax_ids": ["ba5ee3c5-e132-47f1-9c88-0d3d069a4861"],
      "products": [
        {
          "id": "prod_0d9dd3e8131d9da8c88f14bd",
          "product_id": "fb7d5bfd-4ee5-4860-b528-b0ce5add4aad",
          "name": "Latte",
          "price_cents": 450,
          "skus": [
            {
              "id": "2832b722-ffe6-406c-802a-28a74dc1ccf1",
              "price_cents": 450,
              "default": true,
              "choice_name": "Regular",
              "line_name": "Latte",
              "sold_out": false
            }
          ]
        }
      ]
    }
  ],
  "taxes": [
    { "id": "ba5ee3c5-e132-47f1-9c88-0d3d069a4861", "name": "Sales tax", "rate": "8.0", "enabled": true }
  ],
  "discounts": [
    { "id": "6f4e2d1c-8b0a-4d3e-9f21-7c5b3a2e1d09", "name": "Happy hour", "discount_type": "percentage", "value": "10.0",
      "scope": "product", "product_ids": ["prod_0d9dd3e8131d9da8c88f14bd"], "product_type_ids": [],
      "days_of_week": [1, 2, 3, 4, 5], "start_minute": 960, "end_minute": 1080, "location_ids": [] }
  ],
  "livemode": true
}
  • A product is sold as one of its skus: a latte has one, a T-shirt one per size. Sell by SKU id. choice_name labels it among its product's choices ("Large"); line_name is what to print ("Latte · Large").
  • A product type's tax_ids are the taxes its products are charged; a tax's rate is a percentage.
  • A discount of scope product is taken off by itself on the products and product types it names, when its schedule holds (days_of_week, 0 for Sunday, and start_minute to end_minute on the location's clock); a general one only when you pick it for an item with discount_ids. value is a percentage or, for fixed, an amount in cents. To show the total without repeating the arithmetic, let SatsRail price the order first (below).
  • sold_out is true when the merchant tracks stock and has none here. Such a SKU is not refused on an order: whether to sell it is the cashier's call.
  • The answer has an ETag; send it back as If-None-Match for a 304. Or compare GET /api/v1/m/catalog/version with your catalog_version every catalog_refresh_minutes.

Fields left out above (images, weights, barcodes and more) are in the API reference.

Ring up a sale#

An order is the sale: its items, its total and the invoice that pays it. Send what was sold; SatsRail prices it from the catalog, adds the taxes, and makes the invoice in the same call:

Shell
curl -X POST https://app.satsrail.com/api/v1/m/orders \
  -H "Authorization: Bearer $SATSRAIL_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: sale-1042" \
  -d '{
    "order": {
      "items": [
        { "sku_id": "2832b722-ffe6-406c-802a-28a74dc1ccf1", "qty": 2 }
      ],
      "metadata": { "pos_sale_id": "1042" }
    },
    "expected_total_amount_cents": 972,
    "generate_invoice": true
  }'

The answer is 201, the order with its invoice (shortened; the reference lists every field):

JSON
{
  "object": "order",
  "livemode": false,
  "id": "e8da24c6-dca4-4da7-8d29-aa6e1e174c05",
  "order_number": "ORD-C815383054A988AA",
  "subtotal_amount_cents": 900,
  "tax_amount_cents": 72,
  "total_amount_cents": 972,
  "status": "invoice_generated",
  "items": [
    { "name": "Latte", "price_cents": 450, "qty": 2, "line_total_cents": 900, "tax_amount_cents": 72,
      "sku_id": "2832b722-ffe6-406c-802a-28a74dc1ccf1" }
  ],
  "metadata": { "pos_sale_id": "1042" },
  "receipt_url": null,
  "invoice": {
    "id": "fb31556a-a2c0-406b-99ca-f65958711346",
    "payment_method": "lightning",
    "amount_sats": 9720,
    "status": "pending",
    "expires_at": "2026-11-16T20:11:18.683Z",
    "payment_request": "lntb9720n1test_..."
  }
}

Save the order's id and invoice.id against your sale before you show the QR code.

expected_total_amount_cents is the total your screen showed: the price, or the price with the merchant's bitcoin conversion fee (below). A price, a discount or a tax can change after you read the catalog; if the order comes to anything else, nothing is made and the answer is 422 price_changed with the figures:

JSON
{
  "error": {
    "code": "price_changed",
    "message": "The order comes to 972, not the 900 expected: a price or a tax changed since the catalog was read. Read it again (GET /api/v1/m/catalog) and show the customer the new total.",
    "status": 422,
    "details": { "total_amount_cents": 972, "expected_total_amount_cents": 900 },
    "request_id": "80d8d2d8-394b-4a16-81b4-97db3a0fe98c"
  }
}

Read the catalog again and show the new total. Without expected_total_amount_cents, compare the answer's total_amount_cents with your screen yourself.

Items#

Each item names what was sold and a qty, a whole number of at least 1. It names one of:

  • sku_id, from the catalog. Use this when you can.
  • product_id (the catalog's prod_... id or the UUID): the product's default SKU.
  • Neither, with its own name and price_cents: an open item, not from the catalog.

SatsRail fills in a catalog item's name and price, and a key sells at those prices: a catalog item sent with a price_cents of its own is refused. Something sold by weight, or any amount the catalog doesn't set, is an open item, which a cashier rings up where the merchant lets cashiers ring up open items (Settings → Orders). A backend's secret key charges an amount of its own only once the merchant lets that key charge custom amounts (Settings → API keys).

An item that left the catalog#

An item the merchant has archived, or that isn't theirs, answers 422 item_unavailable and no order is made. details names each refused item by its place in items (from 0) and why: not_found (no such SKU or product of this merchant) or not_on_sale (archived):

JSON
{
  "error": {
    "code": "item_unavailable",
    "message": "Some items are not on sale: read the catalog again (GET /api/v1/m/catalog) and ring the sale up from it. error.details says which, by its place in items.",
    "status": 422,
    "details": [
      { "index": 1, "sku_id": "d0542eb8-2fbc-4a28-b6a9-8921c1b88ab4", "reason": "not_found" },
      { "index": 2, "product_id": "prod_nope", "reason": "not_found" }
    ],
    "request_id": "721d03f2-ff20-40d3-9d29-20c3631e5aa6"
  }
}

Read the catalog again, and drop or re-pick those items.

Who works out the total#

SatsRail (recommended)
Leave total_amount_cents out, as above. Each item is priced from the catalog, its discounts applied (the catalog's own, and any you pick as discount_ids), then its product type's taxes. Tax is worked out per line and rounded to the cent, then added: two lines of 3.33 at 8% are 0.27 each, one line of two is 0.53. An item may name its own tax_ids ([] for none). Your screen need not repeat the discounts' arithmetic: make the order without generate_invoice, show its total_amount_cents, then invoice it with POST /api/v1/m/invoices/generate and that figure as expected_total_amount_cents.
Your POS
Send total_amount_cents and tax_amount_cents, with no tax_ids or discount_ids on the items. The order charges exactly your total and keeps the items as its lines. A total with no items is one amount.
Shell
curl -X POST https://app.satsrail.com/api/v1/m/orders \
  -H "Authorization: Bearer $SATSRAIL_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: sale-1044" \
  -d '{
    "order": {
      "total_amount_cents": 972,
      "tax_amount_cents": 72,
      "items": [
        { "sku_id": "2832b722-ffe6-406c-802a-28a74dc1ccf1", "qty": 2 }
      ]
    },
    "generate_invoice": true
  }'

Tips#

A tip has no field of its own:

  • Add it as an open item, {"name": "Tip", "price_cents": 200, "qty": 1}, which is charged no tax. A cashier's key can do this only where the merchant lets cashiers ring up open items.

A total of your own beside priced lines is refused: SatsRail works the total out from the lines.

Open tickets and tabs#

Make the order without generate_invoice, and send the whole list of items each time it changes:

Shell
curl -X PATCH https://app.satsrail.com/api/v1/m/orders/ORDER_ID \
  -H "Authorization: Bearer $SATSRAIL_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "order": {
      "items": [
        { "sku_id": "2832b722-ffe6-406c-802a-28a74dc1ccf1", "qty": 3 }
      ]
    }
  }'
  • The items replace the old ones and are priced again from the catalog. Show the new total_amount_cents from the answer.
  • metadata sent here replaces the order's whole: send every key you want kept.
  • When the customer is ready, make the invoice with POST /api/v1/m/invoices/generate, sending order_id and expected_total_amount_cents.
  • Once the order has an invoice, only its metadata can change (422 not_editable).
  • status takes shipped for a paid order handed over. Cash isn't recorded through the API: it is taken at the SatsRail POS, into a till. To cancel, use DELETE.

A cashier's key is held to the counter's limits#

A key whose holder doesn't manage discounts prices a sale only as far as the merchant lets a cashier (Settings → Orders). As a store is first set up, a cashier takes nothing off a list price but may raise one up to double, keeps the catalog's taxes and rings up no open items. Sales priced by SatsRail from the catalog are always within the limits. Each refusal is a 422; show its message to the cashier.

CodeWhat was refused
open_item_not_allowed, open_items_off, open_item_over_limitAn open item (a total with no items counts as one), or one priced over the store's ceiling.
discount_over_limit, price_raise_over_limitA line priced further below, or above, its list price than a cashier may go, or a total below what the lines come to. If you sent the catalog's own price, it changed: read the catalog again.
tax_exempt_not_allowedA line missing a tax its product type charges, or a tax_amount_cents below what the lines owe. Leave both out and SatsRail works the tax out.

What the request takes#

  • payment_method is lightning (the default) or onchain where the merchant has it. One the merchant can't take now, Lightning with no wallet that can take it included, answers 422 invalid_payment_method before any order is made.
  • A card: where the merchant takes cards through its own processor, the order answers checkout_url, a page where the customer pays it by card or bitcoin. Open it on the device or show it as a QR code.
  • metadata is a flat object: each value a string, a number, true, false or null. A few keys are SatsRail's own (pickup, offline, left_at, cashier_limits, cash_returned_*); name yours otherwise.
  • customer_email gets the receipt once paid, where the merchant sends receipts by email. Receipts are rate-limited per address and per merchant; past that the sale is still recorded and its receipt_url works.
  • A device's key sells at its own location: leave location_id out.
  • What is wrong is said. An unknown field answers 422 unknown_parameter naming it; a value of the wrong shape answers 422 invalid_argument saying what is wrong; a JSON body without Content-Type: application/json answers 415 unsupported_media_type. Two values are taken as they can be: tender_type: card where the merchant takes no cards makes a bitcoin order (no checkout_url), and a device_name past 60 characters is cut.

Show the invoice#

Encode the exact payment_request string as a QR code, and show the amount and a countdown to expires_at: the merchant's wallet provider's expiry, 15 minutes at most (a test invoice's too). Or let SatsRail draw it as SVG:

Shell
curl https://app.satsrail.com/api/v1/m/invoices/INVOICE_ID/qr \
  -H "Authorization: Bearer $SATSRAIL_KEY"

That call needs the Authorization header, so fetch it and insert the SVG; it can't be an <img> src. Always use the invoice made for this sale, never a static Lightning Address QR code. Showing the QR code doesn't mean the sale is paid.

The conversion fee. A merchant may add up to 3% to bitcoin payments (conversion_fee_percent on GET /api/v1/m/merchant). Then the order carries conversion_fee_cents and amount_due_cents: show amount_due_cents as what the customer pays; total_amount_cents stays the price. To show it before the order is made, the fee is the total times the percent, rounded half up to the cent (972 at 1.5% is 15, so 987). Either figure is taken as expected_total_amount_cents.

Wait for the payment#

While the payment screen is open, ask for the status (how often):

Shell
curl https://app.satsrail.com/api/v1/m/invoices/INVOICE_ID/status \
  -H "Authorization: Bearer $SATSRAIL_KEY"
JSON
{
  "object": "invoice_status",
  "id": "fb31556a-a2c0-406b-99ca-f65958711346",
  "order_id": "e8da24c6-dca4-4da7-8d29-aa6e1e174c05",
  "livemode": false,
  "status": "pending",
  "paid": false,
  "expired": false,
  "wallet_reachable": true,
  "paid_at": null,
  "expires_at": "2026-11-16T20:11:18.683Z",
  "amount_sats": 9720,
  "amount_paid_sats": null,
  "receipt_url": null
}

Once paid:

JSON
{
  "object": "invoice_status",
  "id": "fb31556a-a2c0-406b-99ca-f65958711346",
  "status": "paid",
  "paid": true,
  "wallet_reachable": true,
  "paid_at": "2026-11-16T19:11:19.167Z",
  "amount_paid_sats": 9720,
  "receipt_url": "https://www.satsrail.com/receipt/e8da24c6-dca4-4da7-8d29-aa6e1e174c05",
  "payment": {
    "id": "a937d3b9-be8b-4db6-bb56-7a3868bd3f7a",
    "amount_sats": 9720,
    "confirmed_at": "2026-11-16T19:11:19.167Z",
    "order": { "id": "e8da24c6-dca4-4da7-8d29-aa6e1e174c05", "status": "paid", "total_amount_cents": 972 }
  }
}

Only when paid is true, mark the sale paid and print the receipt, once: the same answer may come more than once. receipt_url is a permanent page you can print as a QR code or send.

An on-chain invoice's status also carries seen_at, confirmations and required_confirmations. A payment seen in time reads awaiting_confirmations: true until the chain has confirmed it that many times; then paid is true. Letting the customer go before then is the merchant's risk to take.

When the wallet can't be reached#

The status call answers 200 even when the wallet provider couldn't be asked. Then wallet_reachable is false and "paid": false means "not known yet", not "not paid". Keep asking, tell the cashier the payment can't be confirmed yet, and don't cancel or take another payment until an answer comes with wallet_reachable: true.

How often to ask#

Every 2 to 3 seconds: SatsRail asks the wallet at most once in 2 seconds per invoice, so asking faster learns nothing sooner. Status calls count toward a key's minute but not its hour, and on Free a key makes at most 12 a minute, so ask every 5 seconds there (Rate limits). A backend polling for many terminals with one key shares that minute: subscribe to the webhook below.

A webhook for a backend#

A backend can subscribe to payment.received and tell the terminal, rather than poll. Verify each delivery's signature and handle each event once: see Webhooks. Keep the status call for a terminal that reconnects.

When the invoice runs out#

Once expired is true, take the QR code down. If the customer wants to try again, ask for a new invoice for the same order:

Shell
curl -X POST https://app.satsrail.com/api/v1/m/invoices/generate \
  -H "Authorization: Bearer $SATSRAIL_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "order_id": "e8da24c6-dca4-4da7-8d29-aa6e1e174c05" }'

SatsRail first checks once more whether the old invoice was paid as it ran out, so a sale is never quoted twice. The answer is the invoice, with its order inside it (the reverse of POST /api/v1/m/orders, which answers the order with its invoice):

JSON
{
  "object": "invoice",
  "id": "7b79b800-a35a-402d-8a83-02a3d5be4139",
  "order_id": "e8da24c6-dca4-4da7-8d29-aa6e1e174c05",
  "status": "pending",
  "payment_request": "lntb9720n1test_43dd03fd5425fa241ef502...",
  "amount_sats": 9720,
  "expires_at": "2026-11-16T21:22:06.595Z",
  "expired": false,
  "order": { "id": "e8da24c6-dca4-4da7-8d29-aa6e1e174c05", "status": "invoice_generated", "total_amount_cents": 972, "...": "..." }
}
AnswerMeaningDo
201A new invoice, priced at the current rateShow it and poll its status
200The invoice the order already has: paid, or still pendingPaid: print the receipt. Pending: keep showing it.
503 service_unavailableThe wallet couldn't say whether the old one was paid; nothing new was madeWait Retry-After and ask again

With an Idempotency-Key, use a new one each time you ask. A cancelled or expired order takes no new invoice (422 not_invoiceable): ring the sale up again.

Cancel a sale, or take cash#

Shell
curl -X DELETE https://app.satsrail.com/api/v1/m/orders/ORDER_ID \
  -H "Authorization: Bearer $SATSRAIL_KEY"

An order with no invoice, or with a Lightning invoice still open, is cancelled: 204. Its invoice is cancelled with it and stops counting toward your plan's open invoices. A Lightning invoice can't be taken back from a wallet, so a customer who scanned it may still pay: that payment is recorded on the cancelled order and flagged for refund (the payment.flagged webhook), and you send the sats back from the portal. An order whose on-chain invoice can still be paid, or whose payment is confirming, is not cancelled:

JSON
{
  "error": {
    "code": "payment_in_progress",
    "message": "Order ORD-C815383054A988AA's bitcoin invoice can still be paid until 2026-11-16 20:11 UTC: wait for it to run out, or for its payment, then cancel",
    "status": 422,
    "details": { "expires_at": "2026-11-16T20:11:18.683Z" },
    "request_id": "2f8a5b06-6954-4916-96c3-4e3cb3e993d5"
  }
}

Keep the invoice's id. If it is paid before details.expires_at, its status says so: refund the customer in the portal (the API makes no refunds). After that time it can't be paid; leave the order or cancel it. A paid order answers 422 cannot_cancel.

Cash#

Cash isn't recorded through the API. An order marked paid in cash over the API took no money and went into no till, so cash is taken at the SatsRail POS, into the cashier's till, where it is counted when the till closes. Until the API refuses it, mark_as_paid and status: paid with tender_type: cash still work and answer with a Deprecation header.

Retries and recovery#

Send an Idempotency-Key (up to 255 characters) on POST /api/v1/m/orders, POST /api/v1/m/payment_requests and POST /api/v1/m/invoices/generate: one key per charge (sale-1042), the same key on every retry of it, and a new one (sale-1042-2) only when you change the request, as after price_changed. Retried with the same key and body:

  • Done already: the first answer again, with X-Idempotency-Replayed: true, for 24 hours. No second order.
  • Still running: 409 idempotency_in_progress. Wait a second and send it again.
  • The same key with another body, endpoint or API key, after a success: 422 idempotency_key_reused. A refused request isn't kept, so a new key after a 422 is a habit, not a rule. After a device signs in again, find the sale by its metadata (below) rather than retry with the old key's request.

If the invoice can't be made#

The wallet provider can fail. Then POST /api/v1/m/orders answers 502 provider_error or 503 service_unavailable, and names the order it made, still pending:

JSON
{
  "error": {
    "code": "provider_error",
    "message": "Payment provider is temporarily unavailable. Please try again.",
    "status": 502,
    "details": { "order_id": "e8da24c6-dca4-4da7-8d29-aa6e1e174c05" },
    "request_id": "9b0d6546-279b-458a-aad6-305b2776e8ec"
  }
}

Send the same request with the same key: within 24 hours it invoices that order and makes no second one. Without a key, invoice the named order yourself, as when an invoice runs out.

422 amount_exceeds_wallet_limits also names the order: the amount is more than any of the merchant's Lightning wallets takes in one payment, so take the sale another way and cancel the order.

Interruptions#

The app restarted or lost its connection
Load the saved invoice id and ask for its status. SatsRail watches the payment whether or not the terminal is there.
Making the order timed out
Send it again, as above. A network error doesn't mean the order wasn't made, nor that the customer didn't pay.
The order's id was lost
Find it by your own id in its metadata, below. Add expand=payment for the payment that paid it.
Shell
curl -g "https://app.satsrail.com/api/v1/m/orders?metadata[pos_sale_id]=1042" \
  -H "Authorization: Bearer $SATSRAIL_KEY"

Up to five metadata[key]=value pairs, all of which must match (curl needs -g for the brackets); 1042 finds both the text and the number. The answer is a list, newest first, each order with its invoice.

Test mode#

Sign the device in with "mode": "test", or use a test key from Settings → API Keys: everything above works the same, moves no money and answers "livemode": false. Pay a test invoice with POST /api/v1/m/invoices/:id/simulate_payment, or end it with …/simulate_expiry. A test invoice reaches no wallet, so wallet failures never happen in test mode: make one small live payment before the store opens. More in Testing.

Errors#

Every failure has the same shape:

JSON
{
  "error": {
    "code": "validation_error",
    "message": "Validation failed",
    "status": 422,
    "details": ["Total amount cents doesn't match the items less their discounts plus their taxes, 972"],
    "fields": {
      "total_amount_cents": ["doesn't match the items less their discounts plus their taxes, 972"]
    },
    "request_id": "0255aef3-4cf3-47ec-8762-4be3dc509486"
  }
}

Branch on code, never on message, whose words can change. details and fields appear when there is something to put in them; request_id is what to quote to support. The API reference lists each endpoint's codes; this table says what to do.

StatusCodeWhat to do
Any call
400invalid_json, bad_request, missing_params, invalid_idempotency_keyThe request couldn't be read, or lacks a required part. The message says which. A bug in your client.
401missing_token, invalid_token, token_expired, token_revokedNo working key. A device signs in again; a backend needs a new key from the merchant.
403forbidden, not_a_counter_orderThe key may not do this (when its security group refused, details names the missing resource and access), or the order came from another channel and is changed from the dashboard. Don't retry.
403merchant_not_operational, location_archived, live_key_requiredThe account isn't approved yet for a live key, or is suspended; the device's location was archived (sign in again); or a test key asked for what only a live key reads.
404not_foundNo such record for this key in its mode, or no such endpoint.
415unsupported_media_typeSend the body with Content-Type: application/json.
422unknown_parameter, invalid_argument, invalid_amount, validation_error, invalid_filterA field or value the call doesn't take. The message names it; fields maps each field to its messages.
429rate_limit_exceeded, daily_cap_exceeded, open_invoice_limit_reachedWait Retry-After seconds. For open_invoice_limit_reached, send the same request again then: it invoices the order it made.
Signing a device in
400authorization_pending, slow_downThe person hasn't approved the code yet. Ask again after interval seconds, a little later after slow_down.
400access_denied, expired_token, invalid_device_codeRefused, run out, already used, or not a code of ours. Start again with a new code.
401invalid_sessionThe session token ran out or has made its key. Start again.
403access_denied, no_security_group, device_sign_in_disabledThe person may not run a POS here, or the merchant turned device sign-in off. Send them to the owner.
403two_factor_setup_requiredA live key for someone above a cashier: they add a passkey, or use test mode.
413payload_too_largeA sign-in body is at most 4 KB.
422not_a_device_keyRenew and sign out take a device's key only.
429rate_limit_exceededAsked too often from one address. Show the wait in Retry-After.
Taking a payment
402, 403subscription_required, volume_limit_exceeded, aup_acceptance_required, verification_requiredThe merchant can't take a new payment right now. Reading and cancelling still work. Tell the cashier to call the owner.
422invalid_payment_method, location_mismatchA payment method the merchant can't take now, or a location other than the device's. No order was made.
422invalid_status_transition, already_paid, counter_sale, customer_order, reserved_metadataA change the order can't take: shipped before it is paid, paid twice, a sale rung up at SatsRail's own POS, a shopper's open order, or one of SatsRail's own metadata keys (refused as validation_error on a new order). The message says which.
503price_unavailableThe bitcoin price can't be read. Try again in a minute.

The codes of a sale are explained in their sections above; the API reference lists each endpoint's. A code you don't know: act on its HTTP status.

Rate limits#

Each secret key, a device's included, is held to its merchant's plan's limits: Free 20 requests a minute and 200 an hour, with at most 12 status calls a minute; Starter 100 and 1,000; Pro 300 and 3,000; Pro Plus and Enterprise 1,000 and 10,000. Status calls count toward the minute only. Requests with no valid key share 20 a minute per address, and sign-ins 10 a minute. Answers carry X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset, and the same with -Hour for the hour. Past a limit the answer is 429 rate_limit_exceeded with Retry-After in seconds: wait that long.

A merchant also has at most so many invoices waiting to be paid at once, live and test counted apart: Free 5, Starter 20, Pro 100, Pro Plus and Enterprise 500. Past it a sale's invoice answers 429 open_invoice_limit_reached with Retry-After; the order stays pending, named in error.details.order_id. An unpaid Lightning invoice runs out within 15 minutes, which frees its place.

What the API doesn't do#

No split payments (one payment pays an order), no refunds (made in the portal; an order shows how far it was refunded), no tills (cash recorded over the API goes into none), no loyalty or kitchen display, and no offline sales: every call needs a connection. SatsRail's own POS, a page of the merchant portal, does these.

Before you use it at the counter#

In test mode, try: a paid sale; an invoice that runs out and its new one; a sale cancelled while its invoice is open; an item that left the catalog; a price changed after the catalog was read; a retry with the same idempotency key; a terminal restarted mid-sale; a key renewed and one signed out. Then make one small live payment.

API reference Testing Webhooks