Skip to content

Create a transaction

POST
/v1/transactions
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.

Idempotency-Key
Any of:
string

Optional. Retrying with the same key returns the original transaction (200, Idempotent-Replayed: true); the same key with a different body is 409.

Media typeapplication/json
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
object
country_code
Country Code
string
default: SE
currency
Currency
string
default: SEK
discounts
Discounts
Array<object>
<= 50 items
TransactionDiscountInput

Basket-level discount in a create request.

object
amount
required
PriceInput

Monetary amount in minor units + ISO 4217 currency (request input).

object
currency
Currency
string
default: SEK
value
required
Value
integer
description
Description
string
"" <= 255 characters
personal_offer_id
Any of:
string format: uuid
type
required
Type
string
external
required
ExternalFieldsInput

External POS fields — all optional, stored as-received.

object
cashier_id
Any of:
string
<= 255 characters
cashier_name
Any of:
string
<= 255 characters
control_unit_code
Any of:
string
<= 255 characters
external_store_id
Any of:
string
<= 255 characters
external_transaction_id
Any of:
string
<= 255 characters
pos_serial
Any of:
string
<= 255 characters
pos_system
Any of:
string
<= 255 characters
purchased_at
Any of:
string format: date-time
receipt_number
Any of:
string
<= 255 characters
items
Items
Array<object>
<= 1000 items
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.

object
description
Any of:
string
<= 255 characters
discounts
Discounts
Array<object>
<= 50 items
DiscountInput

Per-item discount in a create request.

object
amount
required
PriceInput

Monetary amount in minor units + ISO 4217 currency (request input).

object
currency
Currency
string
default: SEK
value
required
Value
integer
description
Description
string
"" <= 255 characters
personal_offer_id
Any of:
string format: uuid
type
required
Type
string
external_product_id
Any of:
string
<= 255 characters
identifiers
Identifiers
Array<object>
<= 50 items
IdentifierInput

Product identifier (gtin, sku, etc.).

object
type
required
Type
string
value
required
Value
string
>= 1 characters <= 255 characters
loyalty_eligible
Loyalty Eligible
boolean
default: true
product_id
Any of:
string format: uuid
product_name
Any of:
string
<= 255 characters
quantity
required
QuantityInput

Quantity with unit.

object
unit
Unit
string
default: ea
value
required
Value
integer
> 0
sequence_number
Sequence Number
integer
0
tax_rate
Tax Rate
integer
0 <= 10000
unit_price
required
PriceInput

Monetary amount in minor units + ISO 4217 currency (request input).

object
currency
Currency
string
default: SEK
value
required
Value
integer
locale
Locale
string
default: sv-SE
member
Member
Array<object>
<= 20 items
MemberIdentifierInput

Member identifier (user_id, membership_id, mobile_number, email, social_security_number).

object
identifier
required
Identifier
string
value
required
Value
string
>= 1 characters <= 255 characters
metadata
Metadata
object
key
additional properties
any
origin
Origin
string
default: pos
store_id
Any of:
string format: uuid
totals
Any of:
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.

object
currency
Any of:
string
>= 3 characters <= 3 characters
paid_minor
required
Paid Minor

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.

integer
transaction_type
Transaction Type
string
default: purchase
user_id
Any of:
string format: uuid

Replay: this external_transaction_id was already booked with the same content. The body is the original transaction; the response carries Idempotent-Replayed: true.

Idempotent-Replayed
string

true when the body is an earlier booking of this sale.

The created transaction, including computed totals and loyalty outcome.

Media typeapplication/json
TransactionResponse

Full transaction response for detail endpoints.

object
_id
required
Id
string format: uuid
company_id
required
Company Id
string format: uuid
country_code
required
Country Code
string
created_at
required
Created At
string format: date-time
currency
required
Currency
string
discounts
Discounts
Array<object>
DiscountResponse

Discount in response (line-level or basket-level).

object
amount
required
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.

object
currency
Currency

ISO 4217 currency code

string
default: SEK
locale
required
Locale

RFC 5646 locale for formatting (e.g. sv-SE)

string
minor_units
required
Minor Units

Divisor to convert to major units (e.g. 100 for SEK)

integer
value
required
Value

