New Engine Promo Engine
Use this model when Loyal Guru must evaluate discount campaigns and return the final discount amounts that the POS or e-commerce checkout applies to the receipt.
The POS sends the cart and renders what comes back. It does not read campaign rules, does not decide which promotions stack, and does not do the arithmetic.
Responsibilitiesβ
Before the flows, it is worth fixing where each side's work ends. In this model the split is narrow and stable β Loyal Guru owns every decision, the POS owns the payload and the display:
| System | Responsibility |
|---|---|
| Loyal Guru | Evaluates active campaigns, coupons, vouchers, stackability, limits, customer eligibility, product/store scope, and returns calculated effects[]. |
| POS / e-commerce | Sends the cart with complete line, store, customer, payment, and coupon data; displays the returned discounts; confirms or cancels the transaction. |
What this model coversβ
This is the reason most projects choose it. Because Loyal Guru does the calculation, every loyalty mechanic works through the same two calls β and a new mechanic configured in the Owner App reaches the till without a POS release.
| Mechanic | Where it appears in the response |
|---|---|
| Discounts β massive, loyalty member, and targeted vouchers | effects[] with type: discount |
| Points earned | effects[] with type: points |
| Points redeemed as cashback | cashbacks[], driven by cashback_score_desired |
| Games and challenges | Evaluated on the confirmed cart; surfaced through the Visualization connection |
Campaigns come in three audiences, and the same cart can trigger all three at once:
| Audience | API value | Who it reaches |
|---|---|---|
| MASS | all_customers | Every customer, identified or not |
| CLUB | loyalty | Enrolled loyalty members |
| TARGETED | targeted | A specific customer, delivered as a voucher |
MASS and CLUB campaigns need no coupon: they apply because the cart and the customer qualify. TARGETED campaigns arrive as vouchers assigned to one customer, and coupons_desired controls whether they are considered.
End-to-end flowβ
The sequence below is the whole runtime conversation for a transaction, from identifying the customer to printing the vouchers earned. Two calls carry the promotion logic β POST /carts/simulate to preview and POST /carts/realtime to commit β and everything else is context or confirmation:
Two activation pathsβ
The calls above are the same for every customer. What changes is how the vouchers reach the transaction β and that is a product decision that lands squarely in the integration. The two paths differ in when the customer activated the voucher and whether the checkout has to name the code, not in where the customer is shopping.
Digital pre-activation β the customer chose their vouchers before checkoutβ
The customer opened the app or the website before the transaction and activated the offers they wanted. The checkout never sees a voucher code β it identifies the customer and Loyal Guru resolves the selection. This works the same in a physical store as in e-commerce: the customer identifies at the till with their card, phone or QR, and the selection they made at home applies there.
Send coupons_desired: "selected" and Loyal Guru resolves the activation itself. The GET /discounts read is optional and display-only β it lets the cashier show the customer what is about to apply, but the engine does not need it. See Vouchers Pre-Activation for the parameters.
Individual activation β one code at a time at the checkoutβ
Nothing was activated beforehand. The customer presents a code, and the checkout sends that code explicitly. The medium does not matter β it can be printed on a previous receipt or a paper mailing, or shown on the customer's screen as a code or a QR. What matters to the integration is that the codes arrive one by one and the POS has to name them.
The GET /discounts step is a courtesy check: the POS reads the customer's campaigns for the store, locates the presented code in coupon_info.static_code or coupon_info.voucher_info.voucher_code, and can reject an expired code before ringing up the cart. It is not required β an invalid code sent in coupons_desired comes back in invalid_coupons[] rather than failing the cart.
Most retailers run both paths at once. The POS does not choose one at integration time: it decides per transaction which coupons_desired value to send, based on whether a code was presented or not.
Runtime endpointsβ
The flows above use a small, fixed set of endpoints. Grouped by the step they belong to:
| Step | Endpoint | Purpose |
|---|---|---|
| Preview | POST /carts/simulate | Calculates discounts and points without persisting the cart or consuming vouchers. |
| Confirm | POST /carts/realtime | Persists the cart, commits effects, and updates voucher/coupon usage. |
| Cancel | POST /carts/cancellation | Rolls back the confirmed cart effects. Wait at least 5 minutes after the original cart creation. |
POST /vouchers/print | Returns the vouchers to print on the receipt and marks them as printed. |
POST /carts/simulate and POST /carts/realtime take the same payload and return the same response shape. Simulate does not persist. That symmetry is what makes the preview safe: whatever the simulation returned is what confirmation will commit, as long as the cart did not change.
Cart requestβ
Send apply_discounts: true when Loyal Guru must calculate and return final discount values.
POST /carts/simulate
X-Api-Key: your_api_key
X-Api-Secret: your_api_key_secret
X-Api-Version: 1
Content-Type: application/json
{
"id": 202607090001,
"customer_id": 123456,
"apply_discounts": true,
"apply_points": true,
"total": 45.0,
"currency": "EUR",
"location_id": 1001,
"creation_date": "2026-07-09T12:41:08Z",
"payment_method": "visa",
"coupons_desired": "selected",
"lines": [
{
"order": 1,
"product_id": 10045,
"product_code": "CC-33CL-LATA",
"quantity": 3,
"unit_price": 1.5,
"total": 4.5
}
]
}
customer_id and customer_code are mutually exclusive β send one. The same applies to product_id and product_code on each line.
Controlling which vouchers applyβ
coupons_desired is the single most consequential field in the payload, and it is not just an array of codes. It has four distinct behaviours, and choosing the wrong one is the most common cause of "the discount did not apply".
| Value | What Loyal Guru applies |
|---|---|
"all" | All massive and loyalty member promotions + every voucher assigned to the customer |
"selected" | All massive and loyalty member promotions + only the vouchers the customer activated through the app or web |
["34433", "465443"] | All massive and loyalty member promotions without coupon + only the codes listed |
[] or omitted | Only massive and loyalty member promotions without coupon β no vouchers at all |
Read that table against the two paths above: "selected" is digital pre-activation, the array is individual activation, and "all" is the shortcut for retailers who decided the customer should never have to activate anything.
By default β the field omitted β no vouchers are considered. A cart that omits coupons_desired and expects a targeted voucher to apply will silently return no discount for it.
Codes sent in coupons_desired that are invalid or do not exist come back in invalid_coupons[]. Codes that exist but could not be applied come back in rejected_campaigns[] with a reason.
Redeeming points as cashbackβ
If the customer wants to pay part of the cart with points, you do not have to work out the per-line distribution. Send the total points to burn in cashback_score_desired and Loyal Guru returns a recommended cashbacks[] array, prioritising distribution by line_order through an internal algorithm.
- Set
cashback_score_desired: -1to apply the maximum possible points. - The cashback discount on a line cannot exceed a configured share of that line's
original_totalβ 50% by default. - The response reports what could not be used in
cashback_score_desired_unused.
Specifying this parameter changes the total points and the lines in the response compared with your request. Simulate first, show the customer the real figure, then confirm.
Calculation orderβ
Loyal Guru applies effects in a fixed order, and it matters when you reconcile totals:
Discounts burn first, then points are burned, and finally points are earned.
- Each line's
totalis the amount after every applicable discount β promotional campaigns, vouchers, and cashback. - The original, unadjusted line amount is preserved in
original_total. - Points earned are calculated on the post-discount amount, not on the amount the customer would have paid without promotions.
Response handlingβ
Read effects[] as the source of truth for the applied promotion result. The POS should not re-calculate the same discount; it should apply or display what the response returns.
{
"effects": [
{
"rule_id": 2322,
"rule_name": "Product Discount",
"type": "discount",
"effect_type": "percentage",
"distribution_type": "individual_items",
"select_customers": "loyalty",
"value": 100,
"line": 1
},
{
"rule_id": 2323,
"rule_name": "Holiday Points Bonus",
"type": "points",
"effect_type": "direct_value",
"distribution_type": "total",
"select_customers": "all_customers",
"value": 600,
"value_as_money": 6,
"line": -1
}
],
"total_discount_promotion_applied": 14,
"total_discount_voucher_applied": 3,
"rejected_campaigns": [
{
"rule_id": 2401,
"rule_name": "Summer 20%",
"type": "discount",
"error": "The campaign budget was reached"
}
],
"invalid_coupons": []
}
line: -1 means the effect applies to the cart total rather than to a specific line.
Watch the units. On a discount effect, value is the resulting discount in cents β including for percentage, where it is the calculated amount and not the percentage itself. On a points effect, value is a number of points and value_as_money its money equivalent. Cart-level totals β total_discount_applied, total_discount_voucher_applied, total_discount_promotion_applied β are money amounts, and score is the total points won.
Effect typesβ
effect_type | What it does |
|---|---|
percentage | Applies a percentage. Decimals are supported β 0.8 means 0.8%. |
direct_value | A fixed amount of money or points. |
ratio | "Every X, give Y" β input value and output value. Every β¬1 spent β 10 points; every β¬100 spent β β¬10 off. |
strikethrough | Sets a final price for specific products, overriding their original price. Ignores conditions and application rules. |
combo_price | A fixed combined price for a group of products; the difference is distributed across the participating lines. |
rollback | Reverses a previously applied coupon on a return or refund. |
Distribution typesβ
distribution_type | How the value is allocated |
|---|---|
total | To the whole cart total. Not available for strikethrough. |
individual_items | Line by line. With direct_value the amount applies to each line, it is not split. A line only ever absorbs up to its own value. |
individual_items_pro_rata | Line by line, proportionally to each line's total, so higher-value lines take a larger share. |
Rejected campaignsβ
rejected_campaigns[] lists everything the engine tried and could not apply, each with rule_id, rule_name, type and error. Surface it during integration testing β it turns "why is there no discount?" into a one-line answer. Common reasons:
error | Meaning |
|---|---|
The cart does not contain the victory conditions specified in the campaign | The cart does not meet the campaign's conditions. |
The campaign budget was reached | The campaign's total budget is exhausted. |
The total coupon usage was reached | The campaign's global usage limit is exhausted. |
The customer specific redemption limit has been reach | This customer has already used the campaign as many times as allowed. |
The total campaign discount in this event has been reached | The maximum discount per transaction was hit. |
The campaign cannot be used because the campaign exceeds the limits | A configured limit blocks the application. |
Printing vouchers on the receiptβ
The transaction does not end at the total. After confirming the cart, call POST /vouchers/print to get the batch of vouchers to print on the receipt β the campaigns triggered by this purchase are often the ones that bring the customer back.
The list is sorted by campaign priority, then voucher priority, then soonest expiry. The call marks the vouchers as printed, so the next call returns a different batch; a debug parameter suppresses that for testing.
Implementation notesβ
- Use
POST /carts/simulatefor UI preview andPOST /carts/realtimeonly when the transaction is confirmed. - Use the same cart line identifiers in simulation and confirmation to avoid different eligibility results.
- The cart endpoints do not validate integrity or coherence. A duplicated cart
id, a repeatedorderin the lines, atotalthat does not match the sum of the lines, or acustomer_idthat does not exist will all return a success response β while behind the scenes the customer earns no points and no voucher is redeemed. Validate before you send. - Generate the cart
idonce at the origin of the sale and reuse it on every retry β that identifier, not anIdempotency-Keyheader, is what stops a retriedPOST /carts/realtimefrom being applied twice. See Reliability. - If payment fails after confirmation, call
POST /carts/cancellationso campaign limits, points, and vouchers are rolled back. - If campaign conditions reference Customer profile fields, use the
attributesobject on the Customer. Legacycustom1βcustom11/custom1fβcustom8ffields are deprecated β see Custom fields β Attributes. - If another POS (online or physical) accepts the same vouchers but is not integrated as Promo Engine, that POS can call
POST /discounts/redeemto burn the code in Loyal Guru and reduce double-redemption fraud. See Vouchers redeem vs Discounts redeem.
Troubleshootingβ
| Symptom | What to check |
|---|---|
| No voucher discount at all, and no error | coupons_desired is omitted or []. That is the default and it excludes every voucher. |
coupons_desired: "selected" applies nothing | The customer never activated the voucher. See Vouchers Pre-Activation. |
| Discount appears in simulation but not in realtime | Cart payload changed between calls, campaign validity window changed, voucher was consumed, or cart ID handling differs. |
| Coupon is rejected | Check rejected_campaigns[] for the reason, and invalid_coupons[] for codes that do not exist. Then verify customer identity, voucher status, available redemptions, store scope, and date window. |
| Discount amount differs from POS expectation | In Promo Engine mode, the LG response is authoritative. Check effect_type, distribution_type, stackability, limits, and line identifiers. |
| Points look lower than expected | Points are earned on the post-discount amount. Check original_total against total per line, and the calculation order above. |
| Cashback applied less than requested | The per-line cap β 50% of original_total by default β or the available balance. Read cashback_score_desired_unused. |
| Response says success but nothing was recorded | A non-unique cart id or a repeated line order. The endpoint does not validate this and answers as if successful. |
| Cancellation does not restore a voucher immediately | Verify the original cart ID and wait for asynchronous rollback processing before retrying the same voucher. |