Create streaks

A streak refers to a consecutive series of actions or engagements by a customer, based on which loyalty benefits are provided.

You can create a streak using the Create target group API.

👍

Note

For detailed information about our APIs and for hands-on testing, refer documentation in API overview and step-by-step guide on making your first API call in Make your first API call .

Prerequisites

  • Authentication: Basic/OAuth authentication
  • Default access group

Resource information

URIv3/targetGroups
HTTP methodPOST
PaginationNA
Rate limitNA
Batch supportNA

API endpoint example

https://eucrm.cc.capillarytech.com/v3/targetGroups

Request body parameters

Parameter NameData TypeDescription
activeBooleanIndicates if the tracking is active or not.
descriptionStringA brief description of the target group.
name*StringThe name identifier for the target group.
The character limit for the name is 200 characters.
preferredTillIdNumberIdentifier for a preferred till.
trackingType*StringThe type of tracking the milestone is created for. Supported values:

- Default (single target tracking)
- Unified (tracking multiple targets as a unit)
- Streaks (continuous tracking across cycles)
- Capping (track and cap points over a period).
To create a streak, use STREAKS.
targetEvaluationTypeStringThe evaluation strategy for the targets. Supported values:
- FIXED_CALENDAR_WINDOW: Runs for a defined period from the start date
- CYCLIC_WINDOW: Starts after user's first transaction
- PERIOD_AGNOSTIC_WINDOW: Continues until the user meets the target.
totalPeriodsNumberThe total number of periods over which the tracking is evaluated.
frequencyTypeEnumThe frequency of each cycle. Supported values: Monthly, Quarterly, Half-yearly, Yearly, Weekly.
userCreatedBooleanIf true, a user-created target group is created. This allows customers to set and be rewarded for their own goals.
frequencyNumberThe frequency count, relevant to the frequencyType.
recurringCyclesNumberThe number of cycles for which the tracking recurs.
periodsObjectAn array of period objects containing details about individual tracking periods.
periods.activeBooleanIndicates if the period is active.
periods.descriptionStringA brief description of the period.
periods.endDateDate TimeThe end date and time of the period.
periods.periodStatusStringIndicates if the cycle of the milestone is active/inactive.
periods.refCodeStringA reference code for the period.
periods.startDateDate TimeThe start date and time of the period.
targetsObjectAn array of target objects outlining each target in the tracking.
targets.activeBooleanIndicates if the target is active.
targets.descriptionStringA brief description of the target.
targets.expressionStringA string representing the condition to meet the target.
targets.expressionJsonStringA JSON expression specifying the conditions required to achieve the target.
targets.filtersObjectDefines the entity to which the target expressions apply.
targets.filters.entityTypeEnumEntity to which expressions apply. Must satisfy the target condition. Supported values: STORE, ZONE, CONCEPT.
targets.filters.entityIdsArrayThe IDs of the entities to which the filter is applied.
targets.nameStringThe name identifier for the target.
targets.targetEntityEnumThe KPI being tracked. Supported values: TRANSACTION, LINEITEM, EVENT, REWARDS.
Use TRANSACTION or LINEITEM for transactional KPIs.
Use EVENT for behavioural/EMF events.
Use REWARDS for tracking reward-based KPIs like points.
targets.eventNameStringThe name of the behavioural event that triggers the target.
targets.targetType*EnumType of target. Supported values: QUANTITY, SALES, COUNT, VISIT, GROSS_SALES, REGULAR_POINTS, PROMOTIONAL_POINTS, ALL_POINTS, EXTENDED_FIELD, EVENT_ATTRIBUTE.
To use SUM for behavioural events, set to EVENT_ATTRIBUTE and define it using extendedFieldInfo.
extendedFieldInfoObjectDetails of the event attribute being tracked. Applicable when targetType is SUM.
extendedFieldInfo.name*StringEvent on which the sum calculation is performed. E.g., number of 'add to cart' events.
extendedFieldInfo.aggregateFunctionEnumAggregate function used to evaluate behavioural events. Supported: SUM. E.g., use SUM to track total cart value and validate against target.
defaultValuesObjectAn array of objects defining default values for the target.
defaultValues.defaultValueIntegerA default value used during target evaluation.
streaks*ObjectAn array containing streak information. Required when trackingType is STREAKS.
streaks.name*StringName of the streak.
streaks.targetCountOfSequence*IntegerNumber of times a user must meet the target to earn the reward.
{
    "data": {
        "id": 9919,
        "name": "streakTestt123",
        "active": true,
        "preferredTillId": 0,
        "periods": [
            {
                "id": 10678,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "startDate": "2023-11-17",
                "endDate": "2023-11-17",
                "refCode": "period44",
                "periodStatus": "RUNNING",
                "targetGroupId": 9919,
                "description": "p1",
                "active": true
            },
            {
                "id": 10679,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "startDate": "2023-11-18",
                "endDate": "2023-11-20",
                "refCode": "period45",
                "periodStatus": "NOT_STARTED",
                "targetGroupId": 9919,
                "description": "p1",
                "active": true
            }
        ],
        "streaks": [
            {
                "id": 9,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "targetGroupId": 9919,
                "name": "streakTestt193",
                "targetCountOfSequence": 1
            },
            {
                "id": 10,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "targetGroupId": 9919,
                "name": "streakTestt123",
                "targetCountOfSequence": 2
            }
        ],
        "totalPeriods": 1,
        "description": "streak group",
        "targetEvaluationType": "FIXED_CALENDAR_WINDOW",
        "targetCycleStartDate": "2023-11-17T00:00:00.000Z",
        "targetCycleEndDate": "2023-11-20T23:59:59.000Z",
        "frequencyType": "CUSTOM",
        "trackingType": "STREAKS",
        "targets": [
            {
                "id": 22030,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.612+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.612+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "name": "streakTestt123",
                "emfRuleSetId": 1200627,
                "targetType": "SALES",
                "targetEntity": "TRANSACTION",
                "eventName": "TransactionAdd",
                "targetGroupId": 9919,
                "description": "streak",
                "active": true,
                "expression": "currentTxn.value>500",
                "expressionJson": "{\"arity\":\"binary_operation\",\"value\":\">\",\"type\":\"boolean:primitive\",\"operands\":[{\"arity\":\"object_dereference\",\"type\":\"real:object:primitive\",\"operands\":[{\"arity\":\"name\",\"value\":\"currentTxn\",\"type\":\"tx:object:primitive\"},{\"arity\":\"name\",\"value\":\"value\",\"type\":\"real:object:primitive\"}]},{\"arity\":\"literal\",\"value\":\"500\",\"type\":\"number:primitive\"}]}",
                "filters": [
                    {
                        "entityType": "STORE",
                        "entityIds": [
                            50679757,
                            50679770
                        ]
                    }
                ],
                "enrolmentMethod": "TRANSACTION",
                "defaultValues": [
                    {
                        "id": 24105,
                        "periodId": 10678,
                        "defaultValue": 500.000
                    },
                    {
                        "id": 24106,
                        "periodId": 10679,
                        "defaultValue": 1000.000
                    }
                ]
            },
            {
                "id": 22031,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.789+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.789+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "name": "streakTestt123_ReturnBill",
                "emfRuleSetId": 1200628,
                "targetType": "SALES",
                "targetEntity": "TRANSACTION",
                "eventName": "ReturnBill",
                "targetGroupId": 9919,
                "description": "streak",
                "active": true,
                "expression": "currentTxn.value>500",
                "expressionJson": "{\"arity\":\"binary_operation\",\"value\":\">\",\"type\":\"boolean:primitive\",\"operands\":[{\"arity\":\"object_dereference\",\"type\":\"real:object:primitive\",\"operands\":[{\"arity\":\"name\",\"value\":\"currentTxn\",\"type\":\"tx:object:primitive\"},{\"arity\":\"name\",\"value\":\"value\",\"type\":\"real:object:primitive\"}]},{\"arity\":\"literal\",\"value\":\"500\",\"type\":\"number:primitive\"}]}",
                "filters": [
                    {
                        "entityType": "STORE",
                        "entityIds": [
                            50679757,
                            50679770
                        ]
                    }
                ],
                "enrolmentMethod": "TRANSACTION",
                "defaultValues": [
                    {
                        "id": 24107,
                        "periodId": 10678,
                        "defaultValue": 500.000
                    },
                    {
                        "id": 24108,
                        "periodId": 10679,
                        "defaultValue": 1000.000
                    }
                ]
            }
        ]
    },
    "errors": null,
    "warnings": null
}