Amount in minor units (e.g. öre, cents)

integer
description
Description
string
""
personal_offer_id
Any of:
string format: uuid
type
required
Type
string
external
required
ExternalFieldsInput

External POS fields — all optional, stored as-received.

object
cashier_id
Any of:
string
<= 255 characters
cashier_name
Any of:
string
<= 255 characters
control_unit_code
Any of:
string
<= 255 characters
external_store_id
Any of:
string
<= 255 characters
external_transaction_id
Any of:
string
<= 255 characters
pos_serial
Any of:
string
<= 255 characters
pos_system
Any of:
string
<= 255 characters
purchased_at
Any of:
string format: date-time
receipt_number
Any of:
string
<= 255 characters
items
required
Items
Array<object>
ItemResponse

Line item in a transaction response — includes computed fields.

object
description
Any of:
string
discounts
Discounts
Array<object>
DiscountResponse

Discount in response (line-level or basket-level).

object
amount
required
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.

object
currency
Currency

ISO 4217 currency code

string
default: SEK
locale
required
Locale

RFC 5646 locale for formatting (e.g. sv-SE)

string
minor_units
required
Minor Units

Divisor to convert to major units (e.g. 100 for SEK)

integer
value
required
Value

Amount in minor units (e.g. öre, cents)

integer
description
Description
string
""
personal_offer_id
Any of:
string format: uuid
type
required
Type
string
external_product_id
Any of:
string
identifiers
Identifiers
Array<object>
IdentifierInput

Product identifier (gtin, sku, etc.).

object
type
required
Type
string
value
required
Value
string
>= 1 characters <= 255 characters
loyalty_eligible
required
Loyalty Eligible
boolean
product_id
Any of:
string format: uuid
product_name
Any of:
string
quantity
required
QuantityInput

Quantity with unit.

object
unit
Unit
string
default: ea
value
required
Value
integer
> 0
sequence_number
required
Sequence Number
integer
tax_rate
required
Tax Rate
integer
total_amount
required
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.

object
currency
Currency

ISO 4217 currency code

string
default: SEK
locale
required
Locale

RFC 5646 locale for formatting (e.g. sv-SE)

string
minor_units
required
Minor Units

Divisor to convert to major units (e.g. 100 for SEK)

integer
value
required
Value

Amount in minor units (e.g. öre, cents)

integer
total_discount
required
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.

object
currency
Currency

ISO 4217 currency code

string
default: SEK
locale
required
Locale

RFC 5646 locale for formatting (e.g. sv-SE)

string
minor_units
required
Minor Units

Divisor to convert to major units (e.g. 100 for SEK)

integer
value
required
Value

Amount in minor units (e.g. öre, cents)

integer
unit_price
required
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.

object
currency
Currency

ISO 4217 currency code

string
default: SEK
locale
required
Locale

RFC 5646 locale for formatting (e.g. sv-SE)

string
minor_units
required
Minor Units

Divisor to convert to major units (e.g. 100 for SEK)

integer
value
required
Value

Amount in minor units (e.g. öre, cents)

integer
locale
required
Locale
string
loyalty
Any of:
LoyaltyResponse

Loyalty block in responses. Pre-populated with empty keys, filled by the loyalty engine after processing.

object
cycle
Any of:
integer
exchange_rate_used
Any of:
object
key
additional properties
any
points_deducted
Any of:
integer
points_earned
Points Earned
integer
0
post_balance
Post Balance
integer
0
pre_balance
Pre Balance
integer
0
processed_at
Any of:
string format: date-time
refund_processed_at
Any of:
string format: date-time
refund_type
Any of:
string
stamps_earned
Stamps Earned
integer
0
member
required
Member
Array<object>
MemberIdentifierInput

Member identifier (user_id, membership_id, mobile_number, email, social_security_number).

object
identifier
required
Identifier
string
value
required
Value
string
>= 1 characters <= 255 characters
membership_id
Any of:
string format: uuid
metadata
Metadata
object
key
additional properties
any
origin
Any of:
string
status
Status
string
default: unresolved
store_id
Any of:
string format: uuid
totals
required
Totals
Array<object>
TotalResponse

