This API is used to create a loyalty promotion. A loyalty promotion rewards customers for achieving a target.
Prerequisites
- Authentication: Basic/OAuth authentication
- Default access group
Resource information
URI | v1/programs\{programId\} /createPromotion\{promotionType\} |
HTTP method | POST |
Pagination | NA |
Rate limit | NA |
Batch support | NA |
API endpoint example
https://eu.api.capillarytech.com/api_gateway/loyalty/v1/programs/699/createPromotion/simple
Request path parameters
Parameter | Data Type | Description |
---|---|---|
programID | Integer | Unique ID of the loyalty program. |
promotionType | String | Type of promotion. Supported values: SIMPLE , RANGE , KEYWORD . |
Sample request body
{
"promotion": {
"id": -1,
"name": "promotion_name",
"programId": 2932,
"startDate": "2024-08-09T12:00:00+01:00",
"endDate": "2024-08-25T12:00:00+01:00",
"allocatePointsOn": "BILL",
"identifier": "promotion_identfier",
"eventName": "TARGETCOMPLETED",
"pointsOfferType": "LOYALTY",
"promotionType": "BILL",
"promotionSourceType": "USER_CREATED",
"limits": {
"pointsPerCustomer": -1,
"numberOfTimesPerCustomer": -1,
"totalPointsInPromotion": -1
},
"promotionRestrictions": {
"loyaltyEarningType": "ISSUE_AND_EARN",
"isStackable": false,
"isExclusive": false,
"isConsideredForRanking": false,
"targetRuleIds": [
123
],
"targetGroupIds": [
1234567
],
"restrictions": {
"redemptionRestrictions": [
{
"name": "MAX_ALLOWED_TIMES_PER_CUSTOMER",
"value": 3,
"type": "PERIOD_BASED",
"periodType": "MOVING_WINDOW",
"periodUnit": "WEEKLY"
},
{
"name": "MAX_ALLOWED_TIMES_PER_PROMOTION",
"value": 3,
"type": "NON_PERIOD_BASED"
}
],
"issualRestrictions": [
{
"name": "MAX_NUMBER_OF_ISSUALS_PER_CUSTOMER",
"value": 3,
"type": "NON_PERIOD_BASED"
}
],
"earnRestrictions": [
{
"name": "MAX_NUMBER_OF_EARNS_PER_CUSTOMER",
"value": 3
}
],
"expiryRestrictions": [
{
"name": "ISSUAL_PROMOTION_EXPIRY_BASED_ON",
"type": "PROMOTION",
"value": 10
}
]
}
},
"rulesetInfos": [
{
"id": -1,
"contextID": 2932,
"orgID": 51174,
"contextType": "program",
"endpointName": "POINTSENGINE_ENDPOINT",
"name": "rulesetName_uniqueue1",
"type": "USER_CREATED",
"startDate": 1089532593324,
"endDate": 33593126193324,
"active": true,
"rules": [
{
"id": -1,
"exp": "true",
"expJSON": "{ \"arity\": \"literal\", \"value\": \"true\", \"type\": \"boolean:primitive\" }",
"isActive": true,
"caseToActions": {
"true": [
{
"id": -1,
"actionName": "AWARD_TARGET_POINTS_ACTION",
"mandatoryPropertiesValues": {
"ProRateOnSourceValue": "EVENT_DEFAULT_VALUE",
"DelayStrategy": "AS_DEFINED_IN_ALLOCATION_STRATEGY",
"SourceValueRoundingStrategy": "ACTUAL",
"ExpiryStrategy": "81042",
"AwardStrategy": "82690",
"PointsRoundingStrategy": "ACTUAL",
"TargetGroupId": "1234567",
"TargetRuleName": "TargetRuleName"
}
}
]
},
"filterInfo": [],
"description": "",
"expDataType": "",
"ruleSetId": -1,
"updatedViaNewUI": false
}
],
"filterInfo": [
{
"id": -1,
"contextType": "RULESET",
"name": "LoyaltyType",
"description": "LoyaltyType",
"isInclude": true,
"propertyToValues": {
"loyaltyType": [
"loyalty"
]
}
},
{
"id": -1,
"contextType": "RULESET",
"name": "EventSource",
"description": "EventSource",
"isInclude": true,
"propertyToValues": {
"eventSource": [
"INSTORE"
]
}
}
],
"cappingInfo": [],
"isRulesetForGlobalPromotion": "false",
"programIds": []
}
]
}
}
Request Parameters
Parameter (Parameters marked as * are required) | Data Type | Description |
---|---|---|
| Object | Root object containing all promotion details. |
| Integer | Unique ID of the promotion. Set this value to -1 while creating a new promotion. |
| String | Unique name of the loyalty promotion. <br/>The character limit for the name is 255 characters. |
| Integer | Unique ID of the loyalty program to associate with the promotion. You can create multiple promotions under a single loyalty program. |
| String | Start date of the promotion in ISO 8601 |
| String | End date of the promotion in ISO 8601 |
| Enum | Category for point allocation. Supported values: |
| String | Unique identifier for the promotion. This is an external identifier that can be used to identify the promotion. <br/>The character limit for the identifier is 255 characters. |
| Enum | Name of the event to associate with the promotion. Supported values: |
| Enum | Type of loyalty promotion. Supported values: |
| Enum | Type of promotion. Supported values: |
| Enum | Source from where the promotion is created. Supported values: |
| Object | Promotion limits configuration. |
-- | Integer | Maximum points that can be issued per customer (set to |
-- | Integer | Maximum number of times points can be issued to a customer (set to |
-- | Integer | Total points that can be generated during the promotion (set to |
| Integer | Restriction settings for the promotion. |
-- | Enum | Type of earning. Supported values: |
-- | Boolean | Indicate if the promotion is stackable. A stackable promotion refers to the application of multiple promotions within a single transaction. <br/><br/>Refer to the documentation on promotion stacking strategies for more information. |
-- | Boolean | Indicate if the promotion is exclusive. Exclusive promotions are evaluated individually and do not stack with any other promotion. <br/>For creating a UCC promotion, set this value to |
-- | Boolean | Indicate if the promotion is considered for ranking. Rankings allow you to order promotions based on their priority. <br/>For creating a UCC promotion, set this value to |
-- | Array | List of target rule IDs. |
-- | Array | List of target group IDs. |
-- | Object | Contains details on various restrictions for redemption, issual, and earning. |
--- | Object | Contains information on the redemption limits for a promotion. |
---- | Enum | Type of redemption restriction. Supported values: <br/> |
---- | Integer | Number of units corresponding to the name. Specify the value as |
---- | Enum | Type of period for restriction. Supported values: <br/> |
---- | Enum | Type of period for the restriction. Supported value: |
---- | Enum | Frequency of the period. Supported values: |
--- | Object | Contains information on the issual limits for a promotion. |
---- | Enum | Type of issual restriction. Supported values: <br/> |
---- | Integer | Number of units corresponding to the name. Specify the value as |
---- | Enum | Type of period for restriction. Supported values: <br/> |
--- | Object | Contains information on the earn limits for a promotion. This is specific for enrol and issue type promotion. |
---- | Enum | Type of earn restriction. Supported values: <br/> |
---- | Integer | Number of units corresponding to the name. Specify the value as |
--- | Object | Contains information on the expiry for a promotion. This is mandatory for both enrol and issue and direct issue types of promotion. |
---- | Enum | Action that is expiring. Supported values: <br/> |
---- | Integer | Number of days the loyalty promotion expires from the date of issual. |
---- | Enum | Type of expiration. Supported values: <br/> |
| Object | Information about the ruleset associated with the promotion. |
-- | Integer | Unique ID of the ruleset. Set to |
-- | Integer | Unique ID of the program. |
-- | Integer | Unique ID of the organization. |
-- | String | Type of context. |
-- | String | Name of the endpoint. |
-- | String | Unique name for the ruleset. |
-- | Enum | Type of ruleset. <br/>For creating a UCC promotion, set this value to |
-- | Integer | Start date of the ruleset in Epoch time format. |
-- | Integer | End date of the ruleset in Epoch time format. |
-- | Boolean | Status of the ruleset (set to |
-- | Array | List of rules applied to the promotion. |
--- | Integer | Unique ID of the rule (set to |
--- | Boolean | Rule expression to determine if the rule is true or false. |
--- | String | Rule expression in JSON format. |
--- | Boolean | Status of the rule. |
--- | Object | Defines actions to take when the rule is satisfied. |
---- | String | Name of the action. |
---- | Object | Defines the mandatory properties for the action (e.g., |
-- | Object | Information on the scope filters applied to the ruleset. |
--- | String | Name of the filter, e.g., |
--- | Object | Key-value pairs for filter properties, e.g., |
-- | Object | Optional capping information for the ruleset. |
-- | Boolean | Indicates if the ruleset is for a global promotion. |
Sample response
{
"status": {
"code": 200,
"message": "success"
},
"validationErrors": null,
"data": [
{
"id": 200654,
"name": "test_promo_uniqueName10",
"promotionStatus": "COMPLETED",
"programId": 2822,
"startDate": "2024-08-09T00:00:00.284Z",
"endDate": "2024-08-10T23:59:59.285Z",
"identifier": "test_promo_uniqueIdentifier10",
"isActive": true,
"eventName": "TARGETCOMPLETED",
"allocatePointsOn": "BILL",
"limits": {
"pointsPerCustomer": -1,
"numberOfTimesPerCustomer": -1,
"totalPointsInPromotion": -1,
"totalPointsPerEventLimit": -1
},
"pointsOfferType": "LOYALTY",
"promotionRestrictions": {
"restrictions": {
"redemptionRestrictions": [
{
"name": "MAX_ALLOWED_TIMES_PER_CUSTOMER",
"value": 3,
"type": "PERIOD_BASED",
"periodType": "MOVING_WINDOW",
"periodUnit": "WEEKLY"
},
{
"name": "MAX_ALLOWED_TIMES_PER_PROMOTION",
"value": 3,
"type": "NON_PERIOD_BASED",
"periodType": null,
"periodUnit": null
},
{
"name": "MAX_REDEMPTIONS_PER_EARN_PER_CUSTOMER",
"value": 100,
"type": "NON_PERIOD_BASED",
"periodType": null,
"periodUnit": null
}
],
"issualRestrictions": [
{
"name": "MAX_NUMBER_OF_ISSUALS_PER_CUSTOMER",
"value": 3
}
],
"earnRestrictions": [
{
"name": "MAX_NUMBER_OF_EARNS_PER_CUSTOMER",
"value": 3
}
],
"expiryRestrictions": [
{
"name": "ISSUAL_PROMOTION_EXPIRY_BASED_ON",
"value": 10,
"type": "PROMOTION"
}
]
},
"scope": null,
"isStackable": false,
"isConsideredForRanking": true,
"loyaltyEarningType": "ISSUE_AND_EARN",
"expiryReminder": null,
"isExclusive": false,
"isAlwaysApply": false,
"targetGroupIds": [
1234567
],
"targetRuleIds": [
123
]
}
}
]
}
Response parameters
Parameter | Data type | Description |
---|---|---|
status | Object | Contains the response status. |
-code | Integer | Status code of the response (e.g., 200 for success). |
-message | String | Status message (e.g., "success"). |
validationErrors | Object | Contains validation errors, if any. Null indicates no errors. |
data | Array | Contains data related to the promotion. |
| Integer | Unique identifier for the promotion. |
| String | Name of the promotion. |
-promotionStatus | String | Current status of the promotion (e.g., “LIVE”, "COMPLETED"). |
| Integer | ID of the associated loyalty program. |
| String | Start date of the promotion in ISO 8601 format. |
| String | End date of the promotion in ISO 8601 format. |
| String | Unique identifier for the promotion. |
-isActive | Boolean | Indicates if the promotion is active. |
| String | Event that triggers the promotion. An event refers to a specific action for example a store visit or transaction. |
| String | Where points are allocated (e.g., "BILL"). |
| Object | Promotion limits. |
-- pointsPerCustomer | Integer | Maximum points a customer can earn. |
(-1 indicates no limit). | ||
-- numberOfTimesPerCustomer | Integer | Number of times a customer can participate. |
(-1 indicates no limit). | ||
-- totalPointsInPromotion | Integer | Total points available in the promotion. |
(-1 indicates no limit). | ||
-- totalPointsPerEventLimit | Integer | Total points limit per event. |
(-1 indicates no limit). | ||
| String | Type of points offered (e.g., "LOYALTY"). A points offer refers to loyalty points issued to customers |
promotionRestrictions | Object | Contains the restrictions applicable to the promotion. Restrictions can be configured while setting up the loyalty promotion. |
| Object | Contains various restriction types. |
-- redemptionRestrictions | Array | Redemption-related restrictions. These are advanced settings for redemption. |
--- name | String | Name of the redemption restriction |
--- value | Integer | Maximum allowed times per customer. |
--- type | String | Restriction type (e.g., "PERIOD_BASED"). |
--- periodType | String | Period type for restriction (e.g., "MOVING_WINDOW", FIXED_WINDOW). |
--- periodUnit | Array | Period unit for restriction (e.g., "WEEKLY", “MONTHLY”). |
-- issualRestrictions | Array | Issual related restrictions. An “issual” refers to the issuance of a specific promotion to customers based on their behavioral events or transactions. |
--- name | Array | Name of the issuance restriction |
--- value | Integer | Maximum issuances per customer. |
-- earnRestrictions | Array | Earnrelated restrictions. “Earn" refers to the process where a customer completes the necessary activities to qualify for a promotion. |
--- name | String | Name of the earning restriction |
--- value | Integer | Maximum earnings per customer. |
-- expiryRestrictions | Array | Expiry-related restrictions. |
--- name | String | Name of the expiry restriction |
--- value | Integer | Expiry value. |
--- type | String | Expiry type (e.g., "PROMOTION"). |
| Object | Scope of the promotion (if applicable). |
| Boolean | Indicates if the promotion can be combined with other promotions. |
| Boolean | Indicates if the promotion is considered for ranking. |
| String | Type of loyalty earning. |
| Object | Expiry reminder, if any. Null indicates no reminder. |
| Boolean | Indicates if the promotion is exclusive. |
| Boolean | Indicates if the promotion always applies. |
| Integer | List of target group IDs. |
| Integer | List of target rule IDs. |
API error codes
Code | Description | Solution |
---|---|---|
4007 | Promotion identifier already exists for the program | Check the promotion id and ensure it is unique. |
4003 | A promotion with the same name exists for the program | Check the promotion name and ensure it is unique. |
4011 | Given start date is null or empty | Check the promotion start date and ensure it is in the correct format |
4012 | Given end date is null or empty | Check the promotion end date and ensure it is in the correct format |
4074 | For SourceType UserCreated, TargetGroupId and TargetRuleId are mandatory | Enter the TargetGroupID and TargetRuleID for the promotion |
4079 | Promotion Source Type cannot be null or empty | Enter the promotion source type |
4075 | UCC Promotions should always have one RuleSet | Ensure that only one ruleset is passed. Add the rulesets for the promotion if not added. |
4076 | Invalid UCC Promotions Ruleset check for ruleSetName, ContextId, OrgId, ContextType and start & End is not null | Check if the mandatory rule set fields are passed. |
4076 | Invalid UCC Promotions Rules passed check for expression , expressionJson and name is not null | Check if the mandatory rule set fields are correct. |
4080 | Invalid UCC Promotions Actions, Both key and value in cannot be null or empty | Check if the mandatoryPropertiesValues key value is null or Empty. |
4078 | Invalid name in Promotions RuleSet Filter | Check the filter name and ensure it is valid. |