curl --request POST \
--url https://{host}/pos-discount/v1/discounted-purchases \
--header 'Content-Type: application/json' \
--data '
{
"receiptId": "c7ced248-24a6-43a6-a27f-977b3aab4799",
"storeId": "475",
"memberId": "12396909",
"currencyCode": "DKK",
"totalAmount": 27,
"totalTaxAmount": 0,
"purchaseDateTimeUtc": "2026-11-06T12:20:14.950035Z",
"purchaseBusinessDateTime": "2026-11-06T12:20:14.9500351Z",
"paymentMethods": [
{
"amount": 27,
"paymentType": "Card"
}
],
"products": [
{
"id": "5700123969094",
"sequenceNumber": 1,
"name": "Banana",
"categoryId": "fruit",
"unitPrice": 4.5,
"quantity": {
"unitOfMeasure": "pcs",
"value": 2
},
"originalPrice": 9,
"price": 9
},
{
"id": "5700123969095",
"sequenceNumber": 2,
"name": "Orange",
"categoryId": "fruit",
"unitPrice": 6,
"quantity": {
"unitOfMeasure": "pcs",
"value": 3
},
"originalPrice": 18,
"price": 18
}
],
"discounts": [],
"taxes": []
}
'{
"receiptId": "c7ced248-24a6-43a6-a27f-977b3aab4799",
"storeId": "475",
"memberId": "12396909",
"currencyCode": "DKK",
"totalAmount": 26.1,
"totalTaxAmount": 0,
"purchaseDateTimeUtc": "2026-11-06T12:20:14.9503771Z",
"purchaseBusinessDateTime": "2026-11-06T12:20:14.9503772Z",
"paymentMethods": [
{
"amount": 27,
"paymentType": "Card"
}
],
"products": [
{
"id": "5700123969094",
"sequenceNumber": 1,
"name": "Banana",
"categoryId": "fruit",
"unitPrice": 4.5,
"quantity": {
"unitOfMeasure": "pcs",
"value": 2
},
"originalPrice": 9,
"price": 8.1,
"discountAllocations": [
{
"discountSequenceNumber": 1,
"discountAmount": 0.9
}
]
},
{
"id": "5700123969095",
"sequenceNumber": 2,
"name": "Orange",
"categoryId": "fruit",
"unitPrice": 6,
"quantity": {
"unitOfMeasure": "pcs",
"value": 3
},
"originalPrice": 18,
"price": 18,
"discountAllocations": []
}
],
"discounts": [
{
"sequenceNumber": 1,
"name": "10% off bananas",
"totalDiscountAmount": 0.9,
"couponId": "9b7cbade-807d-4094-8592-fc894268f142",
"couponIds": [
"9b7cbade-807d-4094-8592-fc894268f142"
],
"appliedProducts": [
1
]
}
],
"taxes": []
}Calculate discounts for a purchase
The POS calls this with the sale in the shape of a purchase, the same shape it records with the Purchase API afterwards, and gets the priced purchase back. Lobyco recommends it over POST /v1/discounted-baskets: the request and the response are the purchase itself, so the POS records what it was returned. The purchase and its fields are the Purchase API’s, described on POST /v1/purchases; the examples here show the fields the calculation reads and fills. The customer is memberId, as the check-in gave it to the POS; a purchase without one gets no discounts and comes back unchanged.
Lobyco lists the customer’s coupons valid in storeId, applies the ones whose rules the purchase meets in the order of the offers’ priority, and reserves the applied coupons under the receiptId for a short time, 1 minute by default, so they cannot be used at another POS meanwhile. A coupon another sale holds a reservation on is not applied. Pass skipReservation=true to price a sale without reserving, for example one the customer has not committed to yet. Offers of the types baseBonus, voucher and triggeredVoucher are never applied here.
The response repeats the purchase: totalAmount after the discounts, each discounted product’s price reduced and its discountAllocations pointing at the discounts, and discounts listing every applied discount with its couponIds and the appliedProducts it applied to, empty for a basket-level discount. Discounts the POS applied itself, sent in discounts, are returned again only when preserveExternalDiscounts is on, by request or for your environment.
totalAmount must equal the sum of the products’ price, with or without the discounts sent; otherwise the request is refused with 400 InvalidBasketCalculateDiscountRequest.
A return purchase gets a recommended refund for each returned product. A purchase is a return when it has a memberId and at least one product has an originalReceiptId, the receiptId of the sale the product was bought on. The recommended refund is what the customer paid for those units on the original sale, less what earlier returns of that sale already paid back. The response puts it in both the product’s price and originalPrice, as a negative amount, and totalAmount follows. Record the return with what was actually paid back, in both fields. A product that is not on the original sale, or whose sale is not found, keeps the price that was sent. Every product of a return purchase must have a price of zero or below and must not be cancelled, otherwise the request is refused with 400 InvalidReturnPurchase: leave out a voided product together with the product it voids. The quantity can have either sign.
Nothing is stored. Record the finished sale with the Purchase API, with the couponIds from the response in its discounts, so Lobyco redeems the coupons when it loads the purchase.
curl --request POST \
--url https://{host}/pos-discount/v1/discounted-purchases \
--header 'Content-Type: application/json' \
--data '
{
"receiptId": "c7ced248-24a6-43a6-a27f-977b3aab4799",
"storeId": "475",
"memberId": "12396909",
"currencyCode": "DKK",
"totalAmount": 27,
"totalTaxAmount": 0,
"purchaseDateTimeUtc": "2026-11-06T12:20:14.950035Z",
"purchaseBusinessDateTime": "2026-11-06T12:20:14.9500351Z",
"paymentMethods": [
{
"amount": 27,
"paymentType": "Card"
}
],
"products": [
{
"id": "5700123969094",
"sequenceNumber": 1,
"name": "Banana",
"categoryId": "fruit",
"unitPrice": 4.5,
"quantity": {
"unitOfMeasure": "pcs",
"value": 2
},
"originalPrice": 9,
"price": 9
},
{
"id": "5700123969095",
"sequenceNumber": 2,
"name": "Orange",
"categoryId": "fruit",
"unitPrice": 6,
"quantity": {
"unitOfMeasure": "pcs",
"value": 3
},
"originalPrice": 18,
"price": 18
}
],
"discounts": [],
"taxes": []
}
'{
"receiptId": "c7ced248-24a6-43a6-a27f-977b3aab4799",
"storeId": "475",
"memberId": "12396909",
"currencyCode": "DKK",
"totalAmount": 26.1,
"totalTaxAmount": 0,
"purchaseDateTimeUtc": "2026-11-06T12:20:14.9503771Z",
"purchaseBusinessDateTime": "2026-11-06T12:20:14.9503772Z",
"paymentMethods": [
{
"amount": 27,
"paymentType": "Card"
}
],
"products": [
{
"id": "5700123969094",
"sequenceNumber": 1,
"name": "Banana",
"categoryId": "fruit",
"unitPrice": 4.5,
"quantity": {
"unitOfMeasure": "pcs",
"value": 2
},
"originalPrice": 9,
"price": 8.1,
"discountAllocations": [
{
"discountSequenceNumber": 1,
"discountAmount": 0.9
}
]
},
{
"id": "5700123969095",
"sequenceNumber": 2,
"name": "Orange",
"categoryId": "fruit",
"unitPrice": 6,
"quantity": {
"unitOfMeasure": "pcs",
"value": 3
},
"originalPrice": 18,
"price": 18,
"discountAllocations": []
}
],
"discounts": [
{
"sequenceNumber": 1,
"name": "10% off bananas",
"totalDiscountAmount": 0.9,
"couponId": "9b7cbade-807d-4094-8592-fc894268f142",
"couponIds": [
"9b7cbade-807d-4094-8592-fc894268f142"
],
"appliedProducts": [
1
]
}
],
"taxes": []
}Query Parameters
Only apply offers granting these benefits: Discount, Bonus or both. Repeat the parameter for several. Omitted, both.
What an offer gives the customer at checkout.
Discount: a lower price, taken off the line or the basket total.Bonus: loyalty bonus, granted on top of the price.
This list is not final. Lobyco may add a value at any time, and a consumer must not fail on a value it does not know.
Discount, Bonus Body
The sale, in the shape of a purchase.
Response
The purchase with the discounts applied: totalAmount, each product's price and discountAllocations, and the discounts with their coupon ids. A purchase with no applicable discounts comes back unchanged.