Single totals entry. Value is integer minor units. Currency is on the transaction root — not duplicated here.

object
type
required
Type
string
value
required
Value
integer
transaction_type
required
Transaction Type
string
updated_at
required
Updated At
string format: date-time
user_id
Any of:
string format: uuid
voided_at
Any of:
string format: date-time

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.

Media typeapplication/json
ErrorResponse

Standard error response format.

object
error
required
ErrorDetail

Error detail structure (Stripe-like format).

object
code
required
Code

Machine-readable error code

string
details
Any of:
Array<object>
FieldErrorDetail

One failing field of a validation error.

object
message
required
Message

Why the value was refused

string
param
required
Param

Dotted path of the field, e.g. items.0.unit_price.value

string
doc_url
Any of:
string
message
required
Message

Human-readable error message

string
param
Any of:
string
type
required
Type

Error type category

string
request_id
Any of:
string

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.

Media typeapplication/json
ErrorResponse

Standard error response format.

object
error
required
ErrorDetail

Error detail structure (Stripe-like format).

object
code
required
Code

Machine-readable error code

string
details
Any of:
Array<object>
FieldErrorDetail

One failing field of a validation error.

object
message
required
Message

Why the value was refused

string
param
required
Param

Dotted path of the field, e.g. items.0.unit_price.value

string
doc_url
Any of:
string
message
required
Message

Human-readable error message

string
param
Any of:
string
type
required
Type

Error type category

string
request_id
Any of:
string

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.

Media typeapplication/json
ErrorResponse

Standard error response format.

object
error
required
ErrorDetail

Error detail structure (Stripe-like format).

object
code
required
Code

Machine-readable error code

string
details
Any of:
Array<object>
FieldErrorDetail

One failing field of a validation error.

object
message
required
Message

Why the value was refused

string
param
required
Param

Dotted path of the field, e.g. items.0.unit_price.value

string
doc_url
Any of:
string
message
required
Message

Human-readable error message

string
param
Any of:
string
type
required
Type

Error type category

string
request_id
Any of:
string

Example generated

{
"error": {
"code": "example",
"details": [
{
"message": "example",
"param": "example"
}
],
"doc_url": "example",
"message": "example",
"param": "example",
"type": "example"
},
"request_id": "example"
}

Validation Error

Media typeapplication/json
ErrorResponse

Standard error response format.

object
error
required
ErrorDetail

Error detail structure (Stripe-like format).

object
code
required
Code

Machine-readable error code

string
details
Any of:
Array<object>
FieldErrorDetail

One failing field of a validation error.

object
message
required
Message

Why the value was refused

string
param
required
Param

Dotted path of the field, e.g. items.0.unit_price.value

string
doc_url
Any of:
string
message
required
Message

Human-readable error message

string
param
Any of:
string
type
required
Type

Error type category

string
request_id
Any of:
string

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.

Media typeapplication/json
ErrorResponse

Standard error response format.

object
error
required
ErrorDetail

Error detail structure (Stripe-like format).

object
code
required
Code

Machine-readable error code

string
details
Any of:
Array<object>
FieldErrorDetail

One failing field of a validation error.

object
message
required
Message

Why the value was refused

string
param
required
Param

Dotted path of the field, e.g. items.0.unit_price.value

string
doc_url
Any of:
string
message
required
Message

Human-readable error message

string
param
Any of:
string
type
required
Type

Error type category

string
request_id
Any of:
string

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.

Media typeapplication/json
ErrorResponse

Standard error response format.

object
error
required
ErrorDetail

Error detail structure (Stripe-like format).

object
code
required
Code

Machine-readable error code

string
details
Any of:
Array<object>
FieldErrorDetail

One failing field of a validation error.

object
message
required
Message

Why the value was refused

string
param
required
Param

Dotted path of the field, e.g. items.0.unit_price.value

string
doc_url
Any of:
string
message
required
Message

Human-readable error message

string
param
Any of:
string
type
required
Type

Error type category

string
request_id
Any of:
string

Example generated

{
"error": {
"code": "example",
"details": [
{
"message": "example",
"param": "example"
}
],
"doc_url": "example",
"message": "example",
"param": "example",
"type": "example"
},
"request_id": "example"
}