The Earn Cart Promotion API enables the immediate granting of cart promotions to specific customers. This direct earning capability means cart promotions can be associated with a customer's cart and made available for redemption subject to defined conditions directly through a transaction or other activity. This allows redemption without the need for prior evaluation, which streamlines the cart promotion awarding process.
Example request
curl --location 'https://{Host}/api_gateway/v1/promotions/6905a9ffb1cfc114606f7d0f/earn' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic Z2VvcmdlLmJ1a2w6NzNDkxOZjU4ZjY3MmNhZjY1ZmY=' \
--header 'Cookie: _cfuvid=jNvilmDWuR7ZrrAPT99zZDUXtjJoxe_VUUWJf6
--data '{
"customerId": 567205858,
"earnedFromType": "ACTIVITY",
"earnedFromId": "TXN_12345_ABC",
"eventTime": 1761748253000,
"eventDetails": {
"id": "TXN_12345_ABC",
"type": "TransactionAdd",
"eventPayload": {
"storeId": 101,
"amount": 75.50
}
}
}'Prerequisites
- Authentication: Basic or OAuth authentication.
- Default access group
Resource information
| Pagination | No |
| Batch support | No |
Path parameters
| Field | Type | Required | Description |
|---|---|---|---|
| promotionId | string | Yes | Defines the unique identifier of the cart promotion being earned. |
Body parameters
Field | Type | Required | Description |
|---|---|---|---|
customerId | Long | Yes | Specifies the unique identifier for the customer earning the cart promotion. |
earnedFromType | Enum | Yes | Specifies how the cart promotion was earned. ACTIVITY: Triggered by a specific customer event. • MILESTONE: Triggered by achieving a predefined milestone. • REWARD: Granted as a reward. |
earnedFromId | String | Yes | Defines the unique ID generated after issuing the cart promotion. |
eventTimeISO | Long | Conditional | Specifies the timestamp when the earning event occurred, in UTC. |
eventTime | String | Conditional | Defines the date on which the customer performed the activity in ISO 8601 format in UTC and is independent of the user’s local time zone. For example: The activity was performed at 15:00:00 on September 10, 2025. Format for the request parameter: 2025-09-10T15:00:00Z Notes: This parameter overrides the value set in the earnEventDate parameter. The earnEventDate parameter is only used if earnEventDateISO is null. This date can be set up to 24 hours in the future from the current time. For direct-earn badges, the date must fall between the badge's start and end dates. For issue & earn badges, the date must be between the badge issual start and end date. A past date can be entered to issue a badge against an older transaction. |
eventDetails | Object | Yes | Specifies the details about the triggering event. |
.id | String | Yes | Specifies the unique ID of the event itself. Often matches |
.type | String | Yes | Specifies the type of event that triggered the earning. Possible values: |
.eventPayload | Object | Optional | Defines a key-value map for storing additional event data. The structure is user-defined Eg., {"storeId": 101, "amount": 75.50}). |
Example response
{
"data": {
"id": "6905ad0ecd58392443591e92",
"customerId": 567205858,
"promotionId": "6905a9ffb1cfc114606f7d0f",
"earnedFromType": "ACTIVITY",
"earnedFromId": "TXN_12345_ABC",
"eventTime": 1761748253000,
"eventTimeISO": "2025-10-29T14:30:53Z",
"eventDetails": {
"id": "TXN_12345_ABC",
"type": "TransactionAdd",
"eventPayload": {
"storeId": 101,
"amount": 75.5
}
},
"validTill": 1825085406000,
"validTillISO": "2027-11-01T16:10:06Z"
}
}Response parameters
Field | Type | Description |
|---|---|---|
data | Object | Defines the container for the details of the successfully created earning cart promotion. |
.id | String | Specifies the unique identifier for this earning cart promotion. |
.customerId | Long | Specifies the ID of the customer who earned the cart promotion. |
.promotionId | String | Specifies the ID of the cart promotion definition that was earned. |
.earnedFromType | Enum | Indicates how the cart promotion was earned. |
.earnedFromId | String | Indicates the identifier related to the earning trigger. |
.eventTime | Long | Specifies the timestamp when the earning occurred in UTC timezone. Time format: Unix epoch milliseconds. |
.eventTimeISO | String | Specifies the earning timestamp in UTC timezone. |
.eventDetails | Object | Defines details about the triggering event. |
.validTill | Long | Specifies the timestamp when this earning cart promotion expires Calculated based on cart promotion configuration. |
.validTillISO | String | Specifies the expiry timestamp in UTC timezone. |
errors | Array | Defines an array of error objects. |
Error codes
| Code | Description |
|---|---|
| 400 | Bad Request: Indicates an invalid request body. Check required fields, data types , enum values, or JSON format. |
| 401 | Unauthorized: Indicates invalid or missing authentication credentials. |
| 403 | Forbidden: Indicates insufficient permissions to trigger cart promotion earnings. |
| 404 | Not Found: Indicates the specified cart promotionId in the URL does not exist. |
| 409 | Conflict: Indicates a potential business rule violation. |
| 500 | Internal Server Error: Indicates an unexpected server error occurred. Retry the request. |