Response parameters

FieldDatatypeDescription
idintegerUnique identifier for the group.
namestringName of the group.
activebooleanIndicates if the group is active.
preferredTillIdintegerPreferred till ID, indicating no specific preference with 0.
totalPeriodsintegerTotal number of periods specified.
descriptionstringDescription of the /roup.
targetEvaluationTypestringType of target evaluation, e.g., "FIXED_CALENDAR_WINDOW".
targetCycleStartDatestring (date-time)Start date and time for the target cycle.
targetCycleEndDatestring (date-time)End date and time for the target cycle (if applicable).
frequencyTypestringFrequency type, e.g., "CUSTOM" (if applicable).
trackingTypestringType of tracking, e.g., "STREAKS" (if applicable).
fromDatestring (date)Start date for the setting (if applicable).
toDatestring (date)End date for the setting (if applicable).
recurringCyclesintegerNumber of recurring cycles specified (if applicable).
frequencyintegerFrequency value set for the setting (if applicable).
idintegerUnique identifier for each period.
startDatestring (date)Start date for each period.
endDatestring (date)End date for each period.
refCodestringReference code for each period.
periodStatusstringStatus of each period, e.g., "RUNNING", "NOT_STARTED".
targetGroupIdintegerIdentifier linking each period to a target group.
descriptionstringDescription of each period.
activebooleanIndicates if each period is active.
idintegerUnique identifier for each streak.
namestringName of each streak.
targetCountOfSequenceintegerTarget count of sequence for each streak.
idintegerUnique identifier for each target.
namestringName of each target.
targetTypestringType of each target, e.g., "SALES".
targetEntitystringType of entity targeted by each target, e.g.
eventNamestringName of the event associated with each target.
descriptionstringDescription of each target.
activebooleanIndicates if each target is active.
expressionstringExpression defining the criteria for each target.
expressionJsonstring (JSON)Target expression in JSON format for each target.
entityTypestringType of entity for the filter of each target.
entityIdsarray of integersIDs of entities for the filter of each target.
enrolmentMethodstringMethod of enrolment for each target.
defaultValuefloatSpecifies a default value for the target criteria for each target.
{
    "data": {
        "id": 9919,
        "name": "streakTestt123",
        "active": true,
        "preferredTillId": 0,
        "periods": [
            {
                "id": 10678,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "startDate": "2023-11-17",
                "endDate": "2023-11-17",
                "refCode": "period44",
                "periodStatus": "RUNNING",
                "targetGroupId": 9919,
                "description": "p1",
                "active": true
            },
            {
                "id": 10679,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "startDate": "2023-11-18",
                "endDate": "2023-11-20",
                "refCode": "period45",
                "periodStatus": "NOT_STARTED",
                "targetGroupId": 9919,
                "description": "p1",
                "active": true
            }
        ],
        "streaks": [
            {
                "id": 9,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "targetGroupId": 9919,
                "name": "streakTestt193",
                "targetCountOfSequence": 1
            },
            {
                "id": 10,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "targetGroupId": 9919,
                "name": "streakTestt123",
                "targetCountOfSequence": 2
            }
        ],
        "totalPeriods": 1,
        "description": "streak group",
        "targetEvaluationType": "FIXED_CALENDAR_WINDOW",
        "targetCycleStartDate": "2023-11-17T00:00:00.000Z",
        "targetCycleEndDate": "2023-11-20T23:59:59.000Z",
        "frequencyType": "CUSTOM",
        "trackingType": "STREAKS",
        "targets": [
            {
                "id": 22030,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.612+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.612+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "name": "streakTestt123",
                "emfRuleSetId": 1200627,
                "targetType": "SALES",
                "targetEntity": "TRANSACTION",
                "eventName": "TransactionAdd",
                "targetGroupId": 9919,
                "description": "streak",
                "active": true,
                "expression": "currentTxn.value>500",
                "expressionJson": "{\"arity\":\"binary_operation\",\"value\":\">\",\"type\":\"boolean:primitive\",\"operands\":[{\"arity\":\"object_dereference\",\"type\":\"real:object:primitive\",\"operands\":[{\"arity\":\"name\",\"value\":\"currentTxn\",\"type\":\"tx:object:primitive\"},{\"arity\":\"name\",\"value\":\"value\",\"type\":\"real:object:primitive\"}]},{\"arity\":\"literal\",\"value\":\"500\",\"type\":\"number:primitive\"}]}",
                "filters": [
                    {
                        "entityType": "STORE",
                        "entityIds": [
                            50679757,
                            50679770
                        ]
                    }
                ],
                "enrolmentMethod": "TRANSACTION",
                "defaultValues": [
                    {
                        "id": 24105,
                        "periodId": 10678,
                        "defaultValue": 500.000
                    },
                    {
                        "id": 24106,
                        "periodId": 10679,
                        "defaultValue": 1000.000
                    }
                ]
            },
            {
                "id": 22031,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.789+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.789+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "name": "streakTestt123_ReturnBill",
                "emfRuleSetId": 1200628,
                "targetType": "SALES",
                "targetEntity": "TRANSACTION",
                "eventName": "ReturnBill",
                "targetGroupId": 9919,
                "description": "streak",
                "active": true,
                "expression": "currentTxn.value>500",
                "expressionJson": "{\"arity\":\"binary_operation\",\"value\":\">\",\"type\":\"boolean:primitive\",\"operands\":[{\"arity\":\"object_dereference\",\"type\":\"real:object:primitive\",\"operands\":[{\"arity\":\"name\",\"value\":\"currentTxn\",\"type\":\"tx:object:primitive\"},{\"arity\":\"name\",\"value\":\"value\",\"type\":\"real:object:primitive\"}]},{\"arity\":\"literal\",\"value\":\"500\",\"type\":\"number:primitive\"}]}",
                "filters": [
                    {
                        "entityType": "STORE",
                        "entityIds": [
                            50679757,
                            50679770
                        ]
                    }
                ],
                "enrolmentMethod": "TRANSACTION",
                "defaultValues": [
                    {
                        "id": 24107,
                        "periodId": 10678,
                        "defaultValue": 500.000
                    },
                    {
                        "id": 24108,
                        "periodId": 10679,
                        "defaultValue": 1000.000
                    }
                ]
            }
        ]
    },
    "errors": null,
    "warnings": null
}

API error codes

CodeDescription
310069Target group name already exists
300004Invalid input, check all values and ensure they are correct.
310008Length of Target rule name cannot exceed 200
Language
Credentials
Basic
base64
:
URL
Click Try It! to start a request and see the response here!