Sample Scenario of Offer Creation
This section describes how to create a sample offer using Public API calls.
Offer details:
- Create an Offer with a 2% Discount from the Total Amount of the Basket
- Name: 2% Off from the Total Price
- Description: 2% off from the total price for all items in the sale basket (1 or more items added to the basket).
- Restrictions: no restrictions, all items, any day of the week.
Every offer in Vynamic Engage must be linked to a promotion while every promotion has to be linked to a campaign. Use the following endpoints:
| Steps | Endpoint |
|---|---|
| 1. Create a campaign with promotion | POST /campaigns |
2. Get the promotionId of the promotion belonging to your campaign | GET /campaigns/{campaignId}/promotions |
| 3. Create an offer | POST/ offers |
1. Create a Campaign with Promotion - POST /campaigns
Request
Required Body Parameters
| Parameter | Description | Schema |
|---|---|---|
| name | Campaign name, for example: Campaign 1 | string |
| description | Campaign description, for example: First Campaign | string |
| startDate | Campaign start date*, for example: 2024-11-30 | string |
| endDate | Campaign end date*, for example: 2024-11-30 | string |
| promotions.name | Promotion name, for example: Discount | string |
| promotions.description | Promotion description, for example: Discount | string |
| promotions.startDate | Promotion start date*, for example: 2024-11-30 | string |
| promotions.endDate | Promotion end date*, for example: 2025-12-31 | string |
*Date format in the REST API is 'YYYY-MM-DD', for example '2024-11-30'.
Optional Body Parameters
| Parameter | Description | Schema |
|---|---|---|
| status | Campaign status. Possible values: Active, Inactive* | string |
| promotions.status | Promotion status. Possible values: Active, Inactive* | string |
*if empty, the default value set in the VE backend system is active.
Sample request:
202: Response
Required Parameters:
| Parameter | Description | Schema |
|---|---|---|
| CampaignId | ID of the created campaign (internal ID) | integer (int32) |
Optional Parameters:
| Parameter | Description | Schema |
|---|---|---|
| AccountId | Currently, the Account ID always has value 1. | integer (int32) |
| Result | Result of the action. The allowed values: ERROR, SUCCESS | string |
Sample response:
2. Obtain the promotionId - GET /campaigns/{campaignId}/promotions
promotionId - GET /campaigns/{campaignId}/promotionsRequired URI Parameter in the request:
| Parameter | Description | Schema |
|---|---|---|
| campaignId | Unique identifier of the campaign, use the CampaignId generated in the previous call. | integer |
Sample response:
3. Create an Offer with a 2% Discount from the Total Price - POST /offers
Offers are the main objects defined by the Marketing Service. They describe a set of conditions and benefits related to the purchase of specific products. When the conditions configured within the framework of the offer are met, its benefits are granted by the Discount Engine.
Request
Required Body Parameters
| Parameter | Description | Schema |
|---|---|---|
| campaignId | The Campaign to which the offer is linked | integer |
| promotionId | The Promotion that contains the offer that will be created. | integer |
| name | Offer name, in this case: 2% Off from the Total Price | string |
| startDate | The first day of the offer validity period. The date should fall within the promotion duration period, anywhere from its start to its end date. | string |
| endDate | The last day of the offer validity period. The date should fall within the promotion duration period, anywhere from its start to its end date. | string |
| benefitDefinition | Define what kind of benefit should be granted when offer is executed. | object |
| benefitDefinition.type | Type of the benefit. Allowed: Discount, LoyaltyPoints, Coupon, Stamp, Voucher, Message | string |
| bestPriceSorting | Defines the sorting performed by the Discount Engine in the background when deciding which items should be discounted. | string |
| priority | Defines the order in which offers are applied. The benefit with the highest priority is calculated first. | integer |
calculationDefinition > quantityActions
| Parameter | Description | Schema |
|---|---|---|
| quantity | Number of items matching ItemsQualifier in the basket | number |
| calculationType | Benefit calculation type. The allowed values: Percent, Value, NewPrice | string |
| calculationValue | Benefit calculation value, in this example: 2 (2%) | number |
| operator | The allowed values: EveryNth, EveryGroupOfN, AllBelowOrEqual, AllAbove, Threshold, AllAboveOrEqual | string |
| itemsQualifier | Defines the conditions for items that are part of the offer calculation. | object |
| itemsQualifer.qualifierElements.qualifierType | The allowed values: PosItems, PosItemsExclusion, ItemGroups, ItemGroupsExclusion, Categories, CategoriesExclusion, Departments, DepartmentsExclusion, DepartmentGroups, DepartmentGroupsExclusion, AllItems | string |
| countingType | The flag that determines how items are counted when the discount is triggered by a specific number of items. The allowed values: CountAll, GroupSameItems. The CountAll value means that the action is performed for any qualified item. | string |
Sample request:
Time Condition: The default value takes all days of the week from "00:00:00" to "23:59:59". The system sets the default value, if the value is not provided.
Sample response: