Apply rewards to an order

The apply endpoint is used to apply promotions to an order in an e-commerce system. A successful call to this endpoint will;

  1. qualify any currently applied promotions in the order to ensure they still apply

  2. validate and apply the coupon code sent with the request, if any

  3. and apply any automatic promotions that the order qualifies for.

The promotion combination rules that you have configured on your account will decide if and how multiple promotions are applied to an order.

All successfully applied promotions will be returned in the appliedPromotions property of the Order object in the response. This is a combination of successfully applied automatic promotions and any coupon code or promotion that you specified in the request.

You should always pass back the array of applied promotions in the Order object with subsequent requests to the apply endpoint so that the applied promotions can be checked against the updated cart or order to ensure they still meet the qualification rules of the promotion.

Free items the customer chooses

A free item promotion may offer several products for the customer to pick from. When one is applied we add the first of them to the order at no charge and return all of them on the applied reward, as freeItemPool, so you can present the choice.

Once the customer has picked, call apply again with the top level freeItemSelection. It is for a free item promotion the order is already carrying. You only need to send it when the choice changes: as long as you keep echoing the applied promotion back to us with its appliedReward untouched, the items on its appliedReward.products are granted again. Without appliedReward we cannot tell the promotion has a choice to change: a freeItemSelection aimed at it is refused, and the promotion falls back to its default.

It may accompany a code: applying one promotion and re-choosing the free item on another are independent. What it cannot do is name the promotion the same call is applying, since that promotion is not applied yet, and a choice we cannot tie to an applied promotion is returned as an error rather than quietly dropped.

Every chosen product must appear in freeItemPool, the total quantity must not exceed the reward's quantity, and no single product may exceed its own maxQuantity. The same item may be chosen more than once. A freeItemSelection that does not hold up costs the customer the choice, not the promotion: the reason comes back in errors and the promotion stays applied on whatever it was granting before.

What the basket already holds is judged differently. If the promotion has been reconfigured since it was applied and the items on its appliedReward.products are no longer something it can grant, the promotion no longer qualifies and is not applied again -- the same answer a product bundle gives when its configuration moves. Apply the code again to be offered the new freeItemPool. An automatic promotion is exempt, because it is re-evaluated from scratch on every call rather than carried.

The free items we add come back in order.products at a price of 0 and marked with freeItem. Send that marker back on them and we will replace those lines on the next call rather than adding another copy of them. A line sent without the marker is treated as the customer's own and kept, so leaving it out means the free item is granted again on top.

See the guide on Reward Application for more information.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
Body Params
order
object
required

A representation of a customer order

string
string | null

A unique reference for linking a unique coupon code to a customer. This can be any attribute as long as it's unique to the customer e.g. an email address.

customer
object
string | null

This parameter could be based on your different e-commerce applications, brands, regions or a combination of both. Important for segmenting your promotions and accounts or enforcing qualification rules.

string | null

An identifier for the customer journey for linking a customer's checkout session to the promotion engine events. This is also required for preventing a unique code from being used in multiple simultaneous checkout sessions. See more on Validation Locking.

You can use your own value, such as the checkout session identifier, for this parameter or let let Uniqodo generate one for you. If this parameter is not present in the request then a new one will be generated and returned in the response. You should store the journey ID value (typically with the customer's checkout session) and pass it back with subsequent requests until the checkout session ends.

string

A two-letter ISO 639-1 language code. This is required for error message translations. See https://iso639-3.sil.org/code_tables/639/data?title=&field_iso639_cd_st_mmbrshp_639_1_tid=255291.

string

The ID of the Promotion. This can be found as the Long ID on the promotion details page

metadata
object

This field allows storing any related metadata. The keys of the object can be strings and the values can be any type.

freeItemSelection
object

The free items the customer has chosen, for a free item promotion the order is already carrying.
Send it only to change the choice; one already granted is remembered for as long as you echo its applied promotion back with its appliedReward. It may accompany a code aimed at a different promotion, but it cannot name the promotion this call is applying.
Give promotionId when the order holds more than one free item promotion.

Responses

Language
Credentials
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json