Create a transaction
const url = 'https://api.loyx.se/partners/v1/transactions';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"country_code":"SE","currency":"SEK","discounts":[{"amount":{"currency":"SEK","value":1},"description":"","personal_offer_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","type":"example"}],"external":{"cashier_id":"example","cashier_name":"example","control_unit_code":"example","external_store_id":"example","external_transaction_id":"example","pos_serial":"example","pos_system":"example","purchased_at":"2026-04-15T12:00:00Z","receipt_number":"example"},"items":[{"description":"example","discounts":[{"amount":{"currency":"SEK","value":1},"description":"","personal_offer_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","type":"example"}],"external_product_id":"example","identifiers":[{"type":"example","value":"example"}],"loyalty_eligible":true,"product_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","product_name":"example","quantity":{"unit":"ea","value":1},"sequence_number":0,"tax_rate":0,"unit_price":{"currency":"SEK","value":1}}],"locale":"sv-SE","member":[{"identifier":"example","value":"example"}],"metadata":{},"origin":"pos","store_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","totals":{"currency":"example","paid_minor":1},"transaction_type":"purchase","user_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.loyx.se/partners/v1/transactions \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "country_code": "SE", "currency": "SEK", "discounts": [ { "amount": { "currency": "SEK", "value": 1 }, "description": "", "personal_offer_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "type": "example" } ], "external": { "cashier_id": "example", "cashier_name": "example", "control_unit_code": "example", "external_store_id": "example", "external_transaction_id": "example", "pos_serial": "example", "pos_system": "example", "purchased_at": "2026-04-15T12:00:00Z", "receipt_number": "example" }, "items": [ { "description": "example", "discounts": [ { "amount": { "currency": "SEK", "value": 1 }, "description": "", "personal_offer_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "type": "example" } ], "external_product_id": "example", "identifiers": [ { "type": "example", "value": "example" } ], "loyalty_eligible": true, "product_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "product_name": "example", "quantity": { "unit": "ea", "value": 1 }, "sequence_number": 0, "tax_rate": 0, "unit_price": { "currency": "SEK", "value": 1 } } ], "locale": "sv-SE", "member": [ { "identifier": "example", "value": "example" } ], "metadata": {}, "origin": "pos", "store_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "totals": { "currency": "example", "paid_minor": 1 }, "transaction_type": "purchase", "user_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" }'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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”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
object
Basket-level discount in a create request.
External POS fields — all optional, stored as-received.
object
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.
object
Per-item discount in a create request.
Product identifier (gtin, sku, etc.).
object
Quantity with unit.
object
Monetary amount in minor units + ISO 4217 currency (request input).
object
Member identifier (user_id, membership_id, mobile_number, email, social_security_number).
object
object
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.
Responses
Section titled “Responses”Replay: this external_transaction_id was already booked with the same content. The body is the original transaction; the response carries Idempotent-Replayed: true.
Headers
Section titled “Headers”true when the body is an earlier booking of this sale.
The created transaction, including computed totals and loyalty outcome.
Full transaction response for detail endpoints.
object
Discount in response (line-level or basket-level).
object
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.
object
ISO 4217 currency code
RFC 5646 locale for formatting (e.g. sv-SE)
Divisor to convert to major units (e.g. 100 for SEK)
Amount in minor units (e.g. öre, cents)
External POS fields — all optional, stored as-received.
object
Line item in a transaction response — includes computed fields.
object
Discount in response (line-level or basket-level).
object
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.
object
ISO 4217 currency code
RFC 5646 locale for formatting (e.g. sv-SE)
Divisor to convert to major units (e.g. 100 for SEK)
Amount in minor units (e.g. öre, cents)
Product identifier (gtin, sku, etc.).
object
Quantity with unit.
object
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.
object
ISO 4217 currency code
RFC 5646 locale for formatting (e.g. sv-SE)
Divisor to convert to major units (e.g. 100 for SEK)
Amount in minor units (e.g. öre, cents)
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.
object
ISO 4217 currency code
RFC 5646 locale for formatting (e.g. sv-SE)
Divisor to convert to major units (e.g. 100 for SEK)
Amount in minor units (e.g. öre, cents)
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.
object
ISO 4217 currency code
RFC 5646 locale for formatting (e.g. sv-SE)
Divisor to convert to major units (e.g. 100 for SEK)
Amount in minor units (e.g. öre, cents)
Loyalty block in responses. Pre-populated with empty keys, filled by the loyalty engine after processing.
object
Member identifier (user_id, membership_id, mobile_number, email, social_security_number).
object
object
Single totals entry. Value is integer minor units. Currency is on the transaction root — not duplicated here.
object
Example
{ "discounts": [ { "amount": { "currency": "SEK" }, "description": "" } ], "items": [ { "discounts": [ { "amount": { "currency": "SEK" }, "description": "" } ], "quantity": { "unit": "ea" }, "total_amount": { "currency": "SEK" }, "total_discount": { "currency": "SEK" }, "unit_price": { "currency": "SEK" } } ], "loyalty": { "points_earned": 0, "post_balance": 0, "pre_balance": 0, "stamps_earned": 0 }, "status": "unresolved"}missing_token, invalid_authorization_header or invalid_token: get a new access token and retry once.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}insufficient_scope: the API key lacks the scope this route needs.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}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.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}Validation Error
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}rate_limit_exceeded: wait Retry-After seconds.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}internal_server_error or database_error (type internal_error): our fault. Retry with backoff; quote request_id.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}