post https://api.voucherify.io/v1/promotions/validation
Use this method to get valid promotions for a given customer and order (private keys)
Returns
This operation returns a list of valid promotions for a given context (customer and order). You can choose which promotion to apply for example by the highest discount amount.
{
"valid": true,
"promotions": [
{
"valid": true,
"applicable_to": { // returns the list of order items to which the product-specific discount will be applied to, the list is empty if the discount is applied to the whole order
"data": [],
"total": 0,
"data_ref": "data",
"object": "list"
},
"inapplicable_to": { // returns the list of excluded order items to which the product-specific discount won't be applied to
"data": [],
"total": 0,
"data_ref": "data",
"object": "list"
},
"order": { // presents calculations of applied discounts and order total
"amount": 180000,
"discount_amount": 1000,
"total_discount_amount": 1000,
"total_amount": 179000,
"applied_discount_amount": 1000,
"total_applied_discount_amount": 1000,
"items": [
{
"object": "order_item",
"product_id": "prod_f1r5Tpr0DuC7",
"quantity": 2,
"amount": 360000,
"price": 180000,
"subtotal_amount": 360000,
"product": {
"id": "prod_f1r5Tpr0DuC7",
"source_id": "test_prod_id_1",
"name": "Apple iPhone 8"
}
}
],
"customer_id": null,
"referrer_id": null,
"object": "order"
},
"id": "promo_KTmj6j2TGjvKXiHBeesbyh4w",
"name": "Spring Flashsale '21 level 1",
"banner": "level 1",
"discount": {
"type": "AMOUNT",
"effect": "APPLY_TO_ORDER",
"amount_off": 1000
},
"start_date": "2021-04-20T00:00:00.000Z",
"expiration_date": "2021-08-31T00:00:00.000Z",
"campaign": { // returns details of a campaign to which the validated tier belongs
"id": "camp_MqiHYL4bXXKdHheXQEAvShEU",
"start_date": "2021-04-20T00:00:00.000Z",
"expiration_date": "2021-08-31T00:00:00.000Z",
"active": true,
"object": "campaign"
},
"hierarchy": 2, // when customer qualifies for more than one promotion tier, hirarchy decides which can be applied
"discount_amount": 1000,
"applied_discount_amount": 1000,
"metadata": {
"channel": [
"L1",
"L2"
]
},
"object": "promotion_tier"
}
]
}
If a validation session is established then the session details will be returned as well. Read more about sessions: Validation Session
Advanced validation filters
You can narrow down validation to specific promotion ID or tier metadata. Here are the examples of filtering queries you can use:
Filter | Example |
---|---|
promotion_id | [filters][promotion_id][conditions][$is]={{Campaign_id}} |
tier metadata | [filters][metadata.{{Promotion tier metadata key}}][conditions][$is]={{Promotion tier metadata value}} |