# SatsRail Developers > REST API reference and integration guides for SatsRail — non-custodial Bitcoin payment infrastructure, on-chain or Lightning. - The API is served from `https://app.satsrail.com`. Merchant endpoints are under `/api/v1/m/` and take a secret key (`sk_live_…`, or `sk_test_…` in test mode); public endpoints are under `/api/v1/pub/` and take a publishable key. - The hosted MCP server for AI agents is `https://satsrail.com/mcp`. - The OpenAPI spec is at https://www.satsrail.com/developers/data/satsrail-openapi.json. - Every page is also Markdown: at the page's URL plus `index.md`, or at the page's own URL when the request says `Accept: text/markdown`. - Every page in one file: https://www.satsrail.com/developers/llms-full.txt - For the product itself, see https://www.satsrail.com/llms.txt. # API reference > SatsRail REST API documentation. Non-custodial Bitcoin payment infrastructure, on-chain or Lightning. Source: https://www.satsrail.com/developers/ Generated from the OpenAPI 3.1.0 spec: https://www.satsrail.com/developers/data/satsrail-openapi.json Base URL: `https://app.satsrail.com` ## Overview Take bitcoin payments, over Lightning and on-chain, that go straight to the merchant's own wallet. SatsRail asks the wallet for an invoice, watches it, and tells you when it is paid. It never holds the money. **Base URL.** `https://app.satsrail.com`. Every path starts with `/api/v1`. **Authentication.** Send your key as `Authorization: Bearer `. - A secret key (`sk_live_…`, `sk_test_…`) calls the merchant API, `/api/v1/m/…`. Make one in Settings → API Keys and keep it on your server. Live keys work on every plan once the merchant's account is approved; test keys work before that too, while it is set up or reviewed. - A publishable key (`pk_live_…`, `pk_test_…`) calls the public API, `/api/v1/pub/…`, from a web page, and reads the catalog (`GET /api/v1/m/catalog`, `GET /api/v1/m/products`) as a shopper sees it. - A point of sale can sign a person in and get a key of its own: `POST /api/v1/m/sessions` for a code the person approves on satsrail.com/device, `POST /api/v1/m/sessions/token` until it is approved, then `POST /api/v1/m/sessions/activate`. No password is ever sent. See the POS guide. **Live and test.** A key's mode is the mode of everything it makes and reads. Test mode never reaches a wallet. To pay a test invoice, call `POST /api/v1/m/invoices/{id}/simulate_payment`. **Money.** Amounts named `…_cents` are whole numbers of the currency's smallest unit (2500 is $25.00 for a USD merchant). Amounts named `…_sats` are satoshis. **Errors.** Every failure answers the same shape, with the HTTP status that fits: ```json {"error": {"code": "validation_error", "message": "Validation failed", "status": 422, "details": ["Total amount cents must be greater than 0"], "fields": {"total_amount_cents": ["must be greater than 0"]}, "request_id": "5f0c…"}} ``` Read `code`: it doesn't change. `message` is for a person. `details` says more where there is more to say (each refused item, the figures of a `price_changed`, the order a failure left pending), and `fields` maps a `validation_error`'s messages to their fields. Quote `request_id` to support. A 409, a 429 and a 5xx are safe to send again with the same `Idempotency-Key`; any other 4xx answers the same until you change the request. **Retrying safely.** Send an `Idempotency-Key` header with every request that makes something (an order, a payment request, an invoice). The same key with the same request gets the first answer again for 24 hours (`X-Idempotency-Replayed: true`). The same key with another request answers 422 `idempotency_key_reused`. A request still running answers 409 `idempotency_in_progress`. **Lists.** `page` and `per_page` (25 by default, 100 at most); `meta` says where you are. Filter with `q[field_predicate]=value`, such as `q[status_eq]=paid` or `q[created_at_gteq]=2026-10-01`. A filter a list doesn't take answers 422 `invalid_filter`. **Rate limits.** Each key's limits are its merchant's plan's: Free 20 requests a minute and 200 an hour, Starter 100 and 1,000, Pro 300 and 3,000, Pro Plus and Enterprise 1,000 and 10,000 (`GET /api/v1/pub/subscription_plans` answers each plan's `rate_limits`). `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` count the minute; the same three ending `-Hour` count the hour. Asking whether an invoice was paid (`GET …/status`) doesn't count toward the hour; on Free a key asks it at most 12 times a minute. Past a limit: 429 `rate_limit_exceeded`, with `Retry-After`. **Open invoices.** A merchant 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 (each plan's `max_open_invoices`). A Lightning invoice is open 15 minutes at most. Past the limit a new invoice answers 429 `open_invoice_limit_reached` with `Retry-After`; an order the request made stays pending, named in `error.details.order_id`, and the same request sent again invoices it once one is paid, expires or is cancelled. ## Errors Errors share one shape. This is a `422`; each endpoint below lists its own codes: ```json { "error": { "code": "validation_error", "message": "Validation failed", "status": 422, "details": [ "Total amount cents must be greater than 0" ], "fields": { "total_amount_cents": [ "must be greater than 0" ] }, "request_id": "5f0c2a1e-7b1d-4c58-9d0e-2f6a3f0b9c11" } } ``` ## Endpoints Merchant API: - `POST /api/v1/m/sessions` — Start signing a person in on a POS - `DELETE /api/v1/m/sessions` — Sign this device out - `POST /api/v1/m/sessions/activate` — Get a key for this device - `POST /api/v1/m/sessions/renew` — Keep this device's key - `POST /api/v1/m/sessions/token` — Ask whether the person approved the code - `GET /api/v1/m/api_token` — Read the key you are calling with - `GET /api/v1/m/api_tokens/{id}/usage` — Read a key's usage - `GET /api/v1/m/merchant` — Read the merchant - `GET /api/v1/m/locations` — List locations - `GET /api/v1/m/locations/{id}` — Read a location - `GET /api/v1/m/catalog` — Read the whole catalog - `GET /api/v1/m/catalog/version` — Ask whether the catalog changed - `GET /api/v1/m/products` — List products - `POST /api/v1/m/products` — Create a product - `GET /api/v1/m/products/{id}` — Read a product - `PATCH /api/v1/m/products/{id}` — Change a product - `GET /api/v1/m/product_types` — List product types - `GET /api/v1/m/product_types/{id}` — Read a product type - `GET /api/v1/m/orders` — List orders - `POST /api/v1/m/orders` — Create an order - `GET /api/v1/m/orders/{id}` — Read an order - `PATCH /api/v1/m/orders/{id}` — Change an order - `DELETE /api/v1/m/orders/{id}` — Cancel an order - `POST /api/v1/m/invoices/generate` — Generate an invoice for an order - `GET /api/v1/m/invoices/{id}` — Read an invoice - `GET /api/v1/m/invoices/{id}/qr` — Get the invoice as a QR code - `POST /api/v1/m/invoices/{id}/simulate_expiry` — Make a test invoice run out - `POST /api/v1/m/invoices/{id}/simulate_payment` — Pay a test invoice - `GET /api/v1/m/invoices/{id}/status` — Ask whether an invoice was paid - `POST /api/v1/m/payment_requests` — Ask for a payment of an amount - `GET /api/v1/m/payment_requests/{id}` — Read a payment request - `GET /api/v1/m/payment_requests/{id}/status` — Ask whether a payment request was paid - `GET /api/v1/m/payments` — List payments - `GET /api/v1/m/payments/{id}` — Read a payment - `GET /api/v1/m/checkout_sessions` — List checkout sessions - `POST /api/v1/m/checkout_sessions` — Create a checkout session - `GET /api/v1/m/checkout_sessions/{id}` — Read a checkout session - `GET /api/v1/m/webhooks` — List webhook endpoints - `GET /api/v1/m/webhooks/{id}` — Read a webhook endpoint - `GET /api/v1/m/sales` — List sales - `GET /api/v1/m/sales/{id}` — Read a sale - `GET /api/v1/m/wallets` — List wallets - `GET /api/v1/m/wallets/{id}` — Read a wallet - `GET /api/v1/m/media_keys` — List media keys - `GET /api/v1/m/media_keys/{id}` — Read a media key - `GET /api/v1/m/media_keys/{id}/key` — Read a media key's secret - `POST /api/v1/m/access/verify` — Check a buyer's access token Public API: - `GET /api/v1/pub/orders/{id}` — Confirm a paid order - `POST /api/v1/pub/checkout_sessions` — Create a checkout session from a web page - `POST /api/v1/pub/access/verify` — Check a buyer's access token from a web page ## Merchant API ### POST /api/v1/m/sessions Sessions: Start signing a person in on a POS Step one of a device's sign-in, with no key and no password. Send a `device_name` if you like. The answer is a `device_code`, which the device keeps to itself, and a `user_code` to show the person with `verification_uri` (`https://satsrail.com/device`), or `verification_uri_complete` as a QR code. The person opens it on their phone or computer, signs in there as they always do, and approves the code, confirming it's them. Meanwhile ask `POST /api/v1/m/sessions/token` every `interval` seconds, for up to `expires_in` seconds (RFC 8628, the device authorization grant). Request body (`application/json`): - `device_name` (string): What the person sees on satsrail.com/device when they approve it ("Front counter iPad"). Optional. ```json { "device_name": "Front counter iPad" } ``` Responses: - `200` Success. - `400` The body couldn't be read: `invalid_json` for JSON that doesn't parse, `bad_request` for a body of the wrong shape. - `413` The body is too large. Codes: `payload_too_large`. - `415` The body is JSON, sent as something else. Codes: `unsupported_media_type`. - `422` The request can't be done as sent. Codes: `unknown_parameter`. - `429` Too many requests. Codes: `rate_limit_exceeded`. Example `200` response: ```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 } ``` ### DELETE /api/v1/m/sessions Sessions: Sign this device out Ends the device's key at once. Send the key as `Authorization: Bearer`. Answers 204. Only a key a device signed in for is ended here; any other key answers 422 `not_a_device_key` and is ended in Settings → API Keys. Responses: - `204` Done. No body. - `401` No key, or one that doesn't work. Codes: `invalid_token`. - `422` The request can't be done as sent. Codes: `not_a_device_key`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. ### POST /api/v1/m/sessions/activate Sessions: Get a key for this device Step three. Send the `session_token` and the chosen `merchant_id`, with `mode` (`live` or `test`) and a `device_name` if you like. The answer's `api_key` belongs to this device alone: send it as the Bearer key from now on. It reaches the endpoints a counter needs, at the person's location, within what their security group allows. It lasts 30 days (`expires_at`); renew it up to `renewable_until` with `POST /api/v1/m/sessions/renew`. A live key for someone above a cashier needs a passkey on their account (403 `two_factor_setup_required`); test keys never do. A refused call makes no key, so the token can be sent again. Request body (`application/json`): - `session_token` (string, required): From `POST /api/v1/m/sessions/token`. Good for 10 minutes, and for one key. - `merchant_id` (string, uuid, required): One of the `merchants` the sign-in answered. - `mode` (string), one of `live`, `test`: `test` for a key that sells in test mode: no money, on every plan. - `device_name` (string): What the merchant sees beside the key ("Front counter iPad"). "POS device" when left out. ```json { "session_token": "eyJfcmFpbHMiOnsiZGF0YSI6…", "merchant_id": "46525025-e63a-47d3-bc3b-1579896dd502", "mode": "test", "device_name": "Front counter iPad" } ``` Responses: - `200` Success. - `400` The request couldn't be read. Codes: `missing_params`. - `401` No key, or one that doesn't work. Codes: `invalid_session`. - `403` The key may not do this. Codes: `access_denied`, `no_security_group`, `merchant_not_operational`, `device_sign_in_disabled`, `two_factor_setup_required`. - `413` The body is too large. Codes: `payload_too_large`. - `415` The body is JSON, sent as something else. Codes: `unsupported_media_type`. - `422` The request can't be done as sent. Codes: `unknown_parameter`, `invalid_argument`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "api_key": "sk_test_YOUR_SECRET_KEY", "livemode": false, "expires_at": "2026-12-25T03:24:37.224Z", "renewable_until": "2027-02-23T03:24:37.259Z", "device_name": "Front counter iPad", "merchant": { "id": "46525025-e63a-47d3-bc3b-1579896dd502", "name": "Corner Coffee", "currency": "usd" }, "location": { "id": "778e189c-f0ef-4819-81a2-d622404773dc", "name": "Corner Coffee" } } ``` ### POST /api/v1/m/sessions/renew Sessions: Keep this device's key Moves the device key's end to 30 days from now, never past `renewable_until` (90 days after sign-in). Send the key as the Bearer key; no body. It is the same key, so retrying is harmless, and an ended key is not brought back. Call it once a day. When `expires_at` reaches `renewable_until`, sign the person in again before a shift. Only a device's key is renewed here (422 `not_a_device_key`). Responses: - `200` Success. - `401` No key, or one that doesn't work. Codes: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. Codes: `merchant_not_operational`. - `422` The request can't be done as sent. Codes: `not_a_device_key`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response (lists cut to their first item): ```json { "object": "api_token", "id": "98d1b220-78cc-427d-9312-66998d0a6be2", "name": "POS — ana@example.com", "token_type": "secret", "livemode": false, "security_group": { "id": "0ee6f8cc-8e23-4d11-82e9-f2e5346ea0da", "name": "admin", "admin": true }, "permissions": { "access": "manage", "api_request_logs": "manage", "api_tokens": "manage", "checkout_sessions": "manage", "costs": "manage", "customer_notes": "manage", "customers": "manage", "discounts": "manage", "employees": "manage", "integrations": "manage", "inventory": "manage", "invoices": "manage", "kitchen": "manage", "locations": "manage", "loyalty": "manage", "media_keys": "manage", "merchant_documents": "manage", "onchain_payments": "manage", "orders": "manage", "payment_gateways": "manage", "payment_requests": "manage", "payments": "manage", "pos": "manage", "product_types": "manage", "products": "manage", "quick_charges": "manage", "refund_requests": "manage", "refunds": "manage", "reports": "manage", "security_groups": "manage", "settings": "manage", "stock_counts": "manage", "taxes": "manage", "team": "manage", "timesheets": "manage", "users": "manage", "wallets": "manage", "webhooks": "manage" }, "endpoints": [ "api_tokens#current" ], "pos": true, "device_name": "Front counter iPad", "location": { "id": "778e189c-f0ef-4819-81a2-d622404773dc", "name": "Corner Coffee" }, "created_at": "2026-11-25T03:24:37.259Z", "expires_at": "2026-12-25T03:24:37.344Z", "renewable_until": "2027-02-23T03:24:37.259Z" } ``` ### POST /api/v1/m/sessions/token Sessions: Ask whether the person approved the code Step two. Send the `device_code` every `interval` seconds. Until the person approves the code, the answer is 400 `authorization_pending` (`slow_down` when asked sooner); refused on the portal it is `access_denied`, and `expired_token` once the code ran out or was used. Approved, it answers once with a `session_token` (10 minutes, one key) and the merchants where the person may run a POS. `live_available` says whether a live key works there; `live_needs_two_factor` says whether it waits on the person adding a passkey. Request body (`application/json`): - `device_code` (string, required): From `POST /api/v1/m/sessions`. Keep it on the device: it is never shown. ```json { "device_code": "Hn0p3Wq7…" } ``` Responses: - `200` Success. - `400` The request couldn't be read. Codes: `authorization_pending`, `slow_down`, `access_denied`, `expired_token`, `invalid_device_code`. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `413` The body is too large. Codes: `payload_too_large`. - `415` The body is JSON, sent as something else. Codes: `unsupported_media_type`. - `422` The request can't be done as sent. Codes: `unknown_parameter`. - `429` Too many requests. Codes: `rate_limit_exceeded`. Example `200` response: ```json { "session_token": "eyJfcmFpbHMiOnsiZGF0YSI6…", "expires_in": 600, "merchants": [ { "id": "46525025-e63a-47d3-bc3b-1579896dd502", "name": "Corner Coffee", "logo_url": null, "currency": "usd", "role": "owner", "live_available": true, "live_needs_two_factor": true } ] } ``` ### GET /api/v1/m/api_token Api token: Read the key you are calling with What the key may do. `permissions` lists each resource the key reads or manages. For a POS key, `endpoints` lists the calls it reaches, `location` is where it sells and `device_name` is the device. `expires_at` is when it ends. The key itself is never shown. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response (lists cut to their first item): ```json { "object": "api_token", "id": "98d1b220-78cc-427d-9312-66998d0a6be2", "…": "the whole api_token: see POST /api/v1/m/sessions/renew" } ``` ### GET /api/v1/m/api_tokens/{id}/usage Api token: Read a key's usage How many requests a key has made this month and its limit per minute. Path parameters: - `id` (string, required), e.g. `77af5931-75a5-4e02-88df-c55e3fe6ffce` Query parameters: - `{}` (null) Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "id": "77af5931-75a5-4e02-88df-c55e3fe6ffce", "name": "Test API Token", "token_type": "secret", "rpm_limit": 100, "monthly_request_count": 0, "last_request_counted_at": null, "last_used_at": null, "created_at": "2026-11-16T22:40:27.977Z" } ``` ### GET /api/v1/m/merchant Merchant: Read the merchant The merchant the key belongs to. Its name, currency, time zone, tip options and taxes. `wallets` is included for a key that reads wallets. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "merchant", "id": "46525025-e63a-47d3-bc3b-1579896dd502", "name": "Corner Coffee", "client_type": "erp", "email": "merchant1@example.com", "phone": "(555) 555-0100", "address": null, "city": null, "state": "CA", "postal_code": null, "status": "active", "time_zone": "UTC", "currency": "usd", "conversion_fee_percent": 0.0, "locale": "en", "created_at": "2026-11-25T03:24:36.294Z", "updated_at": "2026-11-25T03:24:36.936Z", "tip_options": [], "logo_url": null, "images": [], "taxes": [ { "id": "48d12b21-375f-4654-b0d3-fe213c974dcf", "name": "Sales tax", "rate": "8.0", "enabled": true } ], "livemode": false } ``` ### GET /api/v1/m/locations Locations: List locations Where the merchant sells. Every merchant has a main location. Query parameters: - `q` (object): Filters, as `q[field_predicate]=value`. Fields: `name`, `city`, `state`, `postal_code`, `is_main`, `archived_at`, `created_at`. Predicates: `_eq`, `_not_eq`, `_gteq`, `_lteq`, `_gt`, `_lt`, `_in`, `_cont`. A status takes its name (`q[status_eq]=paid`); a date alone is that day on the merchant's clock. A field or value the list can't read answers 422 `invalid_filter`., e.g. `{"name_eq" => "…"}` - `page` (integer): Which page. - `per_page` (integer): How many a page. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response (lists cut to their first item): ```json { "object": "list", "data": [ { "object": "location", "id": "13058779-3d91-40b6-9d6b-d8bcebff79d8", "name": "Merchant 17", "address_line_1": null, "address_line_2": null, "city": null, "state": "CA", "postal_code": null, "country": "AQ", "latitude": null, "longitude": null, "is_main": true, "archived_at": null, "images": [], "created_at": "2026-11-16T22:46:55.878Z", "updated_at": "2026-11-16T22:46:55.878Z" } ], "meta": { "current_page": 1, "per_page": 25, "total_count": 2, "total_pages": 1, "next_page": null, "prev_page": null } } ``` ### GET /api/v1/m/locations/{id} Locations: Read a location One location, with its address. Path parameters: - `id` (string, required), e.g. `f114c5a0-e724-4700-9c22-bdb85f628fce` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "location", "id": "f114c5a0-e724-4700-9c22-bdb85f628fce", "…": "the whole location: see GET /api/v1/m/locations" } ``` ### GET /api/v1/m/catalog Catalog: Read the whole catalog Everything a POS needs to sell, in one call: product types, their products, each product's SKUs with prices and whether they are sold out, taxes and discounts. A POS key gets the catalog of the location it sells at. Keep the `ETag` and send it back as `If-None-Match`: an unchanged catalog answers 304 with no body. `GET /api/v1/m/catalog/version` is the cheaper way to ask whether it changed. To sell an item, send its SKU's `id` as `sku_id` on an order. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "catalog", "merchant_id": "46525025-e63a-47d3-bc3b-1579896dd502", "location": { "id": "778e189c-f0ef-4819-81a2-d622404773dc", "name": "Corner Coffee", "time_zone": "Etc/UTC" }, "catalog_version": "2026-11-25T03:24:36.936612Z", "catalog_refresh_minutes": 30, "product_types": [ { "id": "45e77889-3cb2-4226-b870-d25054070962", "name": "Drinks", "position": 0, "color": "#EF4444", "images": [], "products": [ { "id": "prod_662969e0e954faca7c1e68b0", "product_id": "02354c22-f2c9-46eb-be54-a75c2f20cc1a", "name": "Latte", "description": null, "price_cents": 450, "currency": "usd", "sku": null, "formatted_price": "$4.50", "image_url": null, "image_medium_url": null, "images": [], "position": 0, "skus": [ { "id": "690fab45-c850-4ca7-8601-3e1c04abef46", "location_id": "778e189c-f0ef-4819-81a2-d622404773dc", "code": null, "barcode": null, "name": "Latte", "price_cents": 450, "default": true, "status": "active", "modifiers": [], "weight_grams": null, "length_mm": null, "width_mm": null, "height_mm": null, "images": [], "choice_name": "Regular", "line_name": "Latte", "sold_out": false, "held_for_pickup": 0 } ] } ], "tax_ids": [ "48d12b21-375f-4654-b0d3-fe213c974dcf" ] } ], "taxes": [ { "id": "48d12b21-375f-4654-b0d3-fe213c974dcf", "name": "Sales tax", "rate": "8.0", "enabled": true } ], "discounts": [], "livemode": true } ``` ### GET /api/v1/m/catalog/version Catalog: Ask whether the catalog changed Answers `catalog_version`, a timestamp that changes whenever the catalog does. Compare it with the one you hold and fetch the catalog again only when it differs. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "catalog_version": "2026-11-25T03:24:36.936612Z" } ``` ### GET /api/v1/m/products Products: List products The merchant's products, in the key's mode. Filter with `q[…]`. A publishable key, which anyone can copy from a web page, is listed what is on sale only, without `metadata`, `external_ref` or archived SKUs. Query parameters: - `q` (object): Filters, as `q[field_predicate]=value`. Fields: `name`, `status`, `sku`, `external_ref`, `created_at`, `updated_at`. Predicates: `_eq`, `_not_eq`, `_gteq`, `_lteq`, `_gt`, `_lt`, `_in`, `_cont`. A status takes its name (`q[status_eq]=paid`); a date alone is that day on the merchant's clock. A field or value the list can't read answers 422 `invalid_filter`., e.g. `{"name_eq" => "…"}` - `page` (integer): Which page. - `per_page` (integer): How many a page. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `422` The request can't be done as sent. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "list", "data": [], "meta": { "current_page": 1, "per_page": 25, "total_count": 0, "total_pages": 0, "next_page": null, "prev_page": null } } ``` ### POST /api/v1/m/products Products: Create a product Adds a product under a product type. A price sent with it sets the price of its default SKU. Request body (`application/json`): - `product` (object, required) - `product.name` (string, required) - `product.price_cents` (integer, required): Sets the price of the product's default SKU, in the subunits of the merchant's currency. A product has no price of its own: every price is a SKU's, and its other SKUs keep theirs. - `product.product_type_id` (string): Product type to file it under. Omit to use the merchant's Default type, created on first use. - `product.external_ref` (string) - `product.image_url` (string) ```json { "product": { "name": "B", "price_cents": 1, "product_type_id": "40735568-9007-471b-9213-44ea3a8fad61", "external_ref": "ch_fitness-series", "image_url": "https://example.com/image.jpg" } } ``` Responses: - `201` Created. - `400` The body couldn't be read: `invalid_json` for JSON that doesn't parse, `bad_request` for a body of the wrong shape. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `422` The request can't be done as sent. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `201` response: ```json { "object": "product", "livemode": true, "id": "e8227797-9ca0-4d85-a5dd-f0ad03d2a377", "name": "B", "description": null, "slug": "prod_b59c6bce1a95a1f94999c61d", "sku": null, "price_cents": 1, "currency": "usd", "status": "active", "position": 0, "image_url": null, "image_medium_url": null, "images": [], "access_duration_seconds": null, "track_stock": false, "lot_tracking": "none", "product_type_id": "253880f1-a730-4242-b022-8af04c343798", "merchant_id": "8c352b19-119f-4800-86d4-95184e4e33f6", "external_ref": null, "created_at": "2026-11-16T22:40:29.487Z", "updated_at": "2026-11-16T22:40:29.487Z", "formatted_price": "$0.01", "payment_link_url": "https://www.satsrail.com/pay/prod_b59c6bce1a95a1f94999c61d", "metadata": {}, "skus": [ { "id": "3a0028e6-6c95-4abb-8e6e-997c3793f76d", "location_id": "a95097f0-fe15-48a3-b2ab-d39dd60ad9b5", "code": null, "barcode": null, "name": "B", "price_cents": 1, "default": true, "status": "active", "modifiers": [], "weight_grams": null, "length_mm": null, "width_mm": null, "height_mm": null, "images": [] } ] } ``` ### GET /api/v1/m/products/{id} Products: Read a product One product, by its UUID or its slug. Path parameters: - `id` (string, required), e.g. `prod_26c9a8ab8eb367c7d4020355` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "product", "id": "8aaf900b-6c82-4a25-9633-63600a7321ae", "…": "the whole product: see POST /api/v1/m/products" } ``` ### PATCH /api/v1/m/products/{id} Products: Change a product Changes the fields you send and leaves the rest. A product's price and status are set when it is made and changed after only in the SatsRail portal or over MCP. Path parameters: - `id` (string, required), e.g. `prod_30872901976af5e46cc33fd3` Request body (`application/json`): - `product` (object, required) - `product.name` (string) - `product.status` (string) - `product.description` (string) ```json { "product": { "name": "Updated Name", "status": "archived", "description": "" } } ``` Responses: - `200` Success. - `400` The body couldn't be read: `invalid_json` for JSON that doesn't parse, `bad_request` for a body of the wrong shape. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `422` The request can't be done as sent: `validation_error` (with `details` and `fields`), `unknown_parameter`, `invalid_argument`, `invalid_amount`, `invalid_filter`, or a code of the endpoint's own. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "product", "id": "9710f334-1915-4afb-9931-2cdfa2997fec", "…": "the whole product: see POST /api/v1/m/products" } ``` ### GET /api/v1/m/product_types Product types: List product types The groups products are filed under, each with its taxes. Query parameters: - `q` (object): Filters, as `q[field_predicate]=value`. Fields: `name`, `external_ref`, `created_at`, `updated_at`. Predicates: `_eq`, `_not_eq`, `_gteq`, `_lteq`, `_gt`, `_lt`, `_in`, `_cont`. A status takes its name (`q[status_eq]=paid`); a date alone is that day on the merchant's clock. A field or value the list can't read answers 422 `invalid_filter`., e.g. `{"name_eq" => "…"}` - `page` (integer): Which page. - `per_page` (integer): How many a page. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "list", "data": [], "meta": { "current_page": 1, "per_page": 25, "total_count": 0, "total_pages": 0, "next_page": null, "prev_page": null } } ``` ### GET /api/v1/m/product_types/{id} Product types: Read a product type One product type, with the taxes its products are charged. Path parameters: - `id` (string, required), e.g. `4cfb2fbc-b2b1-4bb9-a680-10cdddef60f1` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "product_type", "id": "91f99a6c-597e-4515-8175-0b8186598c30", "name": "Category 331", "position": 0, "external_ref": null, "margin_percent": null, "images": [], "created_at": "2026-11-16T22:40:00.140Z", "updated_at": "2026-11-16T22:40:00.140Z" } ``` ### GET /api/v1/m/orders Orders: List orders The key's orders, newest first, each with its invoice. Filter with `q[…]`, find by your own id with `metadata[key]=value`, and add `expand=payment,merchant`. A POS key lists its own location's orders. A parameter the list doesn't take answers 422 `invalid_filter`. Query parameters: - `q` (object): Filters, as `q[field_predicate]=value`. Fields: `status`, `currency`, `order_number`, `total_amount_cents`, `location_id`, `created_at`, `updated_at`, `payments_payment_type`. Predicates: `_eq`, `_not_eq`, `_gteq`, `_lteq`, `_gt`, `_lt`, `_in`, `_cont`. A status takes its name (`q[status_eq]=paid`); a date alone is that day on the merchant's clock. A field or value the list can't read answers 422 `invalid_filter`., e.g. `{"status_eq" => "…"}` - `expand` (string): Adds each record's related records, comma-separated: `invoice`, `payment`, `merchant`. - `metadata` (object): Finds by your own metadata, as `metadata[key]=value` (up to five keys, exact values): `metadata[pos_sale_id]=1042`., e.g. `{"pos_sale_id" => "1042"}` - `page` (integer): Which page. - `per_page` (integer): How many a page. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `422` The request can't be done as sent. Codes: `invalid_filter`, `invalid_argument`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "list", "data": [ { "object": "order", "livemode": false, "id": "7c44f73c-4c3c-4467-b9c0-f493681b1518", "order_number": "ORD-5C6E99CC3B503CED", "total_amount_cents": 972, "tax_amount_cents": 72, "discount_amount_cents": 0, "total_amount_sats": 9720, "status": "paid", "merchant_id": "46525025-e63a-47d3-bc3b-1579896dd502", "location_id": "778e189c-f0ef-4819-81a2-d622404773dc", "price_list_id": null, "wallet_id": "246228f9-e146-4021-810e-28bc9137d332", "discount_id": null, "api_token_id": "98d1b220-78cc-427d-9312-66998d0a6be2", "created_at": "2026-11-25T03:24:37.603Z", "updated_at": "2026-11-25T03:24:37.958Z", "tender_type": "bitcoin", "cash_paid_at": null, "cash_recorded_by": null, "items": [ { "id": "b0b536ea-652d-41a4-8255-d5b6757a5668", "name": "Latte", "price_cents": 450, "qty": 2, "line_total_cents": 900, "product_id": "02354c22-f2c9-46eb-be54-a75c2f20cc1a", "sku_id": "690fab45-c850-4ca7-8601-3e1c04abef46", "tax_amount_cents": 72, "tax_details": [ { "name": "Sales tax", "rate": "8.0", "amount_cents": 72, "tax_id": "48d12b21-375f-4654-b0d3-fe213c974dcf" } ], "total_amount_sats": 9720, "margin_percent": "0.0", "margin_amount_sats": 0, "settlement_amount_sats": 9720, "refund_status": "not_refunded", "refunded_qty": 0, "refunded_cents": 0 } ], "currency": "usd", "customer_email": null, "customer_name": null, "customer_phone": null, "shipping_address": null, "notes": null, "metadata": { "pos_sale_id": "1042" }, "itemized": false, "subtotal_amount_cents": 900, "tax_details": [ { "name": "Sales tax", "rate": "8.0", "amount_cents": 72 } ], "payment_link_url": null, "payment_link_created_at": null, "expires_at": null, "payment_email_sent_at": null, "last_reminder_sent_at": null, "reminders": { "planned": 0, "sent": 0, "next_at": null }, "delivery_status": null, "pay_at_pickup_at": null, "pickup_location": null, "shipped_at": null, "delivered_at": null, "delivery_note": null, "receipt_url": "https://www.satsrail.com/receipt/7c44f73c-4c3c-4467-b9c0-f493681b1518", "po_number": "ORD-5C6E99CC3B503CED", "btc_fiat_price_at_creation": "100000.0", "btc_fiat_rate_source": "coinbase", "margin_percent": "0.0", "margin_amount_sats": 0, "settlement_amount_sats": 9720, "invoice": { "object": "invoice", "livemode": false, "id": "ec0b67ab-99ac-4d5f-a6b2-0c9972c60240", "payment_method": "lightning", "amount_sats": 9720, "status": "paid", "expires_at": "2026-11-25T04:24:37.889Z", "paid_at": "2026-11-25T03:24:37.943Z", "order_id": "7c44f73c-4c3c-4467-b9c0-f493681b1518", "created_at": "2026-11-25T03:24:37.895Z", "updated_at": "2026-11-25T03:24:37.944Z", "payment_request": "lntb9720n1test_1599c8f8b540152b6e134CS3SD35GvzVqiWViRITvx0e6llZzW0hMNLKsmzBAjfAZskeSP0", "payment_hash": "test_1599c8f8b540152b6e134522d1c3502d69fd9b13df95023e413812177b62", "expired": false, "time_until_expiry": 3599, "metadata": { "left_to_pay_cents": 972 } } } ], "meta": { "current_page": 1, "per_page": 25, "total_count": 1, "total_pages": 1, "next_page": null, "prev_page": null } } ``` ### POST /api/v1/m/orders Orders: Create an order Makes a sale: its items, its total and, with `generate_invoice: true`, the Lightning invoice that pays it. `invoice.payment_request` is the string to show as a QR code. Send `items` with `sku_id` and `qty` from the catalog, and SatsRail prices them with the catalog's taxes and discounts. Or send your own `total_amount_cents` and `tax_amount_cents`. Send `expected_total_amount_cents`, the total your screen showed, and the order is made only if it comes to that (otherwise 422 `price_changed`). Send an `Idempotency-Key`. If the invoice can't be made after the order was, the error names the order in `error.details.order_id`, and the same request with the same key invoices it rather than making another. A field the call doesn't take is refused by name. See the POS guide, *Ring up a sale*. Header parameters: - `Idempotency-Key` (string): Any string of yours, one for each thing you make. Sent again with the same request, it gets the first answer again for 24 hours, so a retry after a timeout never makes a second order. Request body (`application/json`): - `order` (object): Send `items` and let the server price them, or your own `total_amount_cents`. One of the two is required. - `order.items` (object[]): The lines. A line names a SKU (`sku_id`) or a product (`product_id`, sold as its default SKU) and is priced from the catalog; or it carries its own `name` and `price_cents`. - `order.items[].sku_id` (string, uuid): A SKU from the catalog. One that left it answers 422 `item_unavailable`. - `order.items[].product_id` (string): A product (its UUID, or the catalog's prod_… id), sold as its default SKU, when no `sku_id` is sent. - `order.items[].qty` (integer): How many. A whole number: 1.5 answers 422 `invalid_argument`. - `order.items[].name` (string): The line's name. Taken from the SKU when left out; required for a line with no SKU or product. - `order.items[].price_cents` (integer): The unit price, in the order's currency's smallest unit. Taken from the SKU when left out. A cashier's key is held to the merchant's limits on changing it. - `order.items[].tax_ids` (string[]): The taxes on this line. Left out, the line takes its product type's taxes; `[]` for none. - `order.items[].discount_ids` (string[]): The merchant's discounts on this line. Needs read access to discounts. - `order.total_amount_cents` (integer): Your own total, tax included. Leave it out with items and the server prices them from the catalog; send it, with `tax_amount_cents` and no `tax_ids` or `discount_ids` on the items, and the order charges exactly it. Alone, with no items, it is one amount. - `order.tax_amount_cents` (integer): The tax inside your own total. - `order.discount_amount_cents` (integer): An amount off the whole order. Not for a cashier's key. - `order.discount_id` (string, uuid): One of the merchant's discounts, on the whole order. - `order.currency` (string): ISO 4217, lowercase. The merchant's own when left out; another answers 422. - `order.tender_type` (string), one of `bitcoin`, `cash`, `card`: `cash` for an order paid in cash (`mark_as_paid`). `card` for one the customer pays by card on the hosted checkout, where the merchant takes cards: the answer's `checkout_url` is the page. Where it takes none, the order is a bitcoin one. - `order.customer_email` (string, email): Where the receipt goes once paid. In test mode the receipt goes to the key's holder instead. - `order.location_id` (string, uuid): Where it is sold. A device's key sells at its own location, and another answers 422 `location_mismatch`. - `order.price_list_id` (string, uuid): One of the merchant's price lists: its prices for the SKUs it names. - `order.wallet_id` (string, uuid): The wallet to be paid to. Left out, the merchant's wallets are tried in their order. - `order.metadata` (object): Your own keys and values (your sale's number, the table). Find the order again with `GET /api/v1/m/orders?metadata[key]=value`. - `generate_invoice` (boolean): Make the invoice in the same call. The answer carries it as `invoice`. - `mark_as_paid` (boolean): Leaving the API: cash is recorded at the SatsRail POS, into a till. Until then it records a cash order as paid now, answered with a `Deprecation` header; it needs `tender_type: cash` and a key that manages payments. - `expected_total_amount_cents` (integer): The total your screen showed the customer: the price (`total_amount_cents`), or the price with the merchant's bitcoin conversion fee (`amount_due_cents`). The order is made only if it comes to exactly one of them; otherwise 422 `price_changed`, with the figures in `error.details`, and nothing is made. Send it whenever the server prices the items: a price, a discount or a tax can change after you read the catalog. - `payment_method` (string), one of `lightning`, `onchain`, `nequi`: What the invoice is: `lightning` (the default), `onchain` (live mode), or `nequi` where the merchant takes it. One the merchant can't take answers 422 `invalid_payment_method` and no order is made. ```json { "order": { "items": [ { "sku_id": "690fab45-c850-4ca7-8601-3e1c04abef46", "qty": 2 } ], "metadata": { "pos_sale_id": "1042" } }, "expected_total_amount_cents": 972, "generate_invoice": true } ``` Responses: - `201` Created. - `400` The request couldn't be read. Codes: `invalid_json`, `bad_request`, `invalid_idempotency_key`. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `402` Payment is needed first. Codes: `subscription_required`. - `403` The key may not do this. Codes: `forbidden`, `merchant_not_operational`, `location_archived`, `volume_limit_exceeded`, `aup_acceptance_required`, `verification_required`. - `409` A conflict with what is there now. Codes: `idempotency_in_progress`. - `415` The body is JSON, sent as something else. Codes: `unsupported_media_type`. - `422` The request can't be done as sent. Codes: `unknown_parameter`, `invalid_argument`, `invalid_amount`, `item_unavailable`, `price_changed`, `invalid_payment_method`, `amount_exceeds_wallet_limits`, `location_mismatch`, `validation_error`, `tax_exempt_not_allowed`, `discount_over_limit`, `price_raise_over_limit`, `open_item_over_limit`, `open_items_off`, `open_item_not_allowed`, `idempotency_key_reused`. - `429` Too many requests. Codes: `rate_limit_exceeded`, `daily_cap_exceeded`, `open_invoice_limit_reached`. - `502` The wallet provider couldn't be reached. Codes: `provider_error`. - `503` Not available right now. Codes: `service_unavailable`, `price_unavailable`. Example `201` response: ```json { "object": "order", "id": "7c44f73c-4c3c-4467-b9c0-f493681b1518", "…": "the whole order: see GET /api/v1/m/orders" } ``` ### GET /api/v1/m/orders/{id} Orders: Read an order One order, with its items, its status, and its merchant, invoice and payment. A paid order carries `receipt_url`, the customer's receipt. `expand=invoice` narrows the answer to the related records you name. Path parameters: - `id` (string, required), e.g. `a3c7418e-2611-4669-9236-35a3e9c65a09` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "order", "id": "7c44f73c-4c3c-4467-b9c0-f493681b1518", "…": "the whole order: see GET /api/v1/m/orders" } ``` ### PATCH /api/v1/m/orders/{id} Orders: Change an order Changes an order that has no invoice yet, such as an open ticket. New `items` replace the old ones and are priced from the catalog again; read the new total from the answer. `metadata` replaces the old whole. Once invoiced, only `metadata` can change (422 `not_editable`). `status` takes `shipped`; `paid` with `tender_type` `cash` is leaving the API (cash is recorded at the SatsRail POS). To cancel, use DELETE. A POS key changes only orders a POS rang up (403 `not_a_counter_order`). Path parameters: - `id` (string, required), e.g. `ac72cead-6ba1-4e10-926e-6853c906e6f9` Request body (`application/json`): - `order` (object, required): What changes. A pending order with no invoice takes every field below; once invoiced, only `metadata`, and `status` (`paid` in cash, `shipped`). `metadata` replaces what was there: send every key you keep. - `order.status` (string), one of `paid`, `shipped`: `shipped` marks a paid order handed over. `paid` with `tender_type: cash` is leaving the API, as `mark_as_paid` is: cash is recorded at the SatsRail POS. To cancel, `DELETE /api/v1/m/orders/{id}`. - `order.items` (object[]): The lines, as on `POST /api/v1/m/orders`. They replace the order's lines. - `order.total_amount_cents` (integer) - `order.tax_amount_cents` (integer) - `order.discount_amount_cents` (integer) - `order.discount_id` (string, uuid) - `order.currency` (string) - `order.tender_type` (string), one of `bitcoin`, `cash`, `card` - `order.customer_email` (string, email) - `order.location_id` (string, uuid) - `order.price_list_id` (string, uuid) - `order.wallet_id` (string, uuid) - `order.metadata` (object): Replaces the order's metadata whole. ```json { "order": { "items": [ { "sku_id": "690fab45-c850-4ca7-8601-3e1c04abef46", "qty": 3 } ], "metadata": { "pos_sale_id": "1044", "table": "7" } } } ``` Responses: - `200` Success. - `400` The request couldn't be read. Codes: `invalid_json`, `bad_request`. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `402` Payment is needed first. Codes: `subscription_required`. - `403` The key may not do this. Codes: `forbidden`, `not_a_counter_order`, `merchant_not_operational`, `location_archived`, `volume_limit_exceeded`, `aup_acceptance_required`, `verification_required`. - `404` No such record for this merchant in the key's mode: `not_found`. - `415` The body is JSON, sent as something else. Codes: `unsupported_media_type`. - `422` The request can't be done as sent. Codes: `unknown_parameter`, `invalid_argument`, `invalid_amount`, `not_editable`, `item_unavailable`, `location_mismatch`, `validation_error`, `tax_exempt_not_allowed`, `invalid_status_transition`, `already_paid`, `payment_in_progress`, `counter_sale`, `customer_order`, `discount_over_limit`, `price_raise_over_limit`, `open_item_over_limit`, `open_items_off`, `open_item_not_allowed`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. - `503` Not available right now. Codes: `price_unavailable`. Example `200` response: ```json { "object": "order", "id": "04ddb01d-838e-412b-9291-8a86eab923ee", "…": "the whole order: see GET /api/v1/m/orders" } ``` ### DELETE /api/v1/m/orders/{id} Orders: Cancel an order Cancels an unpaid order: 204. An open Lightning invoice is cancelled with it and stops counting toward your plan's open invoices at once. A Lightning invoice can't be taken back from the customer's wallet: a payment still made to it is recorded on the cancelled order and flagged for refund (`payment.flagged`). While an on-chain invoice can still be paid, or a payment to it is confirming, the answer is 422 `payment_in_progress`, with `error.details.expires_at`: after that time the invoice can't be paid, and the order can be cancelled or left as it is. A paid order answers 422 `cannot_cancel`. A POS key cancels only orders a POS rang up (403 `not_a_counter_order`). Path parameters: - `id` (string, required), e.g. `26a5cd25-2063-4768-bace-9f7d92b230ba` Responses: - `204` Done. No body. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. Codes: `forbidden`, `not_a_counter_order`. - `404` No such record for this merchant in the key's mode: `not_found`. - `422` The request can't be done as sent. Codes: `payment_in_progress`, `cannot_cancel`, `counter_sale`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. ### POST /api/v1/m/invoices/generate Invoices: Generate an invoice for an order Invoices `order_id`: an order made without an invoice, or one whose invoice ran out. `201` is a new invoice, at the current rate; `200` is the one the order already has, still payable or paid as it ran out, so nothing is quoted twice. Send `expected_total_amount_cents` to invoice only if the order still comes to that. If the wallet can't say whether the old invoice was paid, 503 `service_unavailable` with `Retry-After`, and nothing is made. A cancelled or expired order answers 422 `not_invoiceable`. Header parameters: - `Idempotency-Key` (string): Any string of yours, one for each thing you make. Sent again with the same request, it gets the first answer again for 24 hours, so a retry after a timeout never makes a second order. Request body (`application/json`): - `order_id` (string, uuid, required): The order to invoice. - `expected_total_amount_cents` (integer): The total your screen shows for the order. The invoice is made only if the order comes to exactly that; otherwise 422 `price_changed` with both figures, and no invoice. For an order changed since you last read it (an open ticket). - `payment_method` (string), one of `lightning`, `onchain`: `lightning` when left out, or the merchant's default. ```json { "order_id": "7c44f73c-4c3c-4467-b9c0-f493681b1518" } ``` Responses: - `200` Success. - `201` Created. - `400` The request couldn't be read. Codes: `missing_params`, `invalid_json`. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `404` No such record. - `409` The same `Idempotency-Key` is still being answered (`idempotency_in_progress`): wait a moment and send it again. - `415` The body is JSON, sent as something else. Codes: `unsupported_media_type`. - `422` The request can't be done as sent. Codes: `not_invoiceable`, `price_changed`, `invalid_payment_method`, `amount_exceeds_wallet_limits`, `invalid_argument`, `counter_sale`, `customer_order`, `idempotency_key_reused`. - `429` Too many requests. Codes: `open_invoice_limit_reached`, `rate_limit_exceeded`. - `502` The wallet provider couldn't be reached. Codes: `provider_error`. - `503` Not available right now. Codes: `service_unavailable`. Example `200` response: ```json { "object": "invoice", "id": "0eb8ab4a-9d5a-47ca-b6d7-33142ebc9d71", "…": "the whole invoice: see GET /api/v1/m/orders" } ``` ### GET /api/v1/m/invoices/{id} Invoices: Read an invoice The invoice, with `payment_request` (a BOLT11 string for Lightning, a `bitcoin:` URI for on-chain), its amount in sats and when it expires. Path parameters: - `id` (string, required), e.g. `0e6c9922-eee1-49a4-9333-81122ccdb7f9` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "invoice", "id": "3ae8afdb-00c6-48c4-8dcb-7d63f9f13fbb", "…": "the whole invoice: see GET /api/v1/m/orders" } ``` ### GET /api/v1/m/invoices/{id}/qr Invoices: Get the invoice as a QR code An SVG image of the invoice's `payment_request`. It needs the Authorization header, so a web page fetches it and can't use it as an image address. You can also draw the QR code yourself from `payment_request`. Path parameters: - `id` (string, required), e.g. `0785852c-3673-4507-94d7-452ad32a86d4` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. A `200` response is `image/svg+xml`. ### POST /api/v1/m/invoices/{id}/simulate_expiry Invoices: Make a test invoice run out Test mode only. The test invoice expires now, as one does when the customer takes too long, so you can try what comes next: ask its status once more, then `POST /api/v1/m/invoices/generate` for a new one. Answers what `GET …/status` answers. A live invoice answers 403 `test_mode_only`. Path parameters: - `id` (string, required), e.g. `c3f974a7-0510-4bd2-9ed3-c938cc5f8cad` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. Codes: `test_mode_only`, `forbidden`. - `404` No such record for this merchant in the key's mode: `not_found`. - `422` The request can't be done as sent: `validation_error` (with `details` and `fields`), `unknown_parameter`, `invalid_argument`, `invalid_amount`, `invalid_filter`, or a code of the endpoint's own. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "invoice_status", "id": "3ae8afdb-00c6-48c4-8dcb-7d63f9f13fbb", "order_id": "7c44f73c-4c3c-4467-b9c0-f493681b1518", "livemode": false, "status": "expired", "paid": false, "expired": true, "wallet_reachable": true, "paid_at": null, "expires_at": "2026-11-25T03:24:37.810Z", "payment_method": "lightning", "amount_sats": 9720, "amount_paid_sats": null, "receipt_url": null } ``` ### POST /api/v1/m/invoices/{id}/simulate_payment Invoices: Pay a test invoice Test mode only. Marks a test invoice paid exactly as a real payment would: the order is paid, a payment is recorded, `payment.received` goes to your test webhooks and the receipt exists. Answers what `GET …/status` answers. A live invoice answers 403 `test_mode_only`; one that expired answers 422 `invoice_not_payable`. Path parameters: - `id` (string, required), e.g. `94c2c462-0598-4e90-85f7-438b4b0e31be` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. Codes: `test_mode_only`, `forbidden`. - `404` No such record for this merchant in the key's mode: `not_found`. - `422` The request can't be done as sent. Codes: `invoice_not_payable`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "invoice_status", "id": "ec0b67ab-99ac-4d5f-a6b2-0c9972c60240", "…": "the whole invoice_status: see POST /api/v1/m/invoices/{id}/simulate_expiry" } ``` ### GET /api/v1/m/invoices/{id}/status Invoices: Ask whether an invoice was paid Asks the wallet now. `paid: true` means the money arrived: only then deliver. A paid answer includes the `payment` and `receipt_url`. `expired: true` means it ran out; ask for the next with `POST /api/v1/m/invoices/generate`. Ask every 2 to 3 seconds while the payment screen is open, every 5 on Free, whose keys ask at most 12 times a minute. These calls don't count toward the hourly rate limit. It answers 200 even when the wallet couldn't be asked: then `wallet_reachable` is `false` and `paid: false` means "not known yet". Keep asking. Path parameters: - `id` (string, required), e.g. `6c629209-0df9-417a-8778-78359445b4d2` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response, paid: ```json { "object": "invoice_status", "id": "ec0b67ab-99ac-4d5f-a6b2-0c9972c60240", "…": "the whole invoice_status: see POST /api/v1/m/invoices/{id}/simulate_expiry" } ``` Example `200` response, waiting: ```json { "object": "invoice_status", "id": "3ae8afdb-00c6-48c4-8dcb-7d63f9f13fbb", "…": "the whole invoice_status: see POST /api/v1/m/invoices/{id}/simulate_expiry" } ``` ### POST /api/v1/m/payment_requests Payment requests: Ask for a payment of an amount The shortest way to be paid, for a POS that keeps its own cart: send `amount_cents` in the merchant's currency and get an invoice back. SatsRail makes the order behind it, with one line. An amount of your own: a key charges catalog prices unless the merchant lets it charge custom amounts (Settings → API keys). A POS key's payment request is an open item, as the store's rule for open items allows. `id` is the invoice's id, for `GET /api/v1/m/invoices/{id}/status`; `order_id` is the order. Send an `Idempotency-Key`: a provider's failure names the order in `error.details.order_id`, and the same request invoices it. Header parameters: - `Idempotency-Key` (string): Any string of yours, one for each thing you make. Sent again with the same request, it gets the first answer again for 24 hours, so a retry after a timeout never makes a second order. Request body (`application/json`): - `payment_request` (object) - `payment_request.amount_cents` (integer, required): What to charge, in the merchant's currency's smallest unit. There is no `currency`: it is the merchant's (`GET /api/v1/m/merchant`). - `payment_request.payment_method` (string), one of `lightning`, `onchain`: `lightning` when left out. One the merchant can't take (on-chain in test mode, on-chain with no on-chain wallet) answers 422 `invalid_payment_method` and nothing is made. - `payment_request.confirmations` (integer): On-chain only: how many confirmations before it counts as paid. The wallet's own when left out. - `payment_request.description` (string): The line's name on the order and the receipt. - `payment_request.customer_email` (string, email): Where the receipt goes once paid. - `payment_request.metadata` (object): Your own keys and values, kept on the order and sent in webhooks. ```json { "payment_request": { "amount_cents": 2500, "payment_method": "lightning", "description": "Sale 1043", "metadata": { "pos_sale_id": "1043" } } } ``` Responses: - `201` Created. - `400` The request couldn't be read. Codes: `invalid_json`, `bad_request`, `invalid_idempotency_key`. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `402` Payment is needed first. Codes: `subscription_required`. - `403` The key may not do this. Codes: `forbidden`, `merchant_not_operational`, `location_archived`, `volume_limit_exceeded`, `aup_acceptance_required`, `verification_required`. - `409` A conflict with what is there now. Codes: `idempotency_in_progress`. - `415` The body is JSON, sent as something else. Codes: `unsupported_media_type`. - `422` The request can't be done as sent. Codes: `unknown_parameter`, `validation_error`, `invalid_argument`, `invalid_amount`, `invalid_payment_method`, `amount_exceeds_wallet_limits`, `open_item_over_limit`, `open_items_off`, `open_item_not_allowed`, `idempotency_key_reused`. - `429` Too many requests. Codes: `open_invoice_limit_reached`, `rate_limit_exceeded`, `daily_cap_exceeded`. - `502` The wallet provider couldn't be reached. Codes: `provider_error`. - `503` Not available right now. Codes: `service_unavailable`, `price_unavailable`. Example `201` response: ```json { "object": "payment_request", "id": "93ffa20b-f5d8-4408-9bbc-0a46adff730c", "order_id": "d832c0a2-30a1-4353-a7ca-ce55f7821d6b", "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-25T03:24:38.351Z", "expires_at": "2026-11-25T04:24:38.346Z", "payment_request": "lntb25000n1test_7de963f7a70a4bd5b41b2ukC27ITRmO3R0r3AzUnUQrHDjfgOYfe31MhqofaXt3GGglhwzn", "payment_hash": "test_7de963f7a70a4bd5b41b202143f3b83f793cd4987ac0d4bdc542f7b1b18c" } ``` ### GET /api/v1/m/payment_requests/{id} Payment requests: Read a payment request The payment request, with the invoice's string, its amount and its status. Path parameters: - `id` (string, required), e.g. `bb929bab-24f9-451f-86f1-8f531df7a023` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "payment_request", "id": "bb929bab-24f9-451f-86f1-8f531df7a023", "…": "the whole payment_request: see POST /api/v1/m/payment_requests" } ``` ### GET /api/v1/m/payment_requests/{id}/status Payment requests: Ask whether a payment request was paid The same question as `GET /api/v1/m/invoices/{id}/status`, with the same id and the same answer: it asks the wallet now, and `paid: true` means the money arrived. Path parameters: - `id` (string, required), e.g. `6c16ad44-67f6-496f-a70e-3dadd5118761` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "invoice_status", "id": "93ffa20b-f5d8-4408-9bbc-0a46adff730c", "…": "the whole invoice_status: see POST /api/v1/m/invoices/{id}/simulate_expiry" } ``` ### GET /api/v1/m/payments Payments: List payments Money that arrived, newest first, in the key's mode. Query parameters: - `order_id` (string), e.g. `x` - `q` (object): Filters, as `q[field_predicate]=value`. Fields: `order_id`, `amount_sats`, `currency`, `confirmed_at`, `created_at`. Predicates: `_eq`, `_not_eq`, `_gteq`, `_lteq`, `_gt`, `_lt`, `_in`, `_cont`. A status takes its name (`q[status_eq]=paid`); a date alone is that day on the merchant's clock. A field or value the list can't read answers 422 `invalid_filter`., e.g. `{"order_id_eq" => "…"}` - `page` (integer): Which page. - `per_page` (integer): How many a page. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `422` The request can't be done as sent. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "list", "data": [ { "object": "payment", "livemode": false, "id": "87077927-973e-4ace-8d48-4af38e777043", "amount_sats": 9720, "preimage": "3c84016bfd787a4017128f4fc548fbb8c5ca768bac91d31dd479276c6a44eac8", "confirmed_at": "2026-11-25T03:24:37.943Z", "order_id": "7c44f73c-4c3c-4467-b9c0-f493681b1518", "invoice_id": "ec0b67ab-99ac-4d5f-a6b2-0c9972c60240", "created_at": "2026-11-25T03:24:38.007Z", "updated_at": "2026-11-25T03:24:38.007Z", "currency": "usd", "metadata": {}, "payment_hash": "test_1599c8f8b540152b6e134522d1c3502d69fd9b13df95023e413812177b62", "settled_at": "2026-11-25T03:24:37.943Z", "usd_value_at_payment": "9.72", "usd_variance_cents": 0, "variance_percentage": "0.0", "btc_fiat_price_at_payment": "100000.0", "fiat_value_at_payment": "9.72", "fiat_variance_cents": 0, "confirmations": 0, "required_confirmations": 1, "flagged_for_review": false, "flag": null, "order": { "object": "order", "id": "7c44f73c-4c3c-4467-b9c0-f493681b1518", "…": "the whole order: see GET /api/v1/m/orders" }, "invoice": { "object": "invoice", "id": "ec0b67ab-99ac-4d5f-a6b2-0c9972c60240", "…": "the whole invoice: see GET /api/v1/m/orders" } } ], "meta": { "current_page": 1, "per_page": 25, "total_count": 1, "total_pages": 1, "next_page": null, "prev_page": null } } ``` ### GET /api/v1/m/payments/{id} Payments: Read a payment One payment, with its amount and when it was confirmed. Path parameters: - `id` (string, required), e.g. `b84d3a9b-3f91-4fa2-9271-bc6dfc6c8b89` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "payment", "id": "b84d3a9b-3f91-4fa2-9271-bc6dfc6c8b89", "…": "the whole payment: see GET /api/v1/m/payments" } ``` ### GET /api/v1/m/checkout_sessions Checkout sessions: List checkout sessions The hosted checkout pages the merchant opened, in the key's mode. Query parameters: - `q` (object): Filters, as `q[field_predicate]=value`. Fields: `status`, `created_at`, `updated_at`. Predicates: `_eq`, `_not_eq`, `_gteq`, `_lteq`, `_gt`, `_lt`, `_in`, `_cont`. A status takes its name (`q[status_eq]=paid`); a date alone is that day on the merchant's clock. A field or value the list can't read answers 422 `invalid_filter`., e.g. `{"status_eq" => "…"}` - `page` (integer): Which page. - `per_page` (integer): How many a page. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "list", "data": [], "meta": { "current_page": 1, "per_page": 25, "total_count": 0, "total_pages": 0, "next_page": null, "prev_page": null } } ``` ### POST /api/v1/m/checkout_sessions Checkout sessions: Create a checkout session Opens a hosted page where the customer pays. Send a `product_id` whose price SatsRail sets, or an `amount_cents` with a key the merchant lets charge custom amounts (Settings → API keys). Send the customer to `checkout_url`. A session is in the key's mode. Request body (`application/json`): - `checkout_session` (object, required): `amount_cents` or `product_id`: one of the two. - `checkout_session.amount_cents` (integer): What to charge, when no product is named. - `checkout_session.currency` (string): ISO 4217, lowercase. The merchant's own when left out. - `checkout_session.product_id` (string): A product's id or slug: its price, its name and its taxes. - `checkout_session.customer_email` (string, email) - `checkout_session.customer_name` (string) - `checkout_session.customer_phone` (string) - `checkout_session.customer_address` (object) - `checkout_session.metadata` (object) ```json { "checkout_session": { "amount_cents": 100, "currency": "usd", "product_id": "prod_9b46570fa8a647620df9c0b2", "customer_email": "buyer@example.com", "customer_name": "Alice Smith", "customer_phone": "+1-555-1234", "customer_address": "123 Main St", "metadata": { "order_ref": "MY-123", "source": "stream" } } } ``` Responses: - `201` Created. - `400` The body couldn't be read: `invalid_json` for JSON that doesn't parse, `bad_request` for a body of the wrong shape. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `404` No such record. - `422` The request can't be done as sent. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `201` response: ```json { "object": "checkout_session", "livemode": true, "id": "794e21bd-d97f-48a4-979e-3467528d962e", "token": "cs_pJngEYnjBipWvT2pKJZxzTuZnJfsjqPaOJKWC0QzpdQ", "checkout_url": "https://www.satsrail.com/checkout/cs_pJngEYnjBipWvT2pKJZxzTuZnJfsjqPaOJKWC0QzpdQ", "expires_at": "2026-11-16T23:00:52Z", "amount_cents": 100, "tax_amount_cents": 0, "tax_details": [], "currency": "usd", "customer_email": null, "customer_name": null, "customer_phone": null, "customer_address": null, "checkout_mode": "iframe", "checkout_theme": "light", "checkout_accent_color": "#e8b53c", "metadata": { "order_ref": "MY-123", "source": "stream" }, "status": "pending" } ``` ### GET /api/v1/m/checkout_sessions/{id} Checkout sessions: Read a checkout session One session and its status. `order_id` and `invoice_id` are set once the customer reaches the payment step. Path parameters: - `id` (string, required), e.g. `0c3d34d8-a8f2-4ec6-b912-d98a3a912fc3` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "data": { "object": "checkout_session", "id": "0c3d34d8-a8f2-4ec6-b912-d98a3a912fc3", "…": "the whole checkout_session: see POST /api/v1/m/checkout_sessions" } } ``` ### GET /api/v1/m/webhooks Webhooks: List webhook endpoints Lists your webhook endpoints and every event one can subscribe to (available_events). Query parameters: - `q` (object): Filters, as `q[field_predicate]=value`. Fields: `active`, `url`, `created_at`. Predicates: `_eq`, `_not_eq`, `_gteq`, `_lteq`, `_gt`, `_lt`, `_in`, `_cont`. A status takes its name (`q[status_eq]=paid`); a date alone is that day on the merchant's clock. A field or value the list can't read answers 422 `invalid_filter`., e.g. `{"active_eq" => "…"}` - `page` (integer): Which page. - `per_page` (integer): How many a page. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `422` The request can't be done as sent. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response (lists cut to their first item): ```json { "object": "list", "data": [ { "object": "webhook", "livemode": true, "id": "bf26968c-97ac-4e55-999f-a7978dc9eb46", "url": "https://example.com/webhooks", "description": "Test Webhook", "events": [ "order.created" ], "active": true, "disabled_at": null, "success_count": 0, "failure_count": 0, "last_triggered_at": null, "created_at": "2026-11-16T22:41:01.998Z", "updated_at": "2026-11-16T22:41:01.998Z", "health_percentage": 100, "metadata": {} } ], "meta": { "current_page": 1, "per_page": 25, "total_count": 1, "total_pages": 1, "next_page": null, "prev_page": null }, "available_events": [ "order.created" ] } ``` ### GET /api/v1/m/webhooks/{id} Webhooks: Read a webhook endpoint One endpoint, with its events and delivery counts. Path parameters: - `id` (string, required), e.g. `bf0f2d80-57ae-440b-a151-b0527ca1b950` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response (lists cut to their first item): ```json { "object": "webhook", "id": "fa0a763e-520b-4324-b7e5-81ce7c0ff92b", "…": "the whole webhook: see GET /api/v1/m/webhooks" } ``` ### GET /api/v1/m/sales Sales: List sales The sales ledger: one sale per paid order, newest sold_at first. A sale is written when its order is paid and kept after the order itself is deleted, so its id is the order's id. Read with a secret key whose security group reads reports; a test key lists test sales. Query parameters: - `page` (integer): Which page. - `per_page` (integer): How many a page. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "list", "data": [ { "object": "sale", "kind": "sale", "livemode": true, "id": "86b752b0-2c75-44a5-9b1f-541d27023e7d", "order_id": "86b752b0-2c75-44a5-9b1f-541d27023e7d", "original_sale_id": null, "order_number": "ORD-1794868817-603", "merchant_id": "4055f693-88fe-4aba-859a-2d4172185393", "location_id": "2bce2788-6350-41ee-a64f-fe06e668bdb2", "status": "paid", "current_status": "paid", "source": "api", "currency": "usd", "ordered_at": "2026-11-16T22:40:17.015Z", "sold_at": "2026-11-16T22:40:17.042Z", "subtotal_cents": 10000, "discount_cents": 0, "discount_id": null, "discount_name": null, "tax_cents": 0, "tax_details": [], "conversion_fee_percent": "0.0", "conversion_fee_cents": 0, "total_cents": 10000, "amount_due_cents": 10000, "refunded_cents": 0, "payment_method": "lightning", "custom_method_name": null, "payment_id": "abe7a6c1-c1dc-41eb-af97-89c7e33bf299", "amount_sats": 123456, "btc_price_at_order": "100000.0", "btc_price_at_payment": "100000.0", "btc_usd_price_at_payment": "100000.0", "fiat_value_at_payment": "123.46", "usd_value_at_payment": "123.46", "fiat_variance_cents": 2346, "usd_variance_cents": 2346, "variance_percentage": "23.46", "payment_hash": "97fbc35c56c03c99bc39ba8a6c041b495a0a30c3beb1f8a7102d0f2f59904ac1", "preimage": "preimage_5cac37f7e9c6d4151f67473b143f1aad_179", "wallet_id": "0ef8b61f-5705-44fa-8aaf-3675704bdd78", "wallet_name": "Wallet 1726", "api_token_id": null, "customer_id": null, "customer_name": null, "customer_email": "ada@example.com", "delivery_status": null, "shipped_at": null, "delivered_at": null, "margin_percent": null, "margin_amount_sats": null, "settlement_amount_sats": null, "metadata": {}, "receipt_url": "https://www.satsrail.com/receipt/86b752b0-2c75-44a5-9b1f-541d27023e7d", "items": [ { "id": "475d84f6-8d6b-45d8-beea-b72e32801b63", "original_sale_item_id": null, "name": "Beans", "qty": 2, "price_cents": 5000, "line_total_cents": 10000, "tax_rate": null, "tax_amount_cents": 0, "taxes": [], "discount_amount_cents": 0, "discounts": [], "product_id": null, "sku_id": null, "product_sku": null, "sku_modifiers": [], "product_type_id": null, "product_type_name": null, "total_amount_sats": null, "margin_amount_sats": null, "settlement_amount_sats": null, "refund_status": "not_refunded", "refunded_qty": 0, "refunded_cents": 0 } ], "payments": [ { "id": "abe7a6c1-c1dc-41eb-af97-89c7e33bf299", "kind": "payment", "payment_method": "lightning", "amount_cents": 10000, "paid_at": "2026-11-16T22:40:17.042Z", "amount_sats": 123456, "btc_price_at_payment": "100000.0", "fiat_value_at_payment": "123.46", "fiat_variance_cents": 2346, "payment_hash": "97fbc35c56c03c99bc39ba8a6c041b495a0a30c3beb1f8a7102d0f2f59904ac1", "preimage": "preimage_5cac37f7e9c6d4151f67473b143f1aad_179", "txid": null, "vout": null, "card_brand": null, "card_last4": null, "approval_code": null, "terminal_transaction_number": null, "terminal_tip_cents": null, "custom_method_name": null, "custom_reference": null, "refunded_payment_id": null } ], "created_at": "2026-11-16T22:40:17.065Z", "updated_at": "2026-11-16T22:40:17.065Z" } ], "meta": { "current_page": 1, "per_page": 25, "total_count": 1, "total_pages": 1, "next_page": null, "prev_page": null } } ``` ### GET /api/v1/m/sales/{id} Sales: Read a sale A sale by its id, which is its order's id. It answers the same after the order has been deleted. Another merchant's sale, or one of the other mode, is not found. Path parameters: - `id` (string, required), e.g. `f8ca154d-9596-441c-a46d-622d8e2d4a13` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "sale", "id": "f8ca154d-9596-441c-a46d-622d8e2d4a13", "…": "the whole sale: see GET /api/v1/m/sales" } ``` ### GET /api/v1/m/wallets Wallets: List wallets Where the merchant is paid, in the order they are tried. Read-only; wallets are changed in the portal. Query parameters: - `q` (object): Filters, as `q[field_predicate]=value`. Fields: `status`, `enabled`, `name`. Predicates: `_eq`, `_not_eq`, `_gteq`, `_lteq`, `_gt`, `_lt`, `_in`, `_cont`. A status takes its name (`q[status_eq]=paid`); a date alone is that day on the merchant's clock. A field or value the list can't read answers 422 `invalid_filter`., e.g. `{"status_eq" => "…"}` - `page` (integer): Which page. - `per_page` (integer): How many a page. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `422` The request can't be done as sent. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "list", "data": [ { "object": "wallet", "id": "b82333a1-0c7a-4588-a27f-582edd2b3716", "name": "Wallet 1884", "status": "active", "enabled": true, "position": 1889, "created_at": "2026-11-16T22:40:57.950Z", "updated_at": "2026-11-16T22:40:57.950Z", "operational": true, "lightning": { "lightning_address": "shop@getalby.com", "max_payment_sats": null } } ], "meta": { "current_page": 1, "per_page": 25, "total_count": 1, "total_pages": 1, "next_page": null, "prev_page": null } } ``` ### GET /api/v1/m/wallets/{id} Wallets: Read a wallet One wallet, with its status and the most it takes in one payment. Path parameters: - `id` (string, required), e.g. `2b570b4f-55b1-4116-b27a-0b164afe4dbe` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "wallet", "id": "77e98576-7995-4f6f-a392-e8997612a857", "…": "the whole wallet: see GET /api/v1/m/wallets" } ``` ### GET /api/v1/m/media_keys Media keys: List media keys The keys that protect paid content, without the keys themselves. Query parameters: - `page` (integer): Which page. - `per_page` (integer): How many a page. Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "list", "data": [], "meta": { "current_page": 1, "per_page": 25, "total_count": 0, "total_pages": 0, "next_page": null, "prev_page": null } } ``` ### GET /api/v1/m/media_keys/{id} Media keys: Read a media key One media key and the products linked to it, without the key itself. Path parameters: - `id` (string, required), e.g. `not-a-uuid` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response (lists cut to their first item): ```json { "object": "media_key", "livemode": true, "id": "09d65ffd-d371-4bee-95f3-cf718743b039", "merchant_id": "51c4c93c-54dd-47b9-8b00-9b6036e10fb7", "name": "Video key", "key_fingerprint": "7ed2ba7c2f2cd70eefe86a7ccbd8199c3ca27c78fd7780620844bde5069a01c4", "rotation_pending": false, "browser_delivery": false, "product_ids": [ "7a44c833-c5e5-436c-a6a6-f5c2b697db49" ], "metadata": {}, "created_at": "2026-11-16T22:37:58.038Z", "updated_at": "2026-11-16T22:37:58.038Z" } ``` ### GET /api/v1/m/media_keys/{id}/key Media keys: Read a media key's secret The key itself. Needs manage access to media keys. Path parameters: - `id` (string, required), e.g. `9b076fd5-f1cd-4267-8292-851490144ec8` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "object": "media_key_secret", "id": "29cc1388-dc9f-4faf-ba5d-7f3bbc22ecbe", "key": "_lnyrAEg4wnz_s_AwB1EfKNobtixVQjmWOXAkqgUnoU", "key_fingerprint": "f59dc56d80235a712b7f022a6c65355c33fb26781fb96308ea99693765ac1752", "previous_key": null, "previous_key_fingerprint": null } ``` ### POST /api/v1/m/access/verify Access: Check a buyer's access token From your server. Confirms that an access token a buyer holds is for a paid order, and answers the content key it unlocks. Request body (`application/json`): - `access_token` (string) ```json { "access_token": "eyJfcmFpbHMiOnsiZGF0YSI6eyJvcmRlcl9pZCI6ImNiY2U5Y2I5LThmYmQtNGY0MS1hN2M5LTI3YzhiYzBhZjJiZCIsInByb2R1Y3RfaWQiOiI4YTc2YzAxZS1jNGZlLTQ0NGEtOTc1Ny05MDFkYTZkMDMxNWMiLCJtZXJjaGFudF9pZCI6ImFhNTI2Y2M4LWU4NDQtNDhmNy04YWJlLWU2NDg5ODY5ODViMyIsImV4cCI6MTc5NDg2OTQ0NH0sImV4cCI6IjIwMjYtMTEtMTZUMjI6NTA6NDQuNzkyWiIsInB1ciI6ImFjY2Vzc190b2tlbiJ9fQ--bfd827686f3282c21fa8b8bef046818ebaafb62b86fd33522013e30ce1a61c71" } ``` Responses: - `200` Success. - `400` The request couldn't be read. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `402` Payment is needed first. - `403` The key may not do this. - `422` The request can't be done as sent: `validation_error` (with `details` and `fields`), `unknown_parameter`, `invalid_argument`, `invalid_amount`, `invalid_filter`, or a code of the endpoint's own. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "valid": true, "remaining_seconds": 600, "resource_id": "prod_abc", "resource_type": "stream", "server_time": 1794868844, "expires_at": 1794869444, "product_id": "8a76c01e-c4fe-444a-9757-901da6d0315c", "order_id": "cbce9cb9-8fbd-4f41-a7c9-27c8bc0af2bd" } ``` ## Public API ### GET /api/v1/pub/orders/{id} Orders: Confirm a paid order With a publishable key. Confirms an order was paid and lists what it unlocked. An unpaid order answers 403. Path parameters: - `id` (string, required), e.g. `9b99c9ff-cac6-4fc8-a6ae-d8091e1322a8` Responses: - `200` Success. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `404` No such record for this merchant in the key's mode: `not_found`. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "order_id": "c0aa3aa8-50f6-43a6-b6f0-1f1b999a0f2c", "items": [ { "order_item_id": "ca361f17-e7c2-459e-9c7f-5309d471a1f6" } ] } ``` ### POST /api/v1/pub/checkout_sessions Checkout sessions: Create a checkout session from a web page With a publishable key. Send a `product_id`: SatsRail sets the price, so the page can't change it. Send the customer to `checkout_url`. An `amount_cents` with no product is taken only when the merchant turned on "Let my website name the amount" in Settings → Checkout; otherwise the answer is 403 `open_amounts_disabled`. A publishable key is public, so anyone on the page can change an amount: check the amount paid on `payment.received` before you deliver. Request body (`application/json`): - `checkout_session` (object, required) - `checkout_session.amount_cents` (integer) - `checkout_session.currency` (string): Optional; the merchant's currency, the default. Any other is refused with a validation_error naming the merchant's. - `checkout_session.product_id` (string): One of the merchant's products. Its name and price fill the item when not given. - `checkout_session.customer_email` (string) - `checkout_session.customer_name` (string) - `checkout_session.metadata` (object) - `checkout_session.metadata.order_ref` (string, required) - `checkout_session.metadata.source` (string, required) ```json { "checkout_session": { "amount_cents": 1, "currency": "usd", "product_id": "prod_8d5dd61d7453db75a354b294", "customer_email": "buyer@example.com", "customer_name": "Alice Smith", "metadata": { "order_ref": "MY-123", "source": "website" } } } ``` Responses: - `201` Created. - `400` The body couldn't be read: `invalid_json` for JSON that doesn't parse, `bad_request` for a body of the wrong shape. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `403` The key may not do this. - `404` No such record. - `422` The request can't be done as sent. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `201` response: ```json { "object": "checkout_session", "id": "37c0072e-5091-447f-8d28-589ffa77a042", "…": "the whole checkout_session: see POST /api/v1/m/checkout_sessions" } ``` ### POST /api/v1/pub/access/verify Access: Check a buyer's access token from a web page With a publishable key. Confirms a buyer's access token and answers the content key it unlocks. Request body (`application/json`): - `access_token` (string) ```json { "access_token": "eyJfcmFpbHMiOnsiZGF0YSI6eyJwYXltZW50X2lkIjoicGF5LXRlc3QtdXVpZCIsInJlc291cmNlX2lkIjoicHJvZF9hYmMiLCJyZXNvdXJjZV90eXBlIjoic3RyZWFtIiwibWVyY2hhbnRfaWQiOiJjNGFmNTBiOS1jYjQ5LTQzOTQtOGVkZS0zODJiZGFjZDBhMmEiLCJleHAiOjE3OTQ4Njk3NDh9LCJleHAiOiIyMDI2LTExLTE2VDIyOjU1OjQ4LjY3MFoiLCJwdXIiOiJhY2Nlc3NfdG9rZW4ifX0--96d26011bb03d951b574e70a76a40d10b1548701d087854bda0a2e18c1ef57ec" } ``` Responses: - `200` Success. - `400` The request couldn't be read. - `401` The key is missing, wrong, expired or revoked: `missing_token`, `invalid_token`, `token_expired`, `token_revoked`. - `402` Payment is needed first. - `403` The key may not do this: its security group doesn't allow it (`forbidden`), or the merchant can't act now (`merchant_not_operational`: a live key before the account is approved, or a suspended account). - `422` The request can't be done as sent: `validation_error` (with `details` and `fields`), `unknown_parameter`, `invalid_argument`, `invalid_amount`, `invalid_filter`, or a code of the endpoint's own. - `429` Too many requests: `rate_limit_exceeded`. Wait `Retry-After` seconds. Example `200` response: ```json { "valid": true, "remaining_seconds": 600, "resource_id": "prod_abc", "resource_type": "stream" } ``` --- # AI agents > Connect an AI assistant to a SatsRail merchant account over MCP: the hosted server, keys and OAuth, the payment tools, a payment step by step, and payment links for agents. Source: https://www.satsrail.com/developers/guides/ai-agents/ An AI assistant that takes payments for a merchant over MCP, or sends a person a link to pay. ## Connect to the hosted server SatsRail hosts the [MCP](https://modelcontextprotocol.io/) server at `https://satsrail.com/mcp`. It speaks Streamable HTTP (one JSON-RPC message per POST), so there is nothing to install: point your client at the URL with a secret key. ```json { "mcpServers": { "satsrail": { "type": "http", "url": "https://satsrail.com/mcp", "headers": { "Authorization": "Bearer sk_test_your_key_here" } } } } ``` - **Keys.** A test key (`sk_test_...`) works on every plan. A live key (`sk_live_...`) or an OAuth connection needs the merchant on Pro or above: on Free or Starter every tool call answers `plan_feature_unavailable`. The same live key calls the REST API on every plan. - **OAuth.** A client that supports OAuth connects with the URL alone: you sign in, pick the business and approve. The connection can do what you can do at that business, and you can revoke it under Settings → AI Assistants. Discovery starts at `https://satsrail.com/.well-known/oauth-protected-resource/mcp`. - **Two-factor authentication.** A tool that creates, changes or deletes anything answers `two_factor_required` unless the SatsRail account behind the key (whoever made it, or connected the assistant) has two-factor authentication on, under Account settings. Read-only tools work either way. - **Clients.** Any MCP client that speaks Streamable HTTP; a stdio-only client through `mcp-remote`. ## Tools `tools/list` returns the tools your key may call: what its security groups allow, among the features the business has on. These are the ones a payment uses. | Tool | What it does | | --- | --- | | `create_order` | With `amount_cents`: an order and its invoice (Lightning, or on-chain if asked for). Without: an empty draft to fill item by item | | `add_order_item` / `update_order_item` / `remove_order_item` | Build a draft order from catalog products or freeform items; taxes are worked out per item | | `create_order_payment_link` | One link for a draft order's total, paid once before it expires | | `send_order_payment_email` / `send_order_reminder` | Email the customer the link, or a reminder while it is unpaid | | `get_order` / `list_orders` / `cancel_order` | Read, list and cancel orders | | `get_invoice` / `get_invoice_qr` | An invoice's Lightning string (or on-chain address), and its QR code as SVG | | `check_invoice_status` | Whether an invoice is paid. For Lightning it asks the merchant's wallet provider (its LUD-21 verify URL); for on-chain it reports what SatsRail last saw on the chain | | `generate_invoice` | The invoice for an order still waiting for a bitcoin payment: the one it has if still good, or a new one once it ran out | | `create_checkout_session` / `get_checkout_session` | A hosted checkout for an amount or a product, and its `checkout_url`; read back as `completed` once paid | | `create_payment_link` | A reusable payment link (`/pay/…`) from a name and a price | | `list_payments` / `get_payment` | Confirmed payments | | `list_sales` / `get_sale` | The sales ledger: every paid order and refund, kept after the order is deleted | | `list_unfulfilled_orders` / `mark_order_fulfilled` | Paid orders still to deliver, and marking one shipped or delivered | | `create_webhook` | A webhook endpoint, for `payment.received` and the other events | | `get_merchant` / `list_wallets` | The merchant's profile and settings, and its wallets | ## A payment, step by step 1. `create_order` with `amount_cents`, in the merchant's currency: `invoice.payment_request` is the Lightning invoice. 2. Show the person the invoice, or its QR code from `get_invoice_qr`; they pay from their own wallet, straight to the merchant's. 3. `check_invoice_status` until `status` is `paid`, or wait for the `payment.received` webhook. 4. If it reads `expired`, `generate_invoice` for the same order, and back to step 2. Other ways to get paid: `create_checkout_session` gives a `checkout_url` for the [hosted checkout](https://www.satsrail.com/developers/guides/checkout-flow/), where the person can also choose on-chain or a card when the merchant takes them. An order built item by item goes out as one link (`create_order_payment_link`) or an email (`send_order_payment_email`). Without MCP, the same order and invoice are REST calls: see the [Quickstart](https://www.satsrail.com/developers/guides/quickstart/). ## Payment links for agents A payment link (`https://www.satsrail.com/pay/prod_…`) opens the hosted checkout for one product at one price. It never expires and can be paid any number of times. That makes it the thing an agent hands to a person: - **Selling.** The merchant's agent calls `create_payment_link` with a name and a price and gets back `payment_link_url` to send the customer. Every product the API returns carries its `payment_link_url` too (null while the product is inactive). - **Buying for someone.** An agent paying a SatsRail merchant for the person it works for sends that person the merchant's payment link, and they pay the merchant directly from their own wallet. Before forwarding a link, read it: the same URL with `.json` (or `Accept: application/json`) describes it and opens no checkout. No key is needed. ```http GET https://www.satsrail.com/pay/prod_4f1c9e2a7b3d8e6f5a1c0b9d.json { "object": "payment_link", "url": "https://www.satsrail.com/pay/prod_4f1c9e2a7b3d8e6f5a1c0b9d", "name": "Sunset kayak tour", "amount_cents": 4500, "currency": "usd", "formatted_amount": "$45.00", "merchant": { "name": "Ember Tours" }, "payable": true, "payment_methods": ["lightning"], "how_to_pay": "Open the url in a browser and pay from a bitcoin wallet. ..." } ``` `payable` is false while the merchant has no wallet that can take the price; say so rather than send a link that shows an unavailable page. An inactive or unknown link answers `404`. `amount_cents` is what the checkout opens at, taxes included. A product sold in more than one option (sizes, colors) adds `options`, each with its `id`, `name`, `amount_cents`, `formatted_amount` and `sold_out`: the person chooses one when the link opens, so tell them the choices and their prices. --- # Hosted checkout > SatsRail's hosted payment page: the ways in (API, payment link, embed button), what happens from session to paid order, the statuses, how you learn it was paid, the conversion fee, and what the customer sees. Source: https://www.satsrail.com/developers/guides/checkout-flow/ SatsRail's payment page, from a session to a paid order. ## Ways in Three ways in, one checkout page. **The API.** Create a session from your server and send the customer to its `checkout_url`. Send an amount, or a `product_id` to charge the product's price and taxes: ```bash curl -X POST https://app.satsrail.com/api/v1/m/checkout_sessions \ -H "Authorization: Bearer sk_live_..." \ -H "Content-Type: application/json" \ -d '{ "checkout_session": { "amount_cents": 2500, "customer_email": "buyer@example.com", "metadata": { "order_ref": "ORD-42" } } }' ``` **A payment link.** Every active product has one, its `payment_link_url` (`https://www.satsrail.com/pay/prod_abc123def456`); a test-mode product has none. Each visit starts its own session, so one link takes any number of payments. No code: share it by email, chat or QR code. **The embed button.** `pay.js` and a publishable key open the checkout from any web page. See [Embed button](https://www.satsrail.com/developers/guides/embed/). ## What happens 1. **A session is made** for an amount or a product. It lasts 15 minutes. 2. **The customer reaches the payment step.** SatsRail makes the order, prices it in sats at the current rate, and makes its invoice: a Lightning invoice from the merchant's wallet, or an on-chain address. From then on the session carries `order_id` and `invoice_id`. 3. **The customer pays** from their own wallet, straight to the merchant's. The page sees the payment by itself. 4. **SatsRail records the payment**: the invoice and the order become `paid`, the session `completed`, and `payment.received` goes to your webhook endpoints. A Lightning invoice's own expiry is set by the merchant's wallet provider. If it runs out while the session is still open, opening the checkout again gets a new invoice for the same order. A session left unpaid reads `expired`: make a new one. ## Statuses | Record | Statuses | | --- | --- | | Checkout session | `pending` → `completed` (paid), `expired` or `cancelled` | | Order | `pending` → `invoice_generated` → `paid`, then possibly `partially_refunded` or `refunded`; or `cancelled` or `expired` unpaid | | Invoice | `pending` → `paid`, `expired` or `cancelled` | ## Knowing it was paid Deliver on the `payment.received` webhook, after checking its signature and that `data.order_total_amount_cents` is what you meant to charge: see [Webhooks](https://www.satsrail.com/developers/guides/webhooks/). To ask instead, read the session: ```bash curl https://app.satsrail.com/api/v1/m/checkout_sessions/SESSION_ID \ -H "Authorization: Bearer $SATSRAIL_KEY" ``` The answer is wrapped in `data`: `data.status` is `completed` once paid. Never deliver because the customer came back to your page; the webhook or the session's status is the proof. There is no URL to send the customer back to: after paying they see SatsRail's confirmation. ## Bitcoin conversion fee A merchant can add a fee of up to 3% to bitcoin payments, to cover selling the sats. The price (`amount_cents`, `total_amount_cents`) doesn't change: the fee is on top, and the invoice is priced at `amount_due_cents`. The hosted checkout shows it as its own line. When the fee isn't zero these fields are added, so your own screen can show it too: ```json "total_amount_cents": 10000, "conversion_fee_percent": 1.5, "conversion_fee_cents": 150, "amount_due_cents": 10150, "total_amount_sats": 101500 ``` On orders, invoices, payment requests, checkout sessions and the order in webhook payloads; absent when the fee is zero and on cash orders. `GET /api/v1/m/merchant` returns the merchant's `conversion_fee_percent`. ## What the customer sees In `pay.js`'s overlay the checkout fills the frame; in a page of its own (a payment link, a `checkout_url`) it is one card. Each step shows only when it is needed: | Step | Shown when | | --- | --- | | Choose an option | The product is sold in more than one option (sizes, colors). | | Your details | The merchant asks for details (email, name, phone, shipping address) and the session carries none. | | How to pay | More than one way can take the amount: Lightning, on-chain (from its minimum), card, a bank transfer. | | Pay | Always. A QR code to scan; on a phone, **Open in wallet** hands the invoice to a wallet app on it. | | Paid | Always. In the overlay, "Payment received", then the overlay closes; in a tab, the confirmation page with the receipt. | ![Your details: the customer's email](https://www.satsrail.com/images/docs/checkout/popup-collect-info.png) ![How to pay: Lightning or on-chain](https://www.satsrail.com/images/docs/checkout/popup-select-method.png) ![Pay: the invoice's QR code](https://www.satsrail.com/images/docs/checkout/popup-qr-code.png) Creating a session answers `checkout_theme` (`light` or `dark`) and `checkout_accent_color` (`#rrggbb`), the merchant's choices for the checkout, so your page can match. --- # Embed button > Add a Bitcoin pay button to any web page with one script tag: for a product, or for an amount your page names. No backend needed. Source: https://www.satsrail.com/developers/guides/embed/ A pay button on any web page, from one script tag. ## How it works 1. `pay.js` puts a **Pay with Bitcoin** button on the page, right after its own ` ``` ### For an amount Your page names the amount, in your currency's smallest unit, and can pass the customer's details so the checkout doesn't ask for them. ```html ``` > **Turn amounts on first.** A button with `data-amount` works only once you turn on "Let my website name the amount" in Settings → Checkout. Until then `POST /api/v1/pub/checkout_sessions` answers `403` with the code `open_amounts_disabled`. A publishable key is public, so anyone on the page can change the amount: read what the order came to (`data.order_total_amount_cents` on `payment.received`) before you deliver. ## Attributes | Attribute | Description | | --- | --- | | `data-key` | Required. Your publishable key, `pk_live_...` or `pk_test_...`. | | `data-product` | The product's slug (`prod_...`). Its price is used. Either this or `data-amount`. | | `data-amount` | The amount in your currency's smallest unit (2500 is $25.00). Needs open amounts turned on, above. | | `data-currency` | Leave it out. A checkout is always in your business's currency, and any other is refused with a `validation_error` naming yours. | | `data-label` | The button's text, in place of `Pay with Bitcoin`. | | `data-customer-email`, `data-customer-name` | The customer's details. Send either and the checkout skips its details form. | | `data-on-complete` | A function on your page, called once the payment is made, with `{ order_id, order_number }` (and, for a product, `items` and an `access_token`). `satsrail:payment` fires on `document` with the same data. | | `data-on-detected` | A function called when an on-chain payment is seen and waits for its confirmations, with `{ order_id, order_number, required_confirmations }`. `satsrail:detected` fires too. The overlay closes a few seconds later, so `data-on-complete` doesn't follow: the `payment.received` webhook does, once it confirms. | | `data-on-expired` | For a product with a time limit on its access: a function called when that access runs out. `satsrail:access_expired` fires too. | | `data-delivery` | For content encrypted with a media key (MediaKeys in the [API reference](https://www.satsrail.com/developers/)): the wrapped content key. After the payment, `pay.js` unwraps it, loads `deliver.js` and decrypts the content on the page, then fires `privapaid:unlocked` (or `privapaid:error`). | The callbacks and events come from the overlay only. A checkout in a tab ends on SatsRail's confirmation page: there is no return URL. `data-mode`, which older snippets carry, changes nothing (below). Deliver on the `payment.received` [webhook](https://www.satsrail.com/developers/guides/webhooks/), never on the callback alone. ## How the checkout opens Settings → Checkout → Checkout mode decides, for every button. **Embedded checkout**, the default, opens it in an overlay on your page: 500×700 on a computer, the whole screen on a phone. **New tab** opens a new browser tab, or the same tab on a phone. Closing the overlay before paying cancels the session. **Card payments.** When the merchant takes cards through its own payment gateway, the checkout offers *Pay by card* after bitcoin. Card processors' pages refuse to load inside an iframe, so in the overlay the card choice opens the processor's page in a new tab, and the overlay waits until the processor confirms the payment. Closing the overlay then doesn't cancel the checkout. `data-on-complete` and `satsrail:payment` fire for a card payment as for bitcoin. ## Styling The button is a `