# LoyX Developers > Connect a till, web shop or back office to LoyX: identify members, show their card and rewards, record sales, and keep products and stores in sync. ## Notes for AI tools - Money is always an integer in minor units (4500 = 45.00 SEK) with an ISO 4217 currency. Never send floats. - Send the till's own receipt id as `external.external_transaction_id` on every sale. A retry with the same body returns the original sale; the same id with a different body is a 409. - Points are calculated asynchronously. The sale response does not contain the points earned; read the member card afterwards. - Scan QR codes as raw strings and send them unchanged as `qr_code`. A `404 qr_code_not_resolvable` means "ask the member to refresh the code". - Pages under "Preview" describe planned features. They are not live; do not generate code that calls them. - Access tokens expire. On a 401, fetch a new token and retry once. --- # LoyX Partners API > Connect a till, web shop or back office to LoyX loyalty. Source: https://developers.loyx.se/ LoyX runs loyalty programs for retail brands. Members carry one LoyX app for every brand they join. The Partners API lets your system take part at the moment that matters: the sale. With it you can: - **Find a member** from the QR code in their LoyX app, or from a phone number, email or member id. - **Show their card**: balance, program, current cycle and the rewards they can use. - **Record the sale**, so the member earns points or stamps. - **Keep products and stores in sync** with what your system already knows. ## How it works 1. The brand gives you a **client id and secret** for its account. 2. You exchange them for a short-lived **access token**. 3. You call the API with `Authorization: Bearer `. Every call acts on that one brand. ```bash curl -X POST https://api.loyx.se/partners/v1/memberships/lookup \ -H "Authorization: Bearer $LOYX_TOKEN" \ -H "Content-Type: application/json" \ -d '{"identifier": "qr_code", "value": "lx1_EXAMPLE_TOKEN"}' ``` The base URL is `https://api.loyx.se/partners`. All paths start with `/v1`. ## Where to start - [Authentication](/guides/authentication/): get a token. - [Till integration walkthrough](/guides/till-walkthrough/): the whole flow, from scan to receipt. - [API reference](/api/): every endpoint and field, generated from the same spec the server uses. ## Rules you can rely on - **Money is an integer in minor units** with a currency. `4500` with `SEK` is 45.00 kr. See [Money](/guides/money/). - **A retry never books a sale twice.** Your receipt id is the duplicate key. See [Idempotency](/guides/idempotency/). - **Errors are typed** and carry a `request_id` you can quote to support. See [Errors](/guides/errors/). - **Points are calculated after the sale**, not in the sale response. Read the member card to see the new balance. - **Ignore fields and enum values you do not know.** We add fields without a new version. We never remove or rename them inside `v1`. ## Live and preview Pages under **Preview** describe features we are building, such as joining at the till, reserving rewards and webhooks. They are not live, and their shape may change. Build only against what is in the [API reference](/api/). --- # Authentication > Exchange your client id and secret for a one-hour access token. Source: https://developers.loyx.se/guides/authentication/ The API uses the OAuth 2 **client credentials** flow. You hold a client id and a client secret for one brand. You trade them for an access token, and send that token on every call. ## 1. Get your credentials The brand creates an API key for you in the LoyX Portal and shares the **client id** and **client secret** with you. The secret is shown once, when it is created; afterwards the Portal shows only its last four characters. Store it like a password: in a secret store, never in source code, never in logs. One key belongs to one brand. If you serve several brands, you hold one key per brand. ## 2. Get an access token ```bash curl -X POST https://api.loyx.se/partners/v1/auth/token \ -u "$LOYX_CLIENT_ID:$LOYX_CLIENT_SECRET" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=client_credentials" ``` The client id and secret go in an HTTP Basic `Authorization` header. The body is a form with `grant_type=client_credentials`. ```json { "access_token": "loyx_EXAMPLE_TOKEN", "token_type": "bearer", "expires_in": 3600, "scope": "members:read sales:write rewards:read stores:read" } ``` `scope` lists, space separated, what this token may do. You do not ask for scopes: the token carries the scopes the brand gave the key. ## 3. Call the API ``` Authorization: Bearer loyx_EXAMPLE_TOKEN ``` The token decides which brand you act on. You never send a brand or company id in the body. ## Token lifetime A token lives **one hour** (`expires_in` is in seconds; read it rather than hard-coding 3600). It is opaque: do not parse it. There are no refresh tokens: ask for a new token when the old one is close to expiry. - Cache the token and reuse it across calls and registers. Do not fetch a token per request; the token endpoint has its own, low rate limit. - On a `401` from any call, get a new token and retry that call **once**. Tokens can end early, for example when the brand changes the key's scopes. ## Scopes Each key carries the scopes the brand granted. A call outside them answers `403 insufficient_scope`, with `error.param` set to `scope`. | Scope | Allows | |---|---| | `members:read` | `POST /v1/memberships/lookup` and `GET /v1/memberships/{id}/loyalty`. | | `rewards:read` | `GET /v1/memberships/{id}/rewards`. | | `sales:write` | `POST /v1/transactions`, and reading back transactions (`GET /v1/transactions...`). | | `products:read` | `GET /v1/products...` and `GET /v1/stores/{id}/products`. | | `products:write` | Creating, changing and removing products, including bulk upserts. | | `stores:read` | `GET /v1/stores...`. | | `stores:write` | Creating, changing and removing stores. | `rewards:redeem` and `webhooks:manage` are reserved for [features in preview](/preview/) and cannot be granted yet. Ask the brand for only the scopes your integration uses. A till that looks members up, shows rewards and sends sales needs `members:read`, `rewards:read`, `sales:write` and `stores:read`. ## Rotating the secret Rotate secrets regularly, and at once if one may have leaked. The brand rotates the key in the LoyX Portal and picks an overlap of 0 to 168 hours (default 24): - During the overlap, **both** the old and the new secret work at the token endpoint. Deploy the new secret in that window. - After the overlap, only the new secret works. Tokens already issued keep working until they expire. - An overlap of 0 ends the old secret **and every live token of the key** at once. Use it when a secret has leaked. ## Revocation When the brand revokes a key, its live tokens fail on the next call (`401 invalid_token`) and the token endpoint refuses the key (`401 inactive_client`). There is nothing to retry: ask the brand for a new key. ## Errors | HTTP | `code` | Meaning | |---|---|---| | 400 | `unsupported_grant_type` | `grant_type` is not `client_credentials`. | | 401 | `invalid_basic_auth` | The Basic header is missing or malformed. | | 401 | `invalid_client` | Unknown client id or wrong secret. | | 401 | `inactive_client` | The key is switched off or revoked. | | 401 | `missing_token` | A call came without an `Authorization` header. | | 401 | `invalid_authorization_header` | The header is not `Bearer `. | | 401 | `invalid_token` | The token is unknown, expired or ended. Get a new one. | | 403 | `insufficient_scope` | The key lacks the scope this call needs. | | 429 | `rate_limit_exceeded` | Too many requests. Wait `Retry-After` seconds. See [Rate limits](/guides/rate-limits/). | | 503 | `token_endpoint_unavailable` | The token endpoint cannot check limits right now. Retry with backoff. | All of them use the standard [error shape](/guides/errors/). --- # Till integration walkthrough > The whole flow at the till, from setup to the receipt, with the calls in order. Source: https://developers.loyx.se/guides/till-walkthrough/ This page walks through a complete till integration using only live endpoints. Each step links to its guide. ## Once, at setup 1. **Get credentials.** The brand gives you a client id and secret. Store the secret like a password. See [Authentication](/guides/authentication/). 2. **Map your stores.** For each till location, find the LoyX store by your own store code: `GET /v1/stores/external/{external_store_id}`. If a store has no code yet, set it with `PATCH /v1/stores/{store_id}` or ask the brand to. See [Stores](/guides/stores/). 3. **Decide your receipt id.** Pick an id that is unique per brand for all time, for example `{store}-{register}-{number}`. See [Idempotency](/guides/idempotency/). ## Every time a token expires 4. `POST /v1/auth/token` with your client id and secret. Cache the token until shortly before `expires_in` runs out. On any `401`, get a new token and retry the call once. ## At each sale ``` cashier scans app QR ──► lookup ──► card ──► (sale is paid) ──► record sale │ │ └─ 404: continue without a member ───────┘ ``` 5. **Identify.** The member shows the QR code in the LoyX app. Send the scanned text, unchanged: ``` POST /v1/memberships/lookup {"identifier": "qr_code", "value": ""} ``` Keep `membership_id`. On `404 qr_code_not_resolvable`, ask the member to refresh the code. On `404 membership_not_found`, continue as a guest. See [Identify a member](/guides/identify-member/). 6. **Show the card** (optional). The lookup answer already has the balance, unit and cycle. Add the member's usable rewards at this store with `GET /v1/memberships/{membership_id}/rewards?external_store_id=`. See [Member card and rewards](/guides/member-card/). 7. **Record the sale** once it is paid: `POST /v1/transactions` with your receipt id in `external.external_transaction_id`, your store code in `external.external_store_id`, the member as `{"identifier": "membership_id", "value": "..."}`, and the lines. See [Record a sale](/guides/record-sale/). Send it **after** the receipt prints, from a local queue. The sale should never wait on LoyX. ## When things go wrong | Situation | Do this | |---|---| | No answer, timeout, `502`/`503`/`504` | Retry the same request later. The receipt id makes it safe. | | `429` | Wait `Retry-After` seconds. | | `401` | Get a new token, retry once. | | `409 external_transaction_id_conflict` | Two receipts share an id. Fix your id scheme; do not retry. | | `422` | Fix the fields listed in `error.details`; do not retry unchanged. | | The till is offline | Queue sales locally, send them when online, in order. Late sales are accepted. | ## Checklist before go-live - [ ] Secrets are stored encrypted and never logged. - [ ] Every sale carries a unique, stable `external_transaction_id`. - [ ] A retried sale returns `200` with `Idempotent-Replayed: true`, not a second sale. - [ ] QR text is sent unchanged. - [ ] Amounts are integers in minor units. - [ ] Sales are sent from a queue that survives a restart. - [ ] Phone numbers, emails and national ids never appear in URLs or logs. - [ ] Your client ignores unknown fields and enum values. --- # Identify a member > Turn a scanned QR code, phone number, email or member id into a LoyX membership. Source: https://developers.loyx.se/guides/identify-member/ Before you can show a card or credit a sale, find the member. Call: ``` POST /v1/memberships/lookup ``` with one identifier: ```json { "identifier": "qr_code", "value": "lx1_EXAMPLE_TOKEN" } ``` | `identifier` | `value` | Notes | |---|---|---| | `qr_code` | The string your scanner read | The normal case at a till. See below. | | `mobile_number` | E.164, for example `+46701234567` | Only if the brand collects phone numbers. | | `email` | An email address | Only if the brand collects emails. | | `membership_id` | A LoyX membership UUID | When you kept it from an earlier lookup. | | `user_id` | A LoyX user UUID | Rare. Prefer `membership_id`. | | `national_id` | A national id number | Only if the brand uses it. Never log it. | ## Scanning the app QR code The member opens the LoyX app and shows a QR code. **Send the scanned string exactly as read.** Do not trim, parse or decode it. - Current codes start with `lx1_` and rotate every few minutes. - Older codes are a plain UUID. They still work. LoyX tells the two apart, so you need no change when the old form is retired. ## What you get back `200` with the membership: ```json { "membership_id": "6f1c3e1a-0000-4000-8000-000000000001", "user_id": "0b7d9f52-0000-4000-8000-000000000002", "full_name": "Alex Example", "status": "active", "balance": 3, "loyalty_program_type": "stamps", "unit": { "label": "stamps", "presentation": "card", "currency": null, "minor_units": null, "locale": null }, "cycle": 3, "cycle_length": 10, "stamps_dates": ["2026-11-02T08:30:00Z", "2026-11-09T12:05:00Z", "2026-11-20T10:15:00Z"], "celebration": false, "created_at": "2026-10-01T09:00:00Z", "updated_at": "2026-11-20T10:15:00Z" } ``` Keep `membership_id` for the rest of the sale. Put it on the sale as the member reference. The answer is enough for a simple card: `balance` in the program's `unit`, the current `cycle` number and its size `cycle_length` (`null` when unbounded), and `stamps_dates` on a stamp card. `unit` is `null` when the member is on no program. See [Member card and rewards](/guides/member-card/). ## When nothing is found | Response | Meaning | What the till should do | |---|---|---| | `404 qr_code_not_resolvable` | The QR code expired or a newer one replaced it. | Ask the member to refresh the code in the app, then scan again. | | `404 membership_not_found` | This person is not an active member of this brand. | Continue the sale without a member. | | `422 invalid_fields` | The value does not match the identifier's format. | Fix the input. | A miss is normal traffic. Do not retry it in a loop. ## Privacy Member lookup is rate limited per client, because it can reveal who is a member. Look up once per sale, not once per keystroke. Never put phone numbers, emails or national ids in URLs or logs. --- # Member card and rewards > Show the member's balance, program, cycle and usable rewards at the till. Source: https://developers.loyx.se/guides/member-card/ After you [identify a member](/guides/identify-member/), show their card. Call: ``` GET /v1/memberships/{membership_id}/loyalty ``` ```json { "balance": 3, "unit": { "label": "stamps", "presentation": "card" }, "program": { "id": "1d2e3f40-0000-4000-8000-000000000003", "name": "Coffee card" }, "cycle": { "seq": 3, "length": 10, "progress_pct": 30, "started_at": "2026-11-02T08:30:00Z" }, "punches": ["2026-11-02T08:30:00Z", "2026-11-09T12:05:00Z", "2026-11-20T10:15:00Z"] } ``` The [API reference](/api/) has every field. ## Reading the card - `balance` is in the program's own unit: points, stamps or a cash value. - `unit.presentation` says how to draw it: - `card`: a stamp card. `punches` lists when each stamp in the current cycle was earned. - `counter`: a points counter. `punches` is `null`. - `currency`: a cash-like balance (cashback). `balance` is money in minor units, and `unit` also carries `currency`, `minor_units` and `locale` so you can format it (see [Money](/guides/money/)). For `card` and `counter` these three are `null`. `punches` is `null`. - `cycle` is the member's current round on the program. `length` is the target (or `null` when there is none) and `progress_pct` how full it is. When the target is reached, a reward is unlocked and a new cycle starts. New `presentation` values may be added. When you meet one you do not know, show `balance` with `unit.label`. ## The card straight from the lookup [The lookup](/guides/identify-member/) already returns `balance`, `unit`, `cycle`, `cycle_length` (for example `10` on a 10-stamp card, `null` when unbounded) and `stamps_dates`. For a simple till display, the lookup plus the rewards list below is enough: two calls per sale. ## Balances lag the sale Points and stamps are calculated **after** the sale is recorded, usually within seconds. If you read the card straight after recording a sale, it may still show the old balance. Do not add the points yourself. ## Rewards List the rewards the member can use **now**, at your store: ``` GET /v1/memberships/{membership_id}/rewards?external_store_id=store12 ``` | Query | Notes | |---|---| | `external_store_id` or `store_id` | Optional. Your store code or the LoyX store id; send one, not both. With a store, rewards limited to other stores are left out. | | `limit` | 1 to 200, default 50. | | `cursor` | From `pagination.next_cursor` of the previous page. | ```json { "data": [ { "_id": "2c4d6e80-0000-4000-8000-000000000006", "membership_id": "6f1c3e1a-0000-4000-8000-000000000001", "offer_id": "9e8d7c6b-0000-4000-8000-000000000007", "title": "Free coffee", "benefit": { "kind": "free_item", "quantity": 1, "percent": null, "amount": null, "price": null, "per": null, "pay_quantity": null, "description": null }, "terms_and_conditions": ["One per visit."], "valid_from": "2026-11-20T00:00:00Z", "valid_to": "2026-12-20T23:59:59Z", "max_redemptions": 1, "times_redeemed": 0, "created_at": "2026-11-20T10:16:00Z" } ], "pagination": { "limit": 50, "has_more": false, "next_cursor": null } } ``` - Only active rewards are listed. Rewards from a paused campaign are hidden. Newest first. - `_id` is the member's own reward. Keep it: using rewards at the till will take this id. - `benefit` is the benefit at the store you asked about; a reward can differ between stores. Without a store, it is the reward's default benefit. - `benefit.kind` is one of `percent`, `amount`, `fixed_price`, `free_item`, `text`, `bundle_price`, `bundle_percent`, `multibuy`. More kinds may be added: show the `title` for a kind you do not know. Money fields carry `minor_units` and `locale`. | Error | Meaning | |---|---| | `400 store_reference_ambiguous` | You sent both `store_id` and `external_store_id`. | | `400 invalid_cursor` | The cursor is not one we gave you. Start from the first page. | | `404` | The member, or the store, does not exist for this brand. | Showing rewards is live. **Using** a reward at the till (reserve, then commit or release) is coming: see [Reserve and use rewards](/preview/hold-commit-release/) under Preview. --- # Record a sale > Send the finished receipt so the member earns, and LoyX sees the sale. Source: https://developers.loyx.se/guides/record-sale/ Send every finished receipt to LoyX, with or without a member. With a member, they earn. Without one, the sale still counts for the brand's reports, and the customer can claim it in the app later. ``` POST /v1/transactions ``` ```json { "transaction_type": "purchase", "currency": "SEK", "store_id": null, "member": [ { "identifier": "membership_id", "value": "6f1c3e1a-0000-4000-8000-000000000001" } ], "external": { "external_transaction_id": "store12-reg3-000123", "external_store_id": "store12", "receipt_number": "000123", "purchased_at": "2026-11-20T10:15:00Z", "pos_system": "your-till-name", "cashier_id": "c-42" }, "items": [ { "sequence_number": 1, "external_product_id": "SKU-1001", "product_name": "Oat latte", "quantity": { "value": 2, "unit": "ea" }, "unit_price": { "value": 4500, "currency": "SEK" }, "tax_rate": 1200 } ] } ``` ## The fields that matter | Field | Why | |---|---| | `external.external_transaction_id` | **Your receipt id. Send it on every sale.** It is the duplicate key: a retry with the same id never books twice. It must be unique per brand for your system. If your receipt number is only unique per store or register, combine them, for example `store12-reg3-000123`. | | `external.external_store_id` | Your own store code. LoyX maps it to the brand's store. You can send `store_id` (the LoyX UUID) instead. | | `member` | Who bought. Use `membership_id` from [the lookup](/guides/identify-member/). Leave it empty for a guest. | | `items` | One entry per receipt line, with `unit_price` and `quantity`. LoyX computes the totals. | | `items[].external_product_id` | Your product id. LoyX uses it to match the line to the brand's catalog. | | `external.purchased_at` | When the sale happened at the till, in UTC. | | `items[].tax_rate` | VAT in hundredths of a percent: `2500` is 25 %, `1200` is 12 %. | All amounts are [integers in minor units](/guides/money/). ## The response `201 Created` with the stored transaction, including the totals LoyX computed and its `_id`. The `loyalty` block is empty at this point: **points are calculated after the sale**, usually within seconds. Read the [member card](/guides/member-card/) to see the new balance. ## Retries are safe Network errors happen. If you did not get an answer, send the same request again with the same `external_transaction_id`. | You send | You get | |---|---| | A new `external_transaction_id` | `201`, a new transaction. | | The same id and the same content | `200` with the original transaction and the header `Idempotent-Replayed: true`. Nothing is booked twice. | | The same id with different content | `409 external_transaction_id_conflict`. Two different receipts share one id: fix the id in your system. | You may also send an `Idempotency-Key` header (a new UUID per sale). Reusing a key for a different sale is `409 idempotency_key_reused`. Details: [Idempotency](/guides/idempotency/). ## When the till only knows the total Some systems only know what the customer paid. Send `totals` instead of `items`: ```json { "currency": "SEK", "external": { "external_transaction_id": "web-88812" }, "totals": { "paid_minor": 24900 } } ``` `items` and `totals` cannot be sent together. Programs that earn on specific products cannot earn from a total, so send lines when you have them. ## Offline tills Queue the sale locally and send it when the connection is back. Keep the same `external_transaction_id`. Late sales are accepted and count on the day they arrive. ## Discounts Send the till's own discounts per line (`items[].discounts`) or per basket (`discounts`), each with a `type` (`sale`, `voucher`, `campaign`, `staff`, `manual`, `threshold`, `tier`) and an `amount` in minor units. Members earn on what they actually paid. ## Returns Returns linked to the original receipt are coming. See [Returns](/preview/returns/) under Preview. --- # Products > Keep the brand's catalog in step with yours, matched by your own product id, one at a time or in bulk. Source: https://developers.loyx.se/guides/products/ LoyX keeps a catalog per brand. Products matter for programs that reward specific products, and for the brand's reports. **Your own product id is the key**: send it as `external_product_id` and LoyX matches on it everywhere. You do not have to load the catalog before you send sales. Unknown products on a sale are created for you. ## Products on a sale Put your product id on every sale line as `items[].external_product_id`, with the `product_name`: ```json { "external_product_id": "SKU-1001", "product_name": "Oat latte", "quantity": { "value": 1, "unit": "ea" }, "unit_price": { "value": 4500, "currency": "SEK" } } ``` - A known id links the line to that product. - An unknown id **creates a minimal product**: the line's name, price, unit and identifiers, your id, no store assortment. It counts for loyalty, shows in the staff app, and stays hidden from the consumer app until the brand completes it. - Keep `external_product_id` stable for the life of a product, and never reuse it for a different one. Lines with `loyalty_eligible: false` never earn. Use it for gift cards, deposits and services. ## Create or update one product ``` POST /v1/products ``` ```json { "external_product_id": "SKU-1001", "name": "Oat latte", "price": { "value": 4500, "currency": "SEK" }, "identifiers": [ { "type": "sku", "value": "SKU-1001" }, { "type": "ean13", "value": "7300000000017" } ], "stores": [{ "store_id": "8a9b0c1d-0000-4000-8000-000000000005" }], "is_loyalty_program_eligible": true } ``` This is an **upsert** on `external_product_id`: | Situation | Result | |---|---| | No product has this id | `201`, created. | | A product already has this id | `200`, updated. Only the fields you send change; `price` is always applied; `stores` replaces the assortment. A removed product with this id is restored. | | No `external_product_id` sent | `201`, always a new product. | Retrying is safe: the same id always lands on the same product. You may also send an `Idempotency-Key`: the same key with the same body within 24 hours returns the original response, status included (a `201` stays `201`); the same key with a different body is `409 idempotency_key_reused`; a resend while the first is still running is `409 idempotency_request_in_progress`. Keys for this route and for `/bulk` are separate. - `price` is the base price in [minor units](/guides/money/). Each store entry may override it. - Identifier types are `gtin`, `ean13`, `ean8`, `sku` and `pos`. Each `(type, value)` pair is unique per brand. ## Bulk upsert Send up to **100** products per call: ``` POST /v1/products/bulk { "products": [ { "external_product_id": "SKU-1001", "name": "Oat latte", ... }, ... ] } ``` `external_product_id` is required on every item. Items are processed in order and independently: one failure does not undo the others, and a failed item is never half written. The call always answers `207 Multi-Status` with a result per item: ```json { "results": [ { "index": 0, "external_product_id": "SKU-1001", "status": "updated", "product": { "...": "..." }, "error": null }, { "index": 1, "external_product_id": "SKU-1002", "status": "failed", "product": null, "error": { "code": "store_not_found", "message": "...", "param": "products.1.stores.0.store_id" } } ], "created": 0, "updated": 1, "failed": 1 } ``` - `status` is `created`, `updated` or `failed`. Check every item: `207` does not mean all succeeded. - An id repeated in one request fails from its second occurrence with `duplicate_in_request`. - Retry the whole request or only the failed items: both are safe. - Send an `Idempotency-Key` to make a retry return the original result instead of running again. The same key with the same body within 24 hours replays; the same key with a different body is `409 idempotency_key_reused`; a resend while the first is still running is `409 idempotency_request_in_progress`. Keys are scoped to your API key. - 0 or more than 100 items is a `422`. ## Other calls | Call | Use | |---|---| | `GET /v1/products` | List the catalog (`limit`, `offset`). | | `GET /v1/products/{product_id}` | Read one product. Responses include `external_product_id`. | | `PATCH /v1/products/{product_id}` | Change some fields, including `external_product_id`. Setting an id another product holds is `409 external_product_id_conflict`. | | `DELETE /v1/products/{product_id}` | Remove a product. It is kept for history. | | `GET /v1/products/{product_id}/stores` | Which stores carry it, at what price. | | `GET /v1/stores/{store_id}/products` | What one store carries, with cursor paging. | Reading needs `products:read`; creating, changing and removing need `products:write`. The full fields are in the [API reference](/api/). --- # Stores > Address stores by your own store code and keep them in sync. Source: https://developers.loyx.se/guides/stores/ Every sale happens in a store. LoyX knows the brand's stores, and each store can carry **your own code** for it: `external_store_id`. Use that code everywhere and you never have to keep LoyX's ids. ## Find a store by your code ``` GET /v1/stores/external/{external_store_id} ``` Returns the store, or `404 store_not_found`. The same path takes `PATCH` (change some fields) and `DELETE` (remove the store; it is kept for history, not erased). ## List stores ``` GET /v1/stores?limit=50&offset=0 ``` Filter with `status` and `type`. Use it during setup to let the user pick the store a till belongs to. ## Create a store ``` POST /v1/stores ``` ```json { "external_store_id": "store12", "name": "Example Store Central", "timezone": "Europe/Stockholm", "type": "physical", "address": { "street1": "Exempelgatan 1", "postal_code": "111 22", "city": "Stockholm", "country": "SE" }, "geo": { "latitude": 59.3326, "longitude": 18.0649 } } ``` - `external_store_id`, `name` and `timezone` are required. - Physical and pop-up stores need an address and a location. Online and warehouse stores do not. - A second store with the same `external_store_id` answers `409`. Read the existing one instead. Most brands set their stores up in the LoyX Portal. Create stores through the API only when your system is the brand's source of truth for them. ## On a sale Put your code on the sale as `external.external_store_id`. LoyX maps it to the store. See [Record a sale](/guides/record-sale/). The exact fields for each call are in the [API reference](/api/). --- # Money > Amounts are integers in minor units, always with a currency. Source: https://developers.loyx.se/guides/money/ Every amount in the API is an **integer in the currency's minor unit**, paired with an ISO 4217 currency code. | You mean | You send | |---|---| | 45.00 SEK | `{"value": 4500, "currency": "SEK"}` | | 129.90 NOK | `{"value": 12990, "currency": "NOK"}` | | 9.95 EUR | `{"value": 995, "currency": "EUR"}` | Always send whole numbers in minor units. A decimal such as `45.5` is rejected, and `45` means 0.45 kr, not 45 kr. ## Showing amounts Prices that LoyX returns carry two extra fields, so you can format them without hard-coding rules: ```json { "value": 4500, "currency": "SEK", "minor_units": 100, "locale": "sv-SE" } ``` - `minor_units` is the divisor: `4500 / 100 = 45.00`. - `locale` is the RFC 5646 locale to format with. `sv-SE` gives `45,00 kr`. ## Totals are computed by LoyX On a sale you send line items with a unit price and a quantity. LoyX computes the line totals and the basket total itself, and ignores totals you send. A rounding difference in your system cannot change what the member earns. If your system only knows what the customer paid, not the lines, send that amount as `totals.paid_minor` instead of `items`. See [Record a sale](/guides/record-sale/). ## Currencies A brand's program has one currency. Send sales in that currency. The [API reference](/api/) lists the accepted codes. --- # Idempotency > Retry any call safely. Your own ids are the duplicate keys. Source: https://developers.loyx.se/guides/idempotency/ Tills lose connections, time out and retry. The API is built so that a retry never creates a second sale, product or store. ## Sales: your receipt id is the key `external.external_transaction_id` on `POST /v1/transactions` is the duplicate key for sales. It never expires. | You send | You get | |---|---| | A new id | `201 Created`, a new transaction. | | An id LoyX has seen, with the same content | `200 OK`, the **original** transaction, and the header `Idempotent-Replayed: true`. Nothing new is booked. | | An id LoyX has seen, with different content | `409 external_transaction_id_conflict`. Two receipts share one id. | Two identical requests sent at the same moment are safe too: one gets `201`, the other `200` with the same transaction. "Same content" means the same transaction type, currency, receipt references (including `external_transaction_id`), lines and discounts. The `member` and `metadata` fields are not compared, so adding a member on a retry does not cause a conflict. How to pick the id: - It must be unique per brand for your system, for all time. - Use the id your till already gives the receipt. If that is only unique per store or register, combine them: `store12-reg3-000123`. - Never reuse an id for a new sale, even after a void. ## Products: upsert by your product id `POST /v1/products` and `POST /v1/products/bulk` match on `external_product_id`: a retry updates the same product instead of creating a second one. See [Products](/guides/products/). ## Stores: your store code is the key A store's `external_store_id` is unique per brand. Creating a second store with the same code answers `409`. On a `409` after a retry, read the store back by its code and carry on. ## The Idempotency-Key header On `POST /v1/transactions` you may also send an `Idempotency-Key` header, for example a UUID per sale. It is optional. | You send | You get | |---|---| | A key LoyX has seen, with the same body | `200 OK`, the original transaction, `Idempotent-Replayed: true`. | | A key LoyX has seen, with a different sale | `409 idempotency_key_reused` (`param`: `Idempotency-Key`). Use a new key for every sale. | The receipt id rule above applies whether or not you send a key: the same `external_transaction_id` with the same content is always a replay, even under a new key or none. So the receipt id is your main protection, and the key is an extra one. Never put personal data in a key. `POST /v1/products` and `POST /v1/products/bulk` honour the key too, for 24 hours, scoped to your API key, and replay the original status (`201` stays `201`). A resend while the first is still running is `409 idempotency_request_in_progress`. On other write endpoints the header is accepted and ignored; they are protected by the ids above. ## Retry rules for your client - Retry on network errors, `429`, `502`, `503` and `504`, with backoff. Respect `Retry-After`. - Do not retry other `4xx` answers unchanged. Fix the request. - Treat `200` with `Idempotent-Replayed: true` as success. --- # Errors > Every error has the same JSON shape, a machine code and a request id. Source: https://developers.loyx.se/guides/errors/ Errors use real HTTP status codes and one JSON shape: ```json { "error": { "type": "not_found_error", "code": "membership_not_found", "message": "No active membership matches this identifier.", "param": "value", "doc_url": "https://developers.loyx.se/guides/errors/" }, "request_id": "3f2c9a1e-0000-4000-8000-000000000004" } ``` | Field | Use it for | |---|---| | `error.type` | The broad class. Branch on it when you do not know the `code`. | | `error.code` | The exact reason. Stable: we never change the meaning of a code. Branch on this. | | `error.message` | Text for your logs and developers. Not for the cashier, and it may change. | | `error.param` | The field that caused it, when there is one. | | `error.doc_url` | A link to this page. | | `error.details` | On `422 invalid_fields` only: one entry per failing field. | | `request_id` | Quote it when you contact support. It is also in the `X-Request-ID` response header. | You can send your own `X-Request-ID` (letters, digits, `.`, `_`, `-`, up to 64 characters). We echo it back and use it in our logs, so one id follows the call through both systems. ## Types | HTTP | `error.type` | Meaning | |---|---|---| | 400 | `invalid_request_error` | The request is wrong in a way the schema cannot express. | | 401 | `authentication_error` | No token, or the token is invalid or expired. Get a new token and retry once. | | 403 | `authorization_error` | The token is valid but not allowed to do this, for example `insufficient_scope`. | | 404 | `not_found_error` | The resource does not exist for this brand. | | 409 | `conflict_error` | The request clashes with existing data, for example a duplicate id. | | 422 | `validation_error` | A field failed validation. See `error.details`. | | 429 | `rate_limit_error` | Too many requests. Wait for `Retry-After` seconds. | | 500 | `internal_error` | Our fault (`internal_server_error`, `database_error`). Retry with backoff; quote the `request_id` if it persists. | | 503 | (varies) | A dependency is briefly unavailable. Retry with backoff. | ## Validation errors A `422` lists every failing field at once: ```json { "error": { "type": "validation_error", "code": "invalid_fields", "message": "Validation failed for 1 field(s)", "details": [ { "param": "items.0.unit_price.value", "message": "Input should be a valid integer" } ] }, "request_id": "..." } ``` ## Codes you will meet at the till | Code | HTTP | What to do | |---|---|---| | `qr_code_not_resolvable` | 404 | The QR code expired. Ask the member to refresh it in the app. | | `membership_not_found` | 404 | Not a member of this brand. Continue without a member. | | `external_transaction_id_conflict` | 409 | Two different receipts share an id. Fix the id. | | `invalid_fields` | 422 | Fix the listed fields. | | `invalid_token` | 401 | Get a new token, retry once. | | `insufficient_scope` | 403 | Ask the brand to add the scope to your key. | | `rate_limit_exceeded` | 429 | Wait `Retry-After` seconds. | Authentication errors have their own page: see [Authentication](/guides/authentication/#errors). New codes may be added. Handle unknown codes by their `error.type` and HTTP status. --- # Rate limits > How many calls you can make, the headers that tell you where you stand, and what to do at a limit. Source: https://developers.loyx.se/guides/rate-limits/ Limits protect the brand's members and keep the API fast for every till. They are counted **per API key**, in fixed one-minute windows. | What | Limit per minute | |---|---| | Token requests (`POST /v1/auth/token`) | 30 per key, and 60 per calling IP address | | Member lookups (`POST /v1/memberships/lookup`) | 300 | | Reads, per family (members, products, stores, rewards) | 1,200 each | | Writes, per family (sales, products, stores) | 600 each | A normal store with several registers uses a small part of these. If you need more, for example to load a large catalog, contact us. ## Headers Every response that counts against a limit tells you where you stand: | Header | Meaning | |---|---| | `RateLimit-Limit` | The limit for this window. | | `RateLimit-Remaining` | Calls left in this window. | | `RateLimit-Reset` | Seconds until the window resets. | | `Retry-After` | On a `429` only: seconds to wait before retrying. | ## When you hit a limit You get `429` with the standard [error shape](/guides/errors/): ```json { "error": { "type": "rate_limit_error", "code": "rate_limit_exceeded", "message": "Too many requests." }, "request_id": "..." } ``` Wait at least `Retry-After` seconds, then retry. Do not retry in a tight loop: it only extends the wait. The token endpoint fails safe: if it cannot check its limits it answers `503 token_endpoint_unavailable` rather than letting the request through. Retry with backoff. ## Good habits - Cache the access token for its whole life. - Look a member up once per sale, not per keystroke. - Watch `RateLimit-Remaining` and slow down before you reach zero. - Send sales from a queue at a steady pace. After an offline period, drain the queue gradually instead of all at once. - Read the [changelog](/changelog/): limits may be raised, and are never lowered without notice. --- # About preview pages > What "Preview" means, and how planned features reach the live API. Source: https://developers.loyx.se/preview/ **Preview: this feature is planned and not live. The shape may change. Do not build against it yet.** Pages in this section describe features we are building. They are here so you can plan your integration and tell us early if something does not fit your system. - **Not live.** None of these endpoints or events exist yet. Calls to them answer `404`. - **The shape may change.** Field names, paths and codes on these pages are our current design, not a contract. - **Live means in the API reference.** A feature is live when it appears in the [API reference](/api/) and the [changelog](/changelog/) announces it. The preview page then becomes a normal guide. What is planned: | Feature | What it gives you | |---|---| | [Joining at the till](/preview/join-at-till/) | Sign a customer up from the till, by app QR or by phone with SMS confirmation. | | [Reserve and use rewards](/preview/hold-commit-release/) | Hold a member's reward for one basket, then use it or give it back. | | [Basket pricing](/preview/basket-pricing/) | Member, VIP and staff prices for a basket, as discounts your till applies. | | [Returns](/preview/returns/) | Returns linked to the original sale by your receipt id, so points are reversed. | | [Tiers and perks](/preview/tiers-and-perks/) | Member levels with perks, on the card and in pricing. | | [Webhooks](/preview/webhooks/) | Signed, retried events for members, points, rewards and sales. | | [Vendor apps](/preview/vendor-apps/) | One registered app per till vendor, approved by each brand with its own scopes. | Questions or feedback on a preview: contact your LoyX partner contact. --- # Joining at the till > Preview: sign a customer up at the till by app QR, or by phone with SMS confirmation. Source: https://developers.loyx.se/preview/join-at-till/ **Preview: this feature is planned and not live. The shape may change. Do not build against it yet.** :::caution[Preview — not live, shape may change] This feature is planned. Nothing on this page can be called yet. ::: A customer who is not yet a member of the brand can join during the sale, in one of two ways. Neither asks the cashier to collect consent or personal details: the customer confirms on their own phone. ## Scan to join The customer already has the LoyX app and shows its QR code at a brand they have not joined. - Identify answers that the code belongs to a LoyX user who can join, instead of "not found". - One join call with the same code makes them a member at once. The code is used up. - The brand's welcome offer is granted by the normal join flow and can show on the card within seconds. ## Phone and SMS The customer gives a phone number. LoyX sends an SMS with a link. The customer opens it, signs in and accepts the terms on their own phone. ``` join (phone) ──► PENDING ── customer confirms on phone ──► member ACTIVE │ · held purchases credited │ · welcome offer granted ├─ not confirmed in about 30 days ──► EXPIRED, record deleted └─ cancelled by staff or customer ──► CANCELLED ``` - **The till never waits for the SMS.** It gets a `join_id` straight away and finishes the sale. - **Purchases while pending are held**, not lost. Put the `join_id` on the sale; it is credited when the customer confirms. - **No rewards while pending.** Rewards and the welcome offer arrive on confirmation. - **Marketing is off by default** for till sign-ups. The app asks for opt-in later. - Asking again for the same number returns the same pending sign-up. SMS resends are limited per number. ## Planned shape ``` POST /v1/joins { "context": { "store": { "external_store_id": "store12" } }, "method": "phone", "phone": "0701234567" } 201 { "result": "pending", "join": { "join_id": "...", "status": "pending", "expires_at": "...", "sms": "queued" } } ``` Expected answers include `member_exists` when the number already belongs to a member (switch to that member) and `join_disabled` when the brand does not allow till sign-up. ## Events `join.created`, `join.confirmed` (with the new member id), `join.expired`, `join.cancelled` and `member.joined`. See [Webhooks](/preview/webhooks/). --- # Reserve and use rewards > Preview: hold a member's reward for one basket, then commit it when paid or release it. Source: https://developers.loyx.se/preview/hold-commit-release/ **Preview: this feature is planned and not live. The shape may change. Do not build against it yet.** :::caution[Preview — not live, shape may change] This feature is planned. Nothing on this page can be called yet. ::: Using a reward at the till takes two steps, so a coupon cannot be used twice while payment is in progress, and is not lost when a payment fails. ``` hold ──► HELD ──► commit (paid) ──► COMMITTED (reward used) │ ├──► release (removed, voided, payment failed) ──► RELEASED (reward back) └──► time runs out ──► EXPIRED (reward back) ``` 1. **Hold.** When the cashier adds a reward, hold it for this basket. While held, it cannot be used anywhere else: not in the app, not at another till. The member's app shows it as reserved. 2. **Commit.** When the sale is paid, commit the hold with your receipt id. The reward is used. 3. **Release.** If the reward is removed, the sale is voided or the payment fails, release the hold. The reward is available again. ## Rules - **One hold per basket.** Your basket or cart id is the key. Holding again for the same basket replaces the set of rewards held. - **Holds expire.** Default: 15 minutes in shops, 4 hours in restaurants. The brand can adjust it, up to 24 hours. An expired hold gives the reward back. - **Late commit.** Committing an expired hold still works if the reward is still available. If it was used elsewhere in the meantime, the answer says so; the sale stands and the brand's policy decides. - **The sale can commit for you.** A sale that names its hold commits it, so a lost commit call does not lose the redemption. - **Committed is final.** To undo a used reward, record a [return](/preview/returns/) of the receipt. Release does not undo a commit. - **Pending members** (joined by phone, not yet confirmed) cannot hold rewards. - **No holds offline.** A till that is offline cannot reserve rewards. ## Planned shape ``` POST /v1/holds { context: { store, basket_id }, member_id, items: [{ reward_id }] } POST /v1/holds/{hold_id}/commit { context: { receipt_id } } POST /v1/holds/{hold_id}/release { reason: "item_removed" } ``` Expected refusal reasons include `held_elsewhere`, `hold_released`, `hold_committed`, `hold_expired` and `member_pending`, each with a short text that is safe to show the cashier. ## Events `reward.held`, `reward.redeemed`, `reward.released` and `hold.expired`. See [Webhooks](/preview/webhooks/). --- # Basket pricing > Preview: member, VIP and staff prices and usable rewards for a basket, returned as discounts. Source: https://developers.loyx.se/preview/basket-pricing/ **Preview: this feature is planned and not live. The shape may change. Do not build against it yet.** :::caution[Preview — not live, shape may change] This feature is planned. Nothing on this page can be called yet. ::: Send the basket, with or without a member. LoyX answers with the **price effects** that apply: member prices, VIP prices, staff prices, tier perks and rewards the member can use. LoyX returns **discounts to apply**, never a repriced basket. Your till applies them with its own discount engine, because it owns VAT and the fiscal receipt. ## What comes back | Effect | Meaning | |---|---| | `line_discount` | Take this amount off one line. Member, VIP and staff prices are always expressed this way. | | `basket_discount` | An amount off the whole basket, already split across the lines, so tills that must book discounts per line can do so. | | `free_item` | Make some units of a line free. | | `info` | Text for the cashier or the receipt. | Each effect says why it applies (`member_price`, `vip_price`, `staff_price`, `tier_perk`, `reward`, `offer`), carries a stable offer id and a short receipt text, and says whether it uses up a reward. A reward that is used up must be [held](/preview/hold-commit-release/) before you apply it. The answer also lists rewards the member could use but did not pick, and every presented reward that was refused, with a reason and a cashier text. ## Rules - Same input, same answer. Retrying is safe and cheap. - Price effects first (the best single price per line), then rewards. - LoyX never discounts more than the basket, and never discounts lines marked as gift cards, deposits, services or non-discountable. - Local rules apply by store country, for example no discounts on alcohol in Swedish stores. - Unknown effect types must be ignored. - It is not a points quote, and it never reserves anything. ## Planned shape ``` POST /v1/baskets/price { "context": { "store": { "external_store_id": "store12" }, "basket_id": "cart-991", "currency": "SEK" }, "member_id": "...", "lines": [ { "line_id": "1", "product": { "till_product_id": "SKU-1001" }, "quantity": { "value": 2, "unit": "ea" }, "unit_price_minor": 4500 } ] } ``` The answer carries an `evaluation_id` to echo on the hold and on the sale, and a `valid_until` time. --- # Returns > Preview: record a return linked to the original sale by your receipt id, so points are reversed. Source: https://developers.loyx.se/preview/returns/ **Preview: this feature is planned and not live. The shape may change. Do not build against it yet.** :::caution[Preview — not live, shape may change] This feature is planned. Nothing on this page can be called yet. ::: When goods come back, tell LoyX which receipt they came from. LoyX finds the original sale by **your own receipt id** (the `external_transaction_id` you sent with it) and reverses what that sale earned on the returned lines. ## Rules - **Link by your receipt id.** The original may be from another store of the same brand. - **The member comes from the original.** You do not have to identify the customer again. - **Partial and repeated returns work.** Each reverses only its own lines, net of their discounts, and never more than the original paid. - **Never send a negative sale.** Send a return instead. - **A return that arrives before its sale waits.** If the original is not in LoyX yet, the return is kept as "awaiting original" and linked when the sale arrives. It is not closed with nothing reversed. - **Returns without a reference** are stored but reverse nothing; the brand can review them. - **Points are reversed after the return**, like earning. Read the card or listen for the event. - **Used rewards stay used** by default. The brand can choose to restore them. - A whole-receipt cancellation is a return of every line. ## Planned shape ``` POST /v1/returns { "context": { "store": { "external_store_id": "store12" }, "receipt_id": "store12-reg3-000187", "occurred_at": "...", "currency": "SEK" }, "original": { "receipt_id": "store12-reg3-000123" }, "kind": "return", "lines": [ { "product": { "till_product_id": "SKU-1001" }, "quantity": { "value": 1, "unit": "ea" }, "refund_minor": 4500 } ] } ``` The answer says whether the return is `linked`, `awaiting_original` or `unlinked`. The return's own receipt id is its duplicate key, the same way sales work today. ## Events `return.recorded`, `return.linked` and `points.reversed`. See [Webhooks](/preview/webhooks/). --- # Tiers and perks > Preview: member levels with perks, shown on the card and applied in basket pricing. Source: https://developers.loyx.se/preview/tiers-and-perks/ **Preview: this feature is planned and not live. The shape may change. Do not build against it yet.** :::caution[Preview — not live, shape may change] This feature is planned. Nothing on this page can be called yet. ::: Brands will be able to give members levels, such as Silver and Gold, each with perks. ## What you will see - **On the member card:** the member's tier, with its code, name and rank, its perks as short texts, and how far the member is from the next tier. - **In basket pricing:** perks that are discounts come back as price effects with the reason `tier_perk`. See [Basket pricing](/preview/basket-pricing/). - **A tier list:** the brand's tier codes and names, for tills that keep their own customer groups in sync. ## Rules - Tier codes are stable. Names can change; codes do not. - Tiers are re-evaluated on a schedule, not on every sale. A return does not drop a tier on the spot. - A tier change is announced by event, so tills that mirror tiers can follow. ## Events `tier.reached` and `tier.dropped`, each with the new and the previous tier code. See [Webhooks](/preview/webhooks/). --- # Webhooks > Preview: signed, retried events about members, points, rewards and sales. Source: https://developers.loyx.se/preview/webhooks/ **Preview: this feature is planned and not live. The shape may change. Do not build against it yet.** :::caution[Preview — not live, shape may change] This feature is planned. Nothing on this page can be called yet. ::: Register an HTTPS endpoint and choose the events you want. LoyX sends each event as a signed `POST`, and retries until your endpoint answers `2xx`. ## Event shape Events are small. They carry ids and non-personal fields only. Fetch details with your token when you need them. ```json { "id": "evt_...", "type": "points.earned", "api_version": "v1", "created_at": "2026-11-20T10:15:04Z", "sequence": 42, "resource": { "type": "membership", "id": "..." }, "data": { "sale_id": "...", "receipt_id": "store12-reg3-000123", "points": 45, "balance_after": 310 } } ``` ## Planned events (about 36) | Group | Events | |---|---| | Joining | `join.created`, `join.confirmed`, `join.expired`, `join.cancelled` | | Members | `member.joined`, `member.updated`, `member.left`, `member.deleted`, `consent.changed` | | Points | `points.earned`, `points.reversed`, `points.adjusted`, `balance.changed`, `cycle.completed` | | Tiers | `tier.reached`, `tier.dropped` | | Rewards | `reward.granted`, `reward.held`, `reward.redeemed`, `reward.released`, `hold.expired`, `reward.restored`, `reward.expired`, `reward.revoked` | | Offers | `offer.published`, `offer.updated`, `offer.ended` | | Sales | `sale.recorded`, `sale.resolved`, `return.recorded`, `return.linked` | | Catalog | `product.created`, `store.updated` | | Access | `grant.approved`, `grant.revoked` | | Testing | `webhook.test` | `member.deleted` means the person asked to be erased. Delete any copy of their data you keep. ## Delivery - **Signed.** Each request carries an id, a timestamp and an HMAC-SHA256 signature made with your endpoint's secret. Verify it and reject requests older than 5 minutes. The exact header format is still being decided. - **Retried.** Anything but `2xx` is retried with growing gaps for about 3 days. Answer fast and do the work afterwards. - **At least once.** The same event can arrive twice: de-duplicate on its id. - **Not ordered.** Use `sequence` to drop stale updates for the same resource. - **Never dropped silently.** An endpoint that keeps failing is switched off and the brand and you are told. Missed events can be replayed, and an events list lets you catch up for 30 days. - **Secrets rotate without downtime:** during an overlap, both secrets sign. - HTTPS only. Private addresses and redirects are refused. --- # Vendor apps and brand approval > Preview: one app per till vendor, approved by each brand with the scopes it chooses. Source: https://developers.loyx.se/preview/vendor-apps/ **Preview: this feature is planned and not live. The shape may change. Do not build against it yet.** :::caution[Preview — not live, shape may change] This feature is planned. Today each brand creates an API key for you; see [Authentication](/guides/authentication/). ::: Today, each brand creates an API key and hands it to you. That works for one brand at a time. For a till vendor serving many brands, we are adding **apps**: ``` LoyX registers your app once ──► one client id and secret, the scopes you request │ each brand approves your app in the LoyX Portal (it sees the scopes in plain words, and may limit stores) = a grant │ token request with your app credentials + the brand ──► a token for that brand only ``` ## How it will work - **One app, many brands.** You keep one set of credentials. Each token is for one brand you are approved for. - **The brand decides.** The brand's owner approves your app and picks the scopes. They can limit it to some stores, and revoke it at any time. Revocation is immediate. - **Scopes in plain words.** For example "Find your members at the till and show their card" or "Send receipts and returns". - **Bundles** for common cases: full till checkout, a sales feed only, or the member card only. - **Testing** happens on a LoyX demo brand, not a separate sandbox. ## Events `grant.approved` and `grant.revoked` tell you when a brand approves or revokes your app. See [Webhooks](/preview/webhooks/). --- # Changelog > Every change to the Partners API, newest first. Source: https://developers.loyx.se/changelog/ We add fields and endpoints without a new version. We never remove or rename fields, or change the meaning of a value, inside `v1`. Anything breaking gets a new version and at least 12 months' notice. ## Unreleased - First public documentation of the Partners API `v1`: authentication, member lookup, member card, sales, products and stores. - Sales: `external.external_transaction_id` is the duplicate key. A retry with the same content returns `200` with the original transaction and `Idempotent-Replayed: true`; the same id with different content returns `409 external_transaction_id_conflict`. - Sales honour an optional `Idempotency-Key`: the same key with the same body replays the original (`200`); the same key with a different sale is `409 idempotency_key_reused`. - New: `GET /v1/memberships/{membership_id}/rewards` lists the member's usable rewards, optionally for one store. - Member lookup now returns `unit` and `cycle_length`. On a cashback program, `unit` carries `currency`, `minor_units` and `locale`. - Products: `external_product_id` on products; `POST /v1/products` upserts by it; new `POST /v1/products/bulk` (up to 100, `207` with a result per item, optional `Idempotency-Key`, also on `POST /v1/products`); unknown products on a sale line are created from the line. - Scopes on API keys: `members:read`, `sales:write`, `products:read`, `products:write`, `stores:read`, `stores:write`, `rewards:read`. - Preview pages added for planned features. They are not live. --- # Using these docs with AI tools > Plain Markdown versions of every page, plus llms.txt, for coding assistants. Source: https://developers.loyx.se/for-ai-tools/ Every page on this site has a plain Markdown twin. Add `.md` to the path, or use the **View as Markdown** link under the page title. | File | What it holds | |---|---| | [`/llms.txt`](/llms.txt) | An index of every page with a one-line summary, following [llmstxt.org](https://llmstxt.org/). | | [`/llms-full.txt`](/llms-full.txt) | Every guide, every preview page and the API reference in one file. | | [`/api.md`](/api.md) | The API reference as Markdown. | | [`/openapi/partners-v1.json`](/openapi/partners-v1.json) | The OpenAPI 3.1 spec. Generate a client from it. | To give a coding assistant the full picture, paste `https://developers.loyx.se/llms-full.txt` into its context, or point it at `llms.txt` and let it fetch what it needs. ## Rules worth repeating to your assistant - Money is an integer in minor units with a currency. Never floats. - Send your receipt id as `external.external_transaction_id` on every sale. - Points are not in the sale response. They are calculated afterwards. - Send scanned QR text unchanged. - Pages under **Preview** are not live. Do not generate code that calls them. The spec and these pages are built from the same source as the API, so they match what the server does. --- # LoyX Partners API reference B2B API for partner integrations (POS systems, backend services) Base URL: `https://api.loyx.se/partners`. Every path below is relative to it. OpenAPI 3.1.0, API version 1.0.0. Machine-readable spec: https://developers.loyx.se/openapi/partners-v1.json Authentication: send `Authorization: Bearer ` on every call except `POST /v1/auth/token` and `GET /v1/`. See the authentication guide. ## GET /v1/ **API Information** (Info) Get API version information. ``documentation`` points at the live Swagger UI where it is served (local and development, ``docs_urls_for``) and at the public developer docs site (``PARTNERS_DOCS_URL``) everywhere else, never at a link that 404s. Responses: - `200`: Successful Response. Body: object. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## POST /v1/auth/token **Issue an access token (OAuth2 Client Credentials)** (Auth) Exchange `client_id` and `client_secret` (via HTTP Basic) for an opaque access token valid for one hour (`expires_in`). Use it as `Authorization: Bearer ` against every other Partners endpoint, and fetch a new one on a 401. The token carries the API key's scopes (`scope`). Limited to 30 calls a minute per API key and 60 per caller IP. Parameters: - `authorization` (header, string (nullable)): HTTP Basic header: `Basic base64(client_id:client_secret)`. Request body (`application/x-www-form-urlencoded`, Body_issue_token_v1_auth_token_post): - `grant_type` (string, required): OAuth2 grant type — must be `client_credentials`. Responses: - `200`: The issued access token, its lifetime and its scopes. Body: TokenResponse. - `400`: Unsupported `grant_type`. Body: ErrorResponse. - `401`: Missing or invalid client credentials, or a revoked key. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: Token requests over the limit; see `Retry-After`. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. - `503`: The rate limiter is unreachable, so issuance is refused. Body: ErrorResponse. ## POST /v1/memberships/lookup **Look up a membership by identifier** (Memberships) Find a single membership in the authenticated company by one of six identifiers. The request body is `{identifier, value}`. `identifier` must be one of `membership_id`, `user_id`, `qr_code`, `mobile_number`, `email`, or `national_id`. `membership_id` and `user_id` match top-level UUID fields; `mobile_number`, `email` and `national_id` match entries in `required_member_fields`. The value format is validated per identifier type (UUID / E.164 / email / string). **Scanning a member's QR code:** use `qr_code` and send the scanned string exactly as read, with no client-side parsing. Both code generations are accepted — a rotating `lx1_` token (current) and a bare member UUID (legacy) — and the API tells them apart itself, so no client change is needed when the legacy form is retired. A rotating token is short-lived: if it has expired or been superseded the response is `404 qr_code_not_resolvable`, which means *ask the member to refresh their code*, as distinct from `404 membership_not_found`, which means the person is not an active member of your company. `loyalty_program_type` is `points`, `stamps`, or `null` — for a member on no resolvable program, or on a unit whose presentation has no value in this contract yet. Request body (`application/json`, MembershipLookupRequest): - `identifier` (string (one of `membership_id`, `user_id`, `qr_code`, `mobile_number`, `email`, `national_id`), required): Which field to look up by. One of ``membership_id``, ``user_id``, ``qr_code``, ``mobile_number``, ``email``, ``national_id``. - `value` (string, required): Identifier value. Format depends on ``identifier``. For ``qr_code``, pass the scanned string unchanged — the API tells the two QR generations apart on its own. Responses: - `200`: The matching membership, in its polymorphic detail shape. Body: MembershipDetailResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: No membership matches the provided identifier (`membership_not_found`), or the scanned QR token is expired or invalid (`qr_code_not_resolvable`). Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. - `503`: `qr_code` only — the QR token store is temporarily unreachable. Retry; never treat this as an expired code. Body: ErrorResponse. ## GET /v1/memberships/{membership_id}/loyalty **Get a membership's loyalty state** (Memberships) Unit-agnostic loyalty read model for one membership: `balance`, `unit` (label + presentation), `program`, the current `cycle`, and `punches` (populated only when `unit.presentation` is `card`; `null` otherwise). Parameters: - `membership_id` (path, string, required) Responses: - `200`: The membership's current loyalty state. Body: MembershipLoyaltyResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: No membership with the given id in the authenticated company. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## GET /v1/memberships/{membership_id}/rewards **List a member's redeemable rewards** (Rewards) The rewards the member can redeem now, for the member card at the till: active rewards only, none from a paused campaign, and, when the store is given (`store_id` or `external_store_id`, not both), none that do not run at that store. Cursor-paginated, newest first. Read-only. Parameters: - `membership_id` (path, string, required): The membership's internal UUID. - `store_id` (query, string (nullable)): LoyX id of the store the till is in. - `external_store_id` (query, string (nullable)): The till's own code for the store, as registered on the LoyX store. - `limit` (query, integer): Maximum rewards to return (1-200). - `cursor` (query, string (nullable)): Opaque cursor from the previous page's `next_cursor`. Responses: - `200`: Cursor-paginated list of redeemable rewards. Body: RewardListResponse. - `400`: `store_reference_ambiguous` (both store parameters sent) or `invalid_cursor`. Body: ErrorResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Membership or store not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## GET /v1/products **List products** (Products) List products with offset pagination. Returns an empty array if no products are defined for the company. Parameters: - `limit` (query, integer): Maximum number of products to return (1–200). - `offset` (query, integer): Number of products to skip. Responses: - `200`: Paginated list of products. Body: ProductListResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## POST /v1/products **Create or upsert a product** (Products) Create a new product in the authenticated company's catalog. Fields such as company logo, display name, and category are resolved server-side from the authenticated company — clients never supply them. **Upsert on `external_product_id`.** When the body carries an `external_product_id` that a product of this company already has, that product is updated instead and the response is `200` (a new product is `201`). On update only the fields you send are changed (omitted optional fields keep their stored value), `stores` replaces the assortment, and `image_link` is ignored (it is set at create only). A soft-deleted product with the key is restored. Concurrent upserts of one key converge on one product. Without `external_product_id` every call creates a new product. Parameters: - `Idempotency-Key` (header, string (nullable)): Optional. When provided, retrying with the same key returns the original result. Request body (`application/json`, ProductCreateRequest): - `brand` (string (nullable)): Manufacturer or brand name. - `categories` (array of string): Category labels defined on the company. Must match existing categories. - `description` (string (nullable)): Long-form product description. - `external_product_id` (string (nullable)): Your own product key (till/POS/ERP article id). Unique per company. When set, `POST /products` upserts on it: an existing product with this key is updated instead of a duplicate being created. Sale lines that carry an unknown key create a minimal product with it. - `identifiers` (array of IdentifierInput (product)): Typed identifiers (gtin/ean13/ean8/sku/pos). Each (type, value) pair must be unique per company across non-deleted products. - `type` (string, required): Identifier type: gtin, ean13, ean8, sku, or pos. - `value` (string, required) - `image_link` (string (nullable)): Public URL of the product's primary image. - `is_loyalty_program_eligible` (boolean, default `true`): When true, purchases of this product accrue loyalty points or stamps. - `loyx_app_active` (boolean, default `true`): When true, the product is visible in the consumer LoyX app. - `loyx_business_app_active` (boolean, default `true`): When true, the product is visible in the LoyX Business (staff) app. - `name` (string, required): Display name shown in the mobile app and digital receipts. - `page_url` (string (nullable)): Public URL of the product's web page. - `price` (PriceInput (product), required): Base price in minor units paired with a currency code. - `currency` (string, default `SEK`): ISO 4217 currency code - `value` (integer, required): Amount in minor units (e.g. öre, cents) - `stores` (array of ProductStoreInput, required): Stores that carry this product — at least one. Each entry may set a per-store price override. - `price` (PriceInput (product) (nullable)): Optional per-store price override. When omitted, the store uses the product's base price. Currency must match the base price. - `currency` (string, default `SEK`): ISO 4217 currency code - `value` (integer, required): Amount in minor units (e.g. öre, cents) - `store_id` (string, required): Internal UUID of a store that carries this product. - `unit` (string, default `ea`): Unit the product is sold in (ea, kg, g, l, ml, m, pack). Defaults to `ea` (each). Responses: - `200`: A product with this external_product_id existed and was updated. - `201`: A new product was created. Body: ProductResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## POST /v1/products/bulk **Bulk upsert products** (Products) Create or update up to 100 products in one call, each matched on its required `external_product_id` with the same rules as `POST /products`. Items are processed independently and in order: a failing item does not roll back the others, and the response carries one result per item (`created`, `updated` or `failed` with the error). The call is safe to retry — resend the whole request or only the failed items. A key repeated within one request fails from its second occurrence (`duplicate_in_request`). Always `207 Multi-Status`, even when every item succeeded: read each item's `status`. With an `Idempotency-Key`, a resend of the same body within 24 h returns the first result without running again; the same key with a different body is `409 idempotency_key_reused`, and a resend while the first call is still running is `409 idempotency_request_in_progress`. Parameters: - `Idempotency-Key` (header, string (nullable)): Optional. A resend with the same key and body within 24 h returns the original result instead of running again. Request body (`application/json`, ProductBulkUpsertRequest): - `products` (array of ProductBulkUpsertItem, required): 1–100 products. Each is upserted independently; one failing item does not roll back the others. A key may appear only once per request. - `brand` (string (nullable)): Manufacturer or brand name. - `categories` (array of string): Category labels defined on the company. Must match existing categories. - `description` (string (nullable)): Long-form product description. - `external_product_id` (string, required): Your product key — the upsert match key. Required in a bulk call. - `identifiers` (array of IdentifierInput (product)): Typed identifiers (gtin/ean13/ean8/sku/pos). Each (type, value) pair must be unique per company across non-deleted products. - `type` (string, required): Identifier type: gtin, ean13, ean8, sku, or pos. - `value` (string, required) - `image_link` (string (nullable)): Public URL of the product's primary image. - `is_loyalty_program_eligible` (boolean, default `true`): When true, purchases of this product accrue loyalty points or stamps. - `loyx_app_active` (boolean, default `true`): When true, the product is visible in the consumer LoyX app. - `loyx_business_app_active` (boolean, default `true`): When true, the product is visible in the LoyX Business (staff) app. - `name` (string, required): Display name shown in the mobile app and digital receipts. - `page_url` (string (nullable)): Public URL of the product's web page. - `price` (PriceInput (product), required): Base price in minor units paired with a currency code. - `currency` (string, default `SEK`): ISO 4217 currency code - `value` (integer, required): Amount in minor units (e.g. öre, cents) - `stores` (array of ProductStoreInput, required): Stores that carry this product — at least one. Each entry may set a per-store price override. - `price` (PriceInput (product) (nullable)): Optional per-store price override. When omitted, the store uses the product's base price. Currency must match the base price. - `store_id` (string, required): Internal UUID of a store that carries this product. - `unit` (string, default `ea`): Unit the product is sold in (ea, kg, g, l, ml, m, pack). Defaults to `ea` (each). Responses: - `207`: One result per item, in request order, plus counts. Body: ProductBulkUpsertResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `409`: Idempotency-Key reused with another body, or still in progress. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## GET /v1/products/{product_id} **Get product by ID** (Products) Retrieve a single product by its internal UUID. Parameters: - `product_id` (path, string, required): The product's internal UUID. Responses: - `200`: The requested product. Body: ProductResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Product not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## PATCH /v1/products/{product_id} **Update product by ID** (Products) Partially update a product. Only include the fields you want to change. Omitted fields are left unchanged. Set a field to `null` to clear it. Parameters: - `product_id` (path, string, required): The product's internal UUID. - `Idempotency-Key` (header, string (nullable)): Optional. When provided, retrying with the same key returns the original result. Request body (`application/json`, ProductUpdateRequest): - `brand` (string (nullable)): Updated manufacturer or brand name. - `categories` (array of string (nullable)): Full replacement of the category list. - `description` (string (nullable)): Updated long-form description. - `external_product_id` (string (nullable)): Set or change your product key. Cannot be cleared. 409 `external_product_id_conflict` when another product of the company (including a deleted one) already has it. - `identifiers` (array of IdentifierInput (product) (nullable)): Full replacement of the typed identifier list (gtin/ean13/ean8/sku/pos). Send `[]` to clear all identifiers. - `type` (string, required): Identifier type: gtin, ean13, ean8, sku, or pos. - `value` (string, required) - `is_loyalty_program_eligible` (boolean (nullable)): Whether purchases of this product accrue loyalty points or stamps. - `loyx_app_active` (boolean (nullable)): Visibility toggle for the consumer LoyX app. - `loyx_business_app_active` (boolean (nullable)): Visibility toggle for the LoyX Business (staff) app. - `name` (string (nullable)): Updated display name. - `page_url` (string (nullable)): Updated public URL of the product page. - `price` (PriceInput (product) (nullable)): Updated base price. - `currency` (string, default `SEK`): ISO 4217 currency code - `value` (integer, required): Amount in minor units (e.g. öre, cents) - `stores` (array of ProductStoreInput (nullable)): Full replacement of the store assortment. When sent, stores not listed are delisted and new stores are added. Omit to leave the assortment unchanged. - `price` (PriceInput (product) (nullable)): Optional per-store price override. When omitted, the store uses the product's base price. Currency must match the base price. - `currency` (string, default `SEK`): ISO 4217 currency code - `value` (integer, required): Amount in minor units (e.g. öre, cents) - `store_id` (string, required): Internal UUID of a store that carries this product. - `unit` (string (nullable)): Updated unit (ea, kg, g, l, ml, m, pack). Responses: - `200`: The updated product. Body: ProductResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Product not found. Body: ErrorResponse. - `409`: Another product already has this external_product_id. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## DELETE /v1/products/{product_id} **Delete product by ID** (Products) Soft-delete a product. The product is marked as deleted but not permanently removed. Parameters: - `product_id` (path, string, required): The product's internal UUID. Responses: - `204`: Product deleted successfully. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Product not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## GET /v1/products/{product_id}/stores **List stores carrying a product** (Products) List the stores whose assortment includes this product, with the per-store price override (when set) and the effective price. Parameters: - `product_id` (path, string, required): The product's internal UUID. Responses: - `200`: Stores carrying the product. Body: ProductStoresListResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Product not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## GET /v1/stores **List stores** (Stores) List stores with offset pagination. Filter by status and/or type to narrow results. Parameters: - `limit` (query, integer): Maximum number of stores to return (1–200). - `offset` (query, integer): Number of stores to skip. - `status` (query, string (nullable)): Filter by store status (e.g. `active`, `inactive`). - `type` (query, string (nullable)): Filter by store type (e.g. `physical`, `online`, `warehouse`). Responses: - `200`: Paginated list of stores. Body: StoreListResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## POST /v1/stores **Create a store** (Stores) Create a new store for the authenticated company. Parameters: - `Idempotency-Key` (header, string (nullable)): Optional. When provided, retrying with the same key returns the original result. Request body (`application/json`, StoreCreateRequest): - `address` (AddressInput (nullable)) - `city` (string, required) - `country` (string, required) - `postal_code` (string, required) - `region` (string (nullable)) - `street1` (string, required) - `street2` (string (nullable)) - `contact` (StoreContactInput (nullable)) - `email` (string (nullable)) - `phone` (string (nullable)) - `website` (string (nullable)) - `external_ids` (object) - `external_store_id` (string, required) - `geo` (GeoLocationInput (nullable)) - `latitude` (number, required) - `longitude` (number, required) - `icon` (StoreMediaInput (nullable)) - `content_type` (string, default `image/png`) - `url` (string, required) - `logo` (StoreMediaInput (nullable)) - `content_type` (string, default `image/png`) - `url` (string, required) - `name` (string, required) - `org_number` (string (nullable)) - `status` (string, default `active`) - `tags` (array of string) - `timezone` (string, required) - `type` (string, default `physical`) - `vat_number` (string (nullable)) Responses: - `201`: The created store. Body: StoreResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `409`: A store with this external ID already exists. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## GET /v1/stores/external/{external_store_id} **Get store by external ID** (Stores) Retrieve a single store by the company's own external identifier (e.g. POS code). Parameters: - `external_store_id` (path, string, required): The company's external identifier for the store. Responses: - `200`: The requested store. Body: StoreResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Store not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## PATCH /v1/stores/external/{external_store_id} **Update store by external ID** (Stores) Partially update a store addressed by the company's own external identifier. Same semantics as `PATCH /stores/{store_id}`. Parameters: - `external_store_id` (path, string, required): The company's external identifier for the store. - `Idempotency-Key` (header, string (nullable)): Optional. When provided, retrying with the same key returns the original result. Request body (`application/json`, StoreUpdateRequest): - `address` (AddressInput (nullable)) - `city` (string, required) - `country` (string, required) - `postal_code` (string, required) - `region` (string (nullable)) - `street1` (string, required) - `street2` (string (nullable)) - `contact` (StoreContactInput (nullable)) - `email` (string (nullable)) - `phone` (string (nullable)) - `website` (string (nullable)) - `external_ids` (object (nullable)) - `external_store_id` (string (nullable)) - `geo` (GeoLocationInput (nullable)) - `latitude` (number, required) - `longitude` (number, required) - `icon` (StoreMediaInput (nullable)) - `content_type` (string, default `image/png`) - `url` (string, required) - `logo` (StoreMediaInput (nullable)) - `content_type` (string, default `image/png`) - `url` (string, required) - `name` (string (nullable)) - `org_number` (string (nullable)) - `status` (string (nullable)) - `tags` (array of string (nullable)) - `timezone` (string (nullable)) - `type` (string (nullable)) - `vat_number` (string (nullable)) Responses: - `200`: The updated store. Body: StoreResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Store not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## DELETE /v1/stores/external/{external_store_id} **Delete store by external ID** (Stores) Soft-delete a store addressed by the company's own external identifier. Parameters: - `external_store_id` (path, string, required): The company's external identifier for the store. Responses: - `204`: Store deleted successfully. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Store not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## GET /v1/stores/{store_id} **Get store by ID** (Stores) Retrieve a single store by its internal UUID. Parameters: - `store_id` (path, string, required): The store's internal UUID. Responses: - `200`: The requested store. Body: StoreResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Store not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## PATCH /v1/stores/{store_id} **Update store by ID** (Stores) Partially update a store. Only include the fields you want to change. Omitted fields are left unchanged. Set a field to `null` to clear it. Parameters: - `store_id` (path, string, required): The store's internal UUID. - `Idempotency-Key` (header, string (nullable)): Optional. When provided, retrying with the same key returns the original result. Request body (`application/json`, StoreUpdateRequest): - `address` (AddressInput (nullable)) - `city` (string, required) - `country` (string, required) - `postal_code` (string, required) - `region` (string (nullable)) - `street1` (string, required) - `street2` (string (nullable)) - `contact` (StoreContactInput (nullable)) - `email` (string (nullable)) - `phone` (string (nullable)) - `website` (string (nullable)) - `external_ids` (object (nullable)) - `external_store_id` (string (nullable)) - `geo` (GeoLocationInput (nullable)) - `latitude` (number, required) - `longitude` (number, required) - `icon` (StoreMediaInput (nullable)) - `content_type` (string, default `image/png`) - `url` (string, required) - `logo` (StoreMediaInput (nullable)) - `content_type` (string, default `image/png`) - `url` (string, required) - `name` (string (nullable)) - `org_number` (string (nullable)) - `status` (string (nullable)) - `tags` (array of string (nullable)) - `timezone` (string (nullable)) - `type` (string (nullable)) - `vat_number` (string (nullable)) Responses: - `200`: The updated store. Body: StoreResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Store not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## DELETE /v1/stores/{store_id} **Delete store by ID** (Stores) Soft-delete a store. The store is marked as deleted but not permanently removed. Parameters: - `store_id` (path, string, required): The store's internal UUID. Responses: - `204`: Store deleted successfully. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Store not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## GET /v1/stores/{store_id}/products **List a store's products** (Store Products) List the products carried at a store with cursor pagination. Each item includes the per-store effective price. Pass `next_cursor` from the previous response as `cursor` for the next page. Parameters: - `store_id` (path, string, required): The store's internal UUID. - `limit` (query, integer): Maximum number of products to return. - `cursor` (query, string (nullable)): Opaque pagination token from a previous response. Responses: - `200`: Paginated list of the store's products. Body: StoreProductListResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Store not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## GET /v1/transactions **List transactions** (Transactions) List transactions for the authenticated company with offset pagination. Filter by status to narrow results. Returns an empty array if no transactions match. Parameters: - `limit` (query, integer): Maximum number of transactions to return (1–200). - `offset` (query, integer): Number of transactions to skip. - `status` (query, string (nullable)): Filter by transaction status (e.g. `pending`, `resolved`). Responses: - `200`: Paginated list of transactions. Body: TransactionListResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## POST /v1/transactions **Create a transaction** (Transactions) Create a new transaction for the authenticated company. Line totals and basket totals are derived server-side from the submitted items; client-sent totals are ignored. **Duplicates.** Send the till's own id as `external.external_transaction_id` on every sale; an `Idempotency-Key` header is optional and honoured as well. Posting again under the same id or key with the same content (a network retry) books nothing new and answers `200` with the original transaction and the header `Idempotent-Replayed: true`. The same id with different content answers `409` `external_transaction_id_conflict`; a key reused for a different sale answers `409` `idempotency_key_reused`. Content means the type, currency, `external` fields and the lines' and discounts' values; `member` and `metadata` are not compared. Parameters: - `Idempotency-Key` (header, string (nullable)): Optional. Retrying with the same key returns the original transaction (`200`, `Idempotent-Replayed: true`); the same key with a different body is `409`. Request body (`application/json`, TransactionCreateRequest): - `country_code` (string, default `SE`) - `currency` (string, default `SEK`) - `discounts` (array of TransactionDiscountInput) - `amount` (PriceInput (transaction), required) - `currency` (string, default `SEK`) - `value` (integer, required) - `description` (string, default ``) - `personal_offer_id` (string (nullable)): Stored as the transaction's `offer_id`: the v2 Offer this discount came from, for sale attribution only. Not an entitlement id — entitlements are not redeemed on this surface. - `type` (string, required) - `external` (ExternalFieldsInput, required) - `cashier_id` (string (nullable)) - `cashier_name` (string (nullable)) - `control_unit_code` (string (nullable)) - `external_store_id` (string (nullable)) - `external_transaction_id` (string (nullable)) - `pos_serial` (string (nullable)) - `pos_system` (string (nullable)) - `purchased_at` (string (nullable)) - `receipt_number` (string (nullable)) - `items` (array of ItemInput) - `description` (string (nullable)) - `discounts` (array of DiscountInput) - `amount` (PriceInput (transaction), required) - `description` (string, default ``) - `personal_offer_id` (string (nullable)): Stored as the transaction's `offer_id`: the v2 Offer this discount came from, for sale attribution only. Not an entitlement id — entitlements are not redeemed on this surface. - `type` (string, required) - `external_product_id` (string (nullable)) - `identifiers` (array of IdentifierInput (transaction)) - `type` (string, required) - `value` (string, required) - `loyalty_eligible` (boolean, default `true`) - `product_id` (string (nullable)) - `product_name` (string (nullable)) - `quantity` (QuantityInput, required) - `unit` (string, default `ea`) - `value` (integer, required) - `sequence_number` (integer, default `0`) - `tax_rate` (integer, default `0`) - `unit_price` (PriceInput (transaction), required) - `currency` (string, default `SEK`) - `value` (integer, required) - `locale` (string, default `sv-SE`) - `member` (array of MemberIdentifierInput) - `identifier` (string, required) - `value` (string, required) - `metadata` (object) - `origin` (string, default `pos`) - `store_id` (string (nullable)) - `totals` (TransactionTotalsInput (nullable)): The `sale` shape — send instead of `items` when the POS knows only what the member paid. Mutually exclusive with `items`. - `currency` (string (nullable)): ISO 4217 code. Defaults to the transaction currency. - `paid_minor` (integer, required): What the member paid, in minor units (öre). Use when the POS has no line items; the API records one synthetic, non-eligible line so amount-based programs can earn. - `transaction_type` (string, default `purchase`) - `user_id` (string (nullable)) Responses: - `200`: Replay: this `external_transaction_id` was already booked with the same content. The body is the original transaction; the response carries `Idempotent-Replayed: true`. - `201`: The created transaction, including computed totals and loyalty outcome. Body: TransactionResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `409`: `external_transaction_id_conflict`: this `external_transaction_id` is already booked with different content; `idempotency_key_reused`: this `Idempotency-Key` was used for a different sale. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## GET /v1/transactions/{transaction_id} **Get transaction detail** (Transactions) Retrieve a single transaction by its internal UUID. Parameters: - `transaction_id` (path, string, required): The transaction's internal UUID. Responses: - `200`: The requested transaction. Body: TransactionResponse. - `401`: `missing_token`, `invalid_authorization_header` or `invalid_token`: get a new access token and retry once. Body: ErrorResponse. - `403`: `insufficient_scope`: the API key lacks the scope this route needs. Body: ErrorResponse. - `404`: Transaction not found. Body: ErrorResponse. - `422`: Validation Error. Body: ErrorResponse. - `429`: `rate_limit_exceeded`: wait `Retry-After` seconds. Body: ErrorResponse. - `500`: `internal_server_error` or `database_error` (type `internal_error`): our fault. Retry with backoff; quote `request_id`. Body: ErrorResponse. ## Schemas ### AddressInput Nordic-compatible address input. - `city` (string, required) - `country` (string, required) - `postal_code` (string, required) - `region` (string (nullable)) - `street1` (string, required) - `street2` (string (nullable)) ### AddressResponse Address in response. - `city` (string, required) - `country` (string, required) - `postal_code` (string, required) - `region` (string (nullable)) - `street1` (string, required) - `street2` (string (nullable)) ### Body_issue_token_v1_auth_token_post - `grant_type` (string, required): OAuth2 grant type — must be `client_credentials`. ### BulkItemError Why one bulk item was not written. - `code` (string, required): Machine-readable error code, as on single-item calls. - `message` (string, required): Human-readable explanation; do not parse it. - `param` (string (nullable)): The offending field, prefixed with the item's position (`products..`). ### CursorPaginationMeta Pagination metadata for cursor-based list responses. - `has_more` (boolean, required): Whether more items exist - `limit` (integer, required): Maximum items per page - `next_cursor` (string (nullable)): Opaque cursor token for the next page ### DiscountInput Per-item discount in a create request. - `amount` (PriceInput (transaction), required) - `description` (string, default ``) - `personal_offer_id` (string (nullable)): Stored as the transaction's `offer_id`: the v2 Offer this discount came from, for sale attribution only. Not an entitlement id — entitlements are not redeemed on this surface. - `type` (string, required) ### DiscountResponse Discount in response (line-level or basket-level). - `amount` (PriceSchema, required) - `description` (string, default ``) - `personal_offer_id` (string (nullable)): The transaction's `offer_id`: the v2 Offer the discount came from, echoed under this surface's field name. - `type` (string, required) ### ErrorDetail Error detail structure (Stripe-like format). - `code` (string, required): Machine-readable error code - `details` (array of FieldErrorDetail (nullable)): On `invalid_fields` (422) only: one entry per failing field - `doc_url` (string (nullable)): Link to the errors guide - `message` (string, required): Human-readable error message - `param` (string (nullable)): Parameter that caused the error - `type` (string, required): Error type category ### ErrorResponse Standard error response format. - `error` (ErrorDetail, required) - `request_id` (string (nullable)): Request ID for support ### ExternalFieldsInput External POS fields — all optional, stored as-received. - `cashier_id` (string (nullable)) - `cashier_name` (string (nullable)) - `control_unit_code` (string (nullable)) - `external_store_id` (string (nullable)) - `external_transaction_id` (string (nullable)) - `pos_serial` (string (nullable)) - `pos_system` (string (nullable)) - `purchased_at` (string (nullable)) - `receipt_number` (string (nullable)) ### FieldErrorDetail One failing field of a validation error. - `message` (string, required): Why the value was refused - `param` (string, required): Dotted path of the field, e.g. `items.0.unit_price.value` ### GeoLocationInput GPS coordinate input. - `latitude` (number, required) - `longitude` (number, required) ### GeoLocationResponse Geo location in response. - `latitude` (number, required) - `longitude` (number, required) ### IdentifierInput-Output Product identifier (gtin, sku, etc.). - `type` (string, required) - `value` (string, required) ### IdentifierResponse Typed product identifier in API responses. - `type` (string, required) - `value` (string, required) ### ItemInput Line item in a transaction create request. total_discount and total_amount are computed by the domain model from unit_price, quantity, and discounts — not accepted in input. - `description` (string (nullable)) - `discounts` (array of DiscountInput) - `external_product_id` (string (nullable)) - `identifiers` (array of IdentifierInput (transaction)) - `loyalty_eligible` (boolean, default `true`) - `product_id` (string (nullable)) - `product_name` (string (nullable)) - `quantity` (QuantityInput, required) - `sequence_number` (integer, default `0`) - `tax_rate` (integer, default `0`) - `unit_price` (PriceInput (transaction), required) ### ItemResponse Line item in a transaction response — includes computed fields. - `description` (string (nullable)) - `discounts` (array of DiscountResponse) - `external_product_id` (string (nullable)) - `identifiers` (array of IdentifierInput-Output) - `loyalty_eligible` (boolean, required) - `product_id` (string (nullable)) - `product_name` (string (nullable)) - `quantity` (QuantityInput, required) - `sequence_number` (integer, required) - `tax_rate` (integer, required) - `total_amount` (PriceSchema, required) - `total_discount` (PriceSchema, required) - `unit_price` (PriceSchema, required) ### LoyaltyCycleResponse The membership's current loyalty cycle. - `length` (integer (nullable), required): Cycle length in the program's unit, or null when unbounded. - `progress_pct` (integer (nullable), required): How full the current cycle is, 0-100, or null when the cycle is unbounded. - `seq` (integer, required): Current cycle sequence number. - `started_at` (string, required): When the current cycle started (UTC). ### LoyaltyProgramResponse The loyalty program backing this membership. - `id` (string, required): Loyalty program id. - `name` (string, required): Loyalty program name. ### LoyaltyResponse Loyalty block in responses. Pre-populated with empty keys, filled by the loyalty engine after processing. - `cycle` (integer (nullable)) - `exchange_rate_used` (object (nullable)) - `points_deducted` (integer (nullable)) - `points_earned` (integer, default `0`) - `post_balance` (integer, default `0`) - `pre_balance` (integer, default `0`) - `processed_at` (string (nullable)) - `refund_processed_at` (string (nullable)) - `refund_type` (string (nullable)) - `stamps_earned` (integer, default `0`) ### LoyaltyUnitResponse The program's unit — what the balance number counts and how it renders. For a `currency` unit (cashback) the balance is money in minor units, so the unit also says which currency and how to format it, the same `minor_units` + `locale` pair every price on this API carries. All three are null for `counter` and `card`, whose balance is a plain count. - `currency` (string (nullable)): ISO 4217 code of a `currency` unit; null for `counter` and `card`. - `label` (string, required): Human label for the unit (e.g. `points`, `stamps`). - `locale` (string (nullable)): RFC 5646 locale to format a `currency` balance (e.g. `sv-SE`); null otherwise. - `minor_units` (integer (nullable)): Divisor from the balance to major units (e.g. 100 for SEK) for a `currency` unit; null otherwise. - `presentation` (string, required): How the unit is presented: `counter`, `card`, or `currency`. ### MemberIdentifierInput Member identifier (user_id, membership_id, mobile_number, email, social_security_number). - `identifier` (string, required) - `value` (string, required) ### MembershipDetailResponse Detail response for a membership — flat across loyalty program types. ``balance`` is the ledger's projection, unconditional: points balance for a points program, stamp count in the current cycle for a stamps program. ``stamps_dates`` is populated only for a stamp card. - `balance` (integer, required): Program-agnostic primary value: points balance for `points`, stamp count in the current cycle for `stamps`. - `celebration` (boolean, required): Whether a reward-earned UI should be shown - `created_at` (string, required) - `cycle` (integer, required): Current cycle number (starts at 1) - `cycle_length` (integer (nullable)): Size of the current cycle in the program's unit (e.g. 10 for a 10-stamp card), so a till can show `balance` of `cycle_length`. Null when the cycle is unbounded or there is no program. - `full_name` (string, required): Member's full name - `loyalty_program_type` (string (nullable), required): `points` or `stamps`, derived from the loyalty program's unit presentation — a card is `stamps`, a counter is `points`. Null when the member is on no resolvable program (not enrolled, or the program is gone), or when the unit's presentation has no value in this contract yet; never an error. - `membership_id` (string, required): Membership id - `stamps_dates` (array of string (nullable)): Timestamps of stamps in the current cycle; null for points programs. - `status` (MembershipStatus, required): Membership status - `unit` (LoyaltyUnitResponse (nullable)): What `balance` counts and how to show it (label, presentation, and for a `currency` unit the currency, `minor_units` and `locale`). Null when the member is on no resolvable program. - `updated_at` (string, required) - `user_id` (string, required): Owning user id ### MembershipLookupRequest Body for ``POST /memberships/lookup`` — discriminator + value. ``membership_id`` and ``user_id`` match top-level Membership fields. ``qr_code`` is the raw string scanned off a member's QR code, in either generation: a ``lx1_`` rotating token (v2) or a bare ``user_id`` UUID (legacy v1). ``mobile_number``, ``email``, and ``national_id`` match entries in ``required_member_fields``. - `identifier` (string (one of `membership_id`, `user_id`, `qr_code`, `mobile_number`, `email`, `national_id`), required): Which field to look up by. One of ``membership_id``, ``user_id``, ``qr_code``, ``mobile_number``, ``email``, ``national_id``. - `value` (string, required): Identifier value. Format depends on ``identifier``. For ``qr_code``, pass the scanned string unchanged — the API tells the two QR generations apart on its own. ### MembershipLoyaltyResponse Unit-agnostic loyalty state for one membership. ``punches`` is populated only when ``unit.presentation`` is `card` — for a `counter` or `currency` program it is `null`, never an empty list, since an empty list would mean "a card with no punches yet" rather than "not a card". - `balance` (integer, required): Current balance in the program's unit. - `cycle` (LoyaltyCycleResponse, required): The membership's current cycle. - `program` (LoyaltyProgramResponse, required) - `punches` (array of string (nullable), required): Punch moments for a `card` presentation; `null` for `counter`/`currency`. - `unit` (LoyaltyUnitResponse, required): The program's unit label and presentation. ### PaginationMeta Pagination metadata for list responses. - `has_more` (boolean, required): Whether more items exist - `limit` (integer, required): Maximum items per page - `offset` (integer, required): Number of items skipped - `total` (integer, required): Total number of items ### PriceSchema Monetary amount in minor units + currency code + formatting metadata (response). Includes minor_units (divisor to convert to major units) and locale (RFC 5646) so the client can display prices without hardcoding rules. - `currency` (string, default `SEK`): ISO 4217 currency code - `locale` (string, required): RFC 5646 locale for formatting (e.g. sv-SE) - `minor_units` (integer, required): Divisor to convert to major units (e.g. 100 for SEK) - `value` (integer, required): Amount in minor units (e.g. öre, cents) ### ProductBulkUpsertItem One product in a bulk upsert. Same body as create, but the key is required. Without `external_product_id` a retried bulk call would create duplicates, so the bulk endpoint only accepts keyed items. - `brand` (string (nullable)): Manufacturer or brand name. - `categories` (array of string): Category labels defined on the company. Must match existing categories. - `description` (string (nullable)): Long-form product description. - `external_product_id` (string, required): Your product key — the upsert match key. Required in a bulk call. - `identifiers` (array of IdentifierInput (product)): Typed identifiers (gtin/ean13/ean8/sku/pos). Each (type, value) pair must be unique per company across non-deleted products. - `image_link` (string (nullable)): Public URL of the product's primary image. - `is_loyalty_program_eligible` (boolean, default `true`): When true, purchases of this product accrue loyalty points or stamps. - `loyx_app_active` (boolean, default `true`): When true, the product is visible in the consumer LoyX app. - `loyx_business_app_active` (boolean, default `true`): When true, the product is visible in the LoyX Business (staff) app. - `name` (string, required): Display name shown in the mobile app and digital receipts. - `page_url` (string (nullable)): Public URL of the product's web page. - `price` (PriceInput (product), required): Base price in minor units paired with a currency code. - `stores` (array of ProductStoreInput, required): Stores that carry this product — at least one. Each entry may set a per-store price override. - `unit` (string, default `ea`): Unit the product is sold in (ea, kg, g, l, ml, m, pack). Defaults to `ea` (each). ### ProductBulkUpsertRequest Up to 100 products, each created or updated by its `external_product_id`. - `products` (array of ProductBulkUpsertItem, required): 1–100 products. Each is upserted independently; one failing item does not roll back the others. A key may appear only once per request. ### ProductBulkUpsertResponse Per-item results plus counts. Always 207 Multi-Status, even when some items failed. - `created` (integer, required): How many items created a new product. - `failed` (integer, required): How many items were not written; see their `error`. - `results` (array of ProductBulkUpsertResult, required): One result per request item, in request order. - `updated` (integer, required): How many items updated an existing product. ### ProductBulkUpsertResult Outcome of one bulk item, in request order. - `error` (BulkItemError (nullable)): Set only when `status` is `failed`. - `external_product_id` (string, required): The item's match key, as stored. - `index` (integer, required): Position of the item in the request `products` array. - `product` (ProductResponse (nullable)): The stored product; null when `status` is `failed`. - `status` (string (one of `created`, `updated`, `failed`), required): `created` (new product), `updated` (key matched) or `failed`. ### ProductCreateRequest Create a new product in the company's catalog. - `brand` (string (nullable)): Manufacturer or brand name. - `categories` (array of string): Category labels defined on the company. Must match existing categories. - `description` (string (nullable)): Long-form product description. - `external_product_id` (string (nullable)): Your own product key (till/POS/ERP article id). Unique per company. When set, `POST /products` upserts on it: an existing product with this key is updated instead of a duplicate being created. Sale lines that carry an unknown key create a minimal product with it. - `identifiers` (array of IdentifierInput (product)): Typed identifiers (gtin/ean13/ean8/sku/pos). Each (type, value) pair must be unique per company across non-deleted products. - `image_link` (string (nullable)): Public URL of the product's primary image. - `is_loyalty_program_eligible` (boolean, default `true`): When true, purchases of this product accrue loyalty points or stamps. - `loyx_app_active` (boolean, default `true`): When true, the product is visible in the consumer LoyX app. - `loyx_business_app_active` (boolean, default `true`): When true, the product is visible in the LoyX Business (staff) app. - `name` (string, required): Display name shown in the mobile app and digital receipts. - `page_url` (string (nullable)): Public URL of the product's web page. - `price` (PriceInput (product), required): Base price in minor units paired with a currency code. - `stores` (array of ProductStoreInput, required): Stores that carry this product — at least one. Each entry may set a per-store price override. - `unit` (string, default `ea`): Unit the product is sold in (ea, kg, g, l, ml, m, pack). Defaults to `ea` (each). ### ProductListResponse Paginated list of products. - `data` (array of ProductResponse, required) - `pagination` (PaginationMeta, required) ### ProductResponse Catalog-only product response. Per-store pricing lives in the stores_products schemas (`GET /stores/{store_id}/products`). - `_id` (string, required) - `brand` (string (nullable)) - `categories` (array of string) - `company_category` (string (nullable)) - `company_display_name` (string (nullable)) - `company_logo_url` (string (nullable)) - `created_at` (string, required) - `description` (string (nullable)) - `external_product_id` (string (nullable)): Your product key, when one is set. - `identifiers` (array of IdentifierResponse) - `image_link` (string (nullable)) - `is_loyalty_program_eligible` (boolean, required) - `loyx_app_active` (boolean, required) - `loyx_business_app_active` (boolean, required) - `name` (string, required) - `page_url` (string (nullable)) - `price` (PriceSchema (nullable), required) - `unit` (string, required) - `updated_at` (string, required) ### ProductStoreEntryResponse One store that carries the product, with per-store pricing. - `created_at` (string, required): When the product was added to this store's assortment. - `effective_price` (PriceSchema (nullable), required): Unit price at this store: the override when set, else the base price. Null when neither is set. - `price_override` (PriceSchema (nullable)): Per-store price override; null when the base price applies. - `store_id` (string, required): Internal UUID of the store. - `store_name` (string (nullable)): Display name of the store. ### ProductStoreInput Store assortment entry: a store that carries the product. - `price` (PriceInput (product) (nullable)): Optional per-store price override. When omitted, the store uses the product's base price. Currency must match the base price. - `store_id` (string, required): Internal UUID of a store that carries this product. ### ProductStoresListResponse Stores carrying a product — bounded by store count, no pagination. - `data` (array of ProductStoreEntryResponse, required) ### ProductUpdateRequest Partial update for an existing product. Only fields explicitly sent in the request body are applied. Fields sent as `null` clear their value, except `price`, `name`, `loyx_app_active`, `loyx_business_app_active` and `is_loyalty_program_eligible`, which cannot be cleared; omitted fields are left unchanged. Immutable fields (company_id, company_logo_url, etc.) are rejected at the service layer. - `brand` (string (nullable)): Updated manufacturer or brand name. - `categories` (array of string (nullable)): Full replacement of the category list. - `description` (string (nullable)): Updated long-form description. - `external_product_id` (string (nullable)): Set or change your product key. Cannot be cleared. 409 `external_product_id_conflict` when another product of the company (including a deleted one) already has it. - `identifiers` (array of IdentifierInput (product) (nullable)): Full replacement of the typed identifier list (gtin/ean13/ean8/sku/pos). Send `[]` to clear all identifiers. - `is_loyalty_program_eligible` (boolean (nullable)): Whether purchases of this product accrue loyalty points or stamps. - `loyx_app_active` (boolean (nullable)): Visibility toggle for the consumer LoyX app. - `loyx_business_app_active` (boolean (nullable)): Visibility toggle for the LoyX Business (staff) app. - `name` (string (nullable)): Updated display name. - `page_url` (string (nullable)): Updated public URL of the product page. - `price` (PriceInput (product) (nullable)): Updated base price. - `stores` (array of ProductStoreInput (nullable)): Full replacement of the store assortment. When sent, stores not listed are delisted and new stores are added. Omit to leave the assortment unchanged. - `unit` (string (nullable)): Updated unit (ea, kg, g, l, ml, m, pack). ### QuantityInput Quantity with unit. - `unit` (string, default `ea`) - `value` (integer, required) ### RewardBenefitResponse What the member gets. Which fields are set depends on `kind`. - `amount` (RewardPriceResponse (nullable)): Fixed amount off, for `amount`. - `description` (string (nullable)): Fine print; for `text` it is the whole benefit. - `kind` (string, required): Benefit kind: `percent`, `amount`, `fixed_price`, `free_item`, `text`, `bundle_price`, `bundle_percent` or `multibuy`. Open enum: handle unknown values by showing `description`. - `pay_quantity` (integer (nullable)): Items paid for in a `multibuy` (buy `quantity`, pay this). - `per` (string (nullable)): Unit a `fixed_price` applies per. - `percent` (integer (nullable)): Percent off (1-100) for percent kinds. - `price` (RewardPriceResponse (nullable)): New price per unit (`fixed_price`) or bundle total (`bundle_price`). - `quantity` (integer (nullable)): Items in a bundle or multibuy. ### RewardListResponse Cursor-paginated list of a member's redeemable rewards, newest first. - `data` (array of RewardResponse, required): Rewards, newest first. - `pagination` (CursorPaginationMeta, required): Cursor pagination metadata. ### RewardPriceResponse Money in minor units with the currency and how to format it. - `currency` (string, required): ISO 4217 currency code. - `locale` (string, required): RFC 5646 locale for formatting (e.g. `sv-SE`). - `minor_units` (integer, required): Divisor to convert to major units (e.g. 100 for SEK). - `value` (integer, required): Amount in minor units (e.g. öre, cents). ### RewardResponse One reward the member can redeem now, at the store asked about. - `_id` (string, required): The reward's id (the member's entitlement); redemption will take this id. - `benefit` (RewardBenefitResponse (nullable), required): What the member gets; null when the offer has no deal cell. - `created_at` (string, required): When the member received it (UTC). - `max_redemptions` (integer (nullable), required): How many times the reward may be used in total; null for unlimited. - `membership_id` (string, required): The member holding the reward. - `offer_id` (string, required): The offer the reward was granted from. - `terms_and_conditions` (array of string, required): Terms lines to show the cashier. - `times_redeemed` (integer, required): How many times it has been used so far. - `title` (string, required): Display title. - `valid_from` (string (nullable), required): Start of the validity window (UTC). - `valid_to` (string (nullable), required): End of the validity window (UTC), if any. ### StoreContactInput Store contact details. - `email` (string (nullable)) - `phone` (string (nullable)) - `website` (string (nullable)) ### StoreContactResponse Contact info in response. - `email` (string (nullable)) - `phone` (string (nullable)) - `website` (string (nullable)) ### StoreCreateRequest Request schema for creating a store. address and geo are required for physical/pop_up stores, optional for online/warehouse stores. - `address` (AddressInput (nullable)) - `contact` (StoreContactInput (nullable)) - `external_ids` (object) - `external_store_id` (string, required) - `geo` (GeoLocationInput (nullable)) - `icon` (StoreMediaInput (nullable)) - `logo` (StoreMediaInput (nullable)) - `name` (string, required) - `org_number` (string (nullable)) - `status` (string, default `active`) - `tags` (array of string) - `timezone` (string, required) - `type` (string, default `physical`) - `vat_number` (string (nullable)) ### StoreListResponse Paginated list of stores. - `data` (array of StoreResponse, required) - `pagination` (PaginationMeta, required) ### StoreMediaInput Logo/icon URL reference. - `content_type` (string, default `image/png`) - `url` (string, required) ### StoreMediaResponse Media reference in response. - `content_type` (string, required) - `url` (string, required) ### StoreProductListResponse Cursor-paginated list of a store's products. - `data` (array of StoreProductResponse, required) - `pagination` (CursorPaginationMeta, required) ### StoreProductResponse A product as carried at one store. - `_id` (string, required): Product UUID. - `brand` (string (nullable)) - `categories` (array of string) - `effective_price` (PriceSchema (nullable)): Unit price at this store: the override when set, else the base price. Null when neither is set. - `image_link` (string (nullable)) - `name` (string (nullable)) - `price` (PriceSchema (nullable)): Company-wide base price. - `price_override` (PriceSchema (nullable)): Per-store price override; null when the base price applies. ### StoreResponse Full store response — excludes company_id. - `_id` (string, required) - `address` (AddressResponse (nullable)) - `contact` (StoreContactResponse (nullable)) - `created_at` (string, required) - `external_ids` (object) - `external_store_id` (string (nullable)) - `geo` (GeoLocationResponse (nullable)) - `icon` (StoreMediaResponse (nullable)) - `logo` (StoreMediaResponse (nullable)) - `name` (string, required) - `org_number` (string (nullable)) - `status` (string, required) - `tags` (array of string) - `timezone` (string, required) - `type` (string, required) - `updated_at` (string, required) - `vat_number` (string (nullable)) ### StoreUpdateRequest Request schema for partially updating a store. All fields are optional. Only provided fields are applied. - `address` (AddressInput (nullable)) - `contact` (StoreContactInput (nullable)) - `external_ids` (object (nullable)) - `external_store_id` (string (nullable)) - `geo` (GeoLocationInput (nullable)) - `icon` (StoreMediaInput (nullable)) - `logo` (StoreMediaInput (nullable)) - `name` (string (nullable)) - `org_number` (string (nullable)) - `status` (string (nullable)) - `tags` (array of string (nullable)) - `timezone` (string (nullable)) - `type` (string (nullable)) - `vat_number` (string (nullable)) ### TokenResponse OAuth2 Client Credentials token response. - `access_token` (string, required): Opaque bearer token - `expires_in` (integer, required): Token lifetime in seconds from issuance - `scope` (string, default ``): The scopes this token carries, space-separated (RFC 6749 §5.1), for example `members:read sales:write`. They are the API key's scopes at issuance; a scope change in the Portal ends the token at once. - `token_type` (string, default `bearer`): Always 'bearer' ### TotalResponse Single totals entry. Value is integer minor units. Currency is on the transaction root — not duplicated here. - `type` (string, required) - `value` (integer, required) ### TransactionCreateRequest Request schema for creating a transaction. totals and loyalty are excluded: - totals are derived server-side from items - loyalty is populated by the loyalty engine - status is computed from resolution results - `country_code` (string, default `SE`) - `currency` (string, default `SEK`) - `discounts` (array of TransactionDiscountInput) - `external` (ExternalFieldsInput, required) - `items` (array of ItemInput) - `locale` (string, default `sv-SE`) - `member` (array of MemberIdentifierInput) - `metadata` (object) - `origin` (string, default `pos`) - `store_id` (string (nullable)) - `totals` (TransactionTotalsInput (nullable)): The `sale` shape — send instead of `items` when the POS knows only what the member paid. Mutually exclusive with `items`. - `transaction_type` (string, default `purchase`) - `user_id` (string (nullable)) ### TransactionDiscountInput Basket-level discount in a create request. - `amount` (PriceInput (transaction), required) - `description` (string, default ``) - `personal_offer_id` (string (nullable)): Stored as the transaction's `offer_id`: the v2 Offer this discount came from, for sale attribution only. Not an entitlement id — entitlements are not redeemed on this surface. - `type` (string, required) ### TransactionListResponse Paginated list of transaction summaries. - `data` (array of TransactionSummaryResponse, required) - `pagination` (PaginationMeta, required) ### TransactionResponse Full transaction response for detail endpoints. - `_id` (string, required) - `company_id` (string, required) - `country_code` (string, required) - `created_at` (string, required) - `currency` (string, required) - `discounts` (array of DiscountResponse) - `external` (ExternalFieldsInput, required) - `items` (array of ItemResponse, required) - `locale` (string, required) - `loyalty` (LoyaltyResponse (nullable)) - `member` (array of MemberIdentifierInput, required) - `membership_id` (string (nullable)) - `metadata` (object) - `origin` (string (nullable)) - `status` (string, default `unresolved`) - `store_id` (string (nullable)) - `totals` (array of TotalResponse, required) - `transaction_type` (string, required) - `updated_at` (string, required) - `user_id` (string (nullable)) - `voided_at` (string (nullable)) ### TransactionSummaryResponse Lighter transaction response for list endpoints. - `_id` (string, required) - `company_id` (string, required) - `created_at` (string, required) - `currency` (string, required) - `origin` (string (nullable)) - `status` (string, default `unresolved`) - `totals` (array of TotalResponse, required) - `transaction_type` (string, required) - `voided_at` (string (nullable)) ### TransactionTotalsInput What the member paid, when the POS cannot send the basket. The `sale` shape: a register that knows the receipt total but not its line items. `to_model` turns this into exactly one synthetic, non-eligible line so everything downstream — `calculate_and_store_totals`, the ledger engine, the reversal path — sees the ordinary document shape it already handles. Nothing measured on selected lines can earn from it, which is why the line is deliberately not loyalty-eligible. The transaction records **VAT 0, and NET equal to PAID**: a register that cannot send line items cannot send their tax rates either, and the receipt total alone does not say what the split was. Splitting it would mean guessing a rate, which is a worse answer than none for Skatteverket. A transaction that must carry VAT has to send `items`. - `currency` (string (nullable)): ISO 4217 code. Defaults to the transaction currency. - `paid_minor` (integer, required): What the member paid, in minor units (öre). Use when the POS has no line items; the API records one synthetic, non-eligible line so amount-based programs can earn. ### IdentifierInput (product) Typed product identifier (gtin / ean13 / ean8 / sku / pos). - `type` (string, required): Identifier type: gtin, ean13, ean8, sku, or pos. - `value` (string, required) ### PriceInput (product) Monetary amount in minor units + currency code (request input). - `currency` (string, default `SEK`): ISO 4217 currency code - `value` (integer, required): Amount in minor units (e.g. öre, cents) ### IdentifierInput (transaction) Product identifier (gtin, sku, etc.). - `type` (string, required) - `value` (string, required) ### PriceInput (transaction) Monetary amount in minor units + ISO 4217 currency (request input). - `currency` (string, default `SEK`) - `value` (integer, required)