Skip to main content

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:

SystemResponsibility
Loyal GuruEvaluates active campaigns, coupons, vouchers, stackability, limits, customer eligibility, product/store scope, and returns calculated effects[].
POS / e-commerceSends 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.

MechanicWhere it appears in the response
Discounts β€” massive, loyalty member, and targeted voucherseffects[] with type: discount
Points earnedeffects[] with type: points
Points redeemed as cashbackcashbacks[], driven by cashback_score_desired
Games and challengesEvaluated on the confirmed cart; surfaced through the Visualization connection

Campaigns come in three audiences, and the same cart can trigger all three at once:

AudienceAPI valueWho it reaches
MASSall_customersEvery customer, identified or not
CLUBloyaltyEnrolled loyalty members
TARGETEDtargetedA 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.

note

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:

StepEndpointPurpose
PreviewPOST /carts/simulateCalculates discounts and points without persisting the cart or consuming vouchers.
ConfirmPOST /carts/realtimePersists the cart, commits effects, and updates voucher/coupon usage.
CancelPOST /carts/cancellationRolls back the confirmed cart effects. Wait at least 5 minutes after the original cart creation.
PrintPOST /vouchers/printReturns 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".

ValueWhat 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 omittedOnly 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: -1 to 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 total is 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_typeWhat it does
percentageApplies a percentage. Decimals are supported β€” 0.8 means 0.8%.
direct_valueA 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.
strikethroughSets a final price for specific products, overriding their original price. Ignores conditions and application rules.
combo_priceA fixed combined price for a group of products; the difference is distributed across the participating lines.
rollbackReverses a previously applied coupon on a return or refund.

Distribution types​

distribution_typeHow the value is allocated
totalTo the whole cart total. Not available for strikethrough.
individual_itemsLine 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_rataLine 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:

errorMeaning
The cart does not contain the victory conditions specified in the campaignThe cart does not meet the campaign's conditions.
The campaign budget was reachedThe campaign's total budget is exhausted.
The total coupon usage was reachedThe campaign's global usage limit is exhausted.
The customer specific redemption limit has been reachThis customer has already used the campaign as many times as allowed.
The total campaign discount in this event has been reachedThe maximum discount per transaction was hit.
The campaign cannot be used because the campaign exceeds the limitsA 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/simulate for UI preview and POST /carts/realtime only 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 repeated order in the lines, a total that does not match the sum of the lines, or a customer_id that 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 id once at the origin of the sale and reuse it on every retry β€” that identifier, not an Idempotency-Key header, is what stops a retried POST /carts/realtime from being applied twice. See Reliability.
  • If payment fails after confirmation, call POST /carts/cancellation so campaign limits, points, and vouchers are rolled back.
  • If campaign conditions reference Customer profile fields, use the attributes object on the Customer. Legacy custom1–custom11 / custom1f–custom8f fields 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/redeem to burn the code in Loyal Guru and reduce double-redemption fraud. See Vouchers redeem vs Discounts redeem.

Troubleshooting​

SymptomWhat to check
No voucher discount at all, and no errorcoupons_desired is omitted or []. That is the default and it excludes every voucher.
coupons_desired: "selected" applies nothingThe customer never activated the voucher. See Vouchers Pre-Activation.
Discount appears in simulation but not in realtimeCart payload changed between calls, campaign validity window changed, voucher was consumed, or cart ID handling differs.
Coupon is rejectedCheck 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 expectationIn Promo Engine mode, the LG response is authoritative. Check effect_type, distribution_type, stackability, limits, and line identifiers.
Points look lower than expectedPoints are earned on the post-discount amount. Check original_total against total per line, and the calculation order above.
Cashback applied less than requestedThe per-line cap β€” 50% of original_total by default β€” or the available balance. Read cashback_score_desired_unused.
Response says success but nothing was recordedA 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 immediatelyVerify the original cart ID and wait for asynchronous rollback processing before retrying the same voucher.