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 .

Example request

curl -L 'https://eu.api.capillarytech.com/v3/targetGroups' \
-H 'Content-Type: application/json' \
-H 'Cookie: _cfuvid=aidEostKQWmdskBHmh1pchvz2wSoA1O27JghNUFOpHw-1728306311172-0.0.1.1-604800000; _cfuvid=2ieM2eqBqFdNAAdfQMYR0zNvTd6WWmQxVVyU.OyFiEw-1728475108732-0.0.1.1-604800000; _cfuvid=2G0CzMo50ZKNrUvAmW0geVydLM0NOFZKEj.drnbKFus-1763644069670-0.0.1.1-604800000' \
-H 'Authorization: Basic ZmM2YjZlY2I2MmEy' \
-d '{
  "active": true,
  "description": "Target group number hundered and one",
  "name": "uatTargetGroup101",
  "trackingType": "DEFAULT",
  "targetEvaluationType": "FIXED_CALENDAR_WINDOW",
  "totalPeriods": 1,
  "frequencyType": "DAILY",
  "frequency": 1,
  "timeZoneName":"Asia/Kolkata",
  "recurringCycles": 1,
  "preferredTillId": 751552970000,
  "userCreated": false,
  "periods": [
    {
      "active": true,
      "description": "",
      "endDate": "2025-06-11T23:59:59.999Z",
      "periodStatus": "RUNNING",
      "refCode": "Cycle_1",
      "startDate": "2025-06-11T00:00:00.000Z"
    },
    {
      "active": true,
      "description": "",
      "endDate": "2025-05-11T23:59:59.999Z",
      "periodStatus": "NOT_STARTED",
      "refCode": "Cycle_2",
      "startDate": "2025-05-11T00:00:00.000Z"
    }
  ],
  "targets": [
    {
      "active": true,
      "description": "",
      "expression": true,
      "expressionJson": "{\"arity\":\"literal\",\"value\":\"true\",\"type\":\"boolean:primitive\"}",
      "filters": [],
      "name": "uat_target_group_101",
      "targetEntity": "EVENT",
      "targetType": "COUNT",
      "extendedFieldInfo": {
        "name": "points",
        "aggregateFunction": "SUM"
      },
      "defaultValues": [
        {
          "defaultValue": "1.00"
        },
        {
          "defaultValue": "1.00"
        }
      ]
    }
  ]
}'

Prerequisites

  • Authentication: Basic/OAuth authentication
  • Default access group

Resource information

URIv3/targetGroups
HTTP methodPOST
PaginationNA
Rate limitNA
Batch supportNA

Request body parameters

Parameter Name

Data Type

Description

active

Boolean

Indicates if the tracking is active or not.

description

String

A brief description of the target group.

name*

String

The name identifier for the target group.
The character limit for the name is 200 characters.

preferredTillId

Number

Identifier for a preferred till.

timeZoneName

String

IANA time zone name for
the target group; defaults
to the system time zone when
omitted.

trackingType*

String

The 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.

targetEvaluationType

String

The 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.

totalPeriods

Number

The total number of periods over which the tracking is evaluated.

frequencyType

Enum

The frequency of each cycle. Supported values: Monthly, Quarterly, Half-yearly, Yearly, Weekly.

userCreated

Boolean

If true, a user-created target group is created. This allows customers to set and be rewarded for their own goals.

frequency

Number

The frequency count, relevant to the frequencyType.

recurringCycles

Number

The number of cycles for which the tracking recurs.

periods

Object

An array of period objects containing details about individual tracking periods.

periods.active

Boolean

Indicates if the period is active.

periods.description

String

A brief description of the period.

periods.endDate

Date Time

The end date and time of the period.

periods.periodStatus

String

Indicates if the cycle of the milestone is active/inactive.

periods.refCode

String

A reference code for the period.

periods.startDate

Date Time

The start date and time of the period.

targets

Object

An array of target objects outlining each target in the tracking.

targets.active

Boolean

Indicates if the target is active.

targets.description

String

A brief description of the target.

targets.expression

String

A string representing the condition to meet the target.

targets.expressionJson

String

A JSON expression specifying the conditions required to achieve the target.

targets.filters

Object

Defines the entity to which the target expressions apply.

targets.filters.entityType

Enum

Entity to which expressions apply. Must satisfy the target condition. Supported values: STORE, ZONE, CONCEPT.

targets.filters.entityIds

Array

The IDs of the entities to which the filter is applied.

targets.name

String

The name identifier for the target.

targets.targetEntity

Enum

The 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.eventName

String

The name of the behavioural event that triggers the target.

targets.targetType*

Enum

Type 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.

extendedFieldInfo

Object

Details of the event attribute being tracked. Applicable when targetType is SUM.

extendedFieldInfo.name*

String

Event on which the sum calculation is performed. E.g., number of 'add to cart' events.

extendedFieldInfo.aggregateFunction

Enum

Aggregate function used to evaluate behavioural events. Supported: SUM. E.g., use SUM to track total cart value and validate against target.

defaultValues

Object

An array of objects defining default values for the target.

defaultValues.defaultValue

Integer

A default value used during target evaluation.

streaks*

Object

An array containing streak information. Required when trackingType is STREAKS.

streaks.name*

String

Name of the streak.

streaks.targetCountOfSequence*

Integer

Number of times a user must meet the target to earn the reward.

Example response

{
    "data": {
        "id": 2771,
        "name": "uatTargetGroup101",
        "active": true,
        "preferredTillId": 751552970000,
        "periods": [
            {
                "id": 30160,
                "attribution": {
                    "createdOn": "2025-11-20T13:07:49.000+0000",
                    "createdOnISO": "2025-11-20T13:07:49Z",
                    "lastUpdatedOn": "2025-11-20T13:07:49.000+0000",
                    "lastUpdatedOnISO": "2025-11-20T13:07:49Z",
                    "lastUpdatedBy": {
                        "id": 75152721,
                        "code": "naman_doc",
                        "description": "",
                        "name": "naman",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 75152721,
                        "code": "naman_doc",
                        "description": "",
                        "name": "naman",
                        "type": "TILL"
                    }
                },
                "startDate": "2025-06-11",
                "endDate": "2025-06-11",
                "refCode": "Cycle_1",
                "periodStatus": "ENDED",
                "targetGroupId": 2771,
                "description": "",
                "active": true
            },
            {
                "id": 30161,
                "attribution": {
                    "createdOn": "2025-11-20T13:07:49.000+0000",
                    "createdOnISO": "2025-11-20T13:07:49Z",
                    "lastUpdatedOn": "2025-11-20T13:07:49.000+0000",
                    "lastUpdatedOnISO": "2025-11-20T13:07:49Z",
                    "lastUpdatedBy": {
                        "id": 75152721,
                        "code": "naman_doc",
                        "description": "",
                        "name": "naman",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 75152721,
                        "code": "naman_doc",
                        "description": "",
                        "name": "naman",
                        "type": "TILL"
                    }
                },
                "startDate": "2025-05-11",
                "endDate": "2025-05-11",
                "refCode": "Cycle_2",
                "periodStatus": "ENDED",
                "targetGroupId": 2771,
                "description": "",
                "active": true
            }
        ],
        "totalPeriods": 1,
        "description": "UAT target group number hundered and one",
        "targetEvaluationType": "FIXED_CALENDAR_WINDOW",
        "recurringCycles": 1,
        "frequency": 1,
        "targetCycleStartDate": "2025-05-11T00:00:00.000Z",
        "targetCycleEndDate": "2025-06-11T23:59:59.000Z",
        "targetCycleStartDateISO": "2025-05-11T00:00:00Z",
        "targetCycleEndDateISO": "2025-06-11T23:59:59Z",
        "frequencyType": "DAILY",
        "trackingType": "DEFAULT",
        "targets": [
            {
                "id": 3017,
                "attribution": {
                    "createdOn": "2025-11-20T13:07:49.173+0000",
                    "createdOnISO": "2025-11-20T13:07:49Z",
                    "lastUpdatedOn": "2025-11-20T13:07:49.173+0000",
                    "lastUpdatedOnISO": "2025-11-20T13:07:49Z",
                    "lastUpdatedBy": {
                        "id": 75152721,
                        "code": "naman_doc",
                        "description": "",
                        "name": "naman",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 75152721,
                        "code": "naman_doc",
                        "description": "",
                        "name": "naman",
                        "type": "TILL"
                    }
                },
                "name": "uat_target_group_101",
                "emfRuleSetId": 126455464,
                "targetType": "COUNT",
                "targetEntity": "EVENT",
                "eventName": "TransactionAdd",
                "targetGroupId": 2771,
                "description": "",
                "active": true,
                "expression": "true",
                "expressionJson": "{\"arity\":\"literal\",\"value\":\"true\",\"type\":\"boolean:primitive\"}",
                "filters": [],
                "enrolmentMethod": "IMPORT",
                "defaultValues": [
                    {
                        "id": 127067,
                        "periodId": 30160,
                        "defaultValue": 1.000
                    },
                    {
                        "id": 127068,
                        "periodId": 30161,
                        "defaultValue": 1.000
                    }
                ],
                "targetPeriodDefaultValuesMap": {
                    "30160": {
                        "id": 127067,
                        "periodId": 30160,
                        "defaultValue": 1.000
                    },
                    "30161": {
                        "id": 127068,
                        "periodId": 30161,
                        "defaultValue": 1.000
                    }
                },
                "extendedFieldInfo": {
                    "name": "points",
                    "aggregateFunction": "SUM"
                }
            }
        ],
        "leaderboardEnabled": false,
        "userCreated": false,
        "timeZoneName": "Asia/Kolkata"
    },
    "errors": null,
    "warnings": null
}

Response parameters

FieldDatatypeDescription
objectobjectRoot response object.
.dataobjectTarget group details.
..idintegerUnique identifier for the group.
..namestringName of the group.
..activebooleanIndicates if the group is active.
..preferredTillIdintegerPreferred till ID, indicating no specific preference with 0.
..periodsarray of objectsList of periods specified for the group.
...idintegerUnique identifier for each period.
...attributionobjectAudit information for each period.
....createdOnstring (date-time)Creation date and time of the period in ISO 8601 extended format.
....createdOnISOstring (date-time)Creation date and time of the period in ISO 8601 extended format with timezone included.
....lastUpdatedOnstring (date-time)Date and time when the period was last updated in ISO 8601 extended format.
....lastUpdatedOnISOstring (date-time)Date and time when the period was last updated in ISO 8601 extended format with timezone included.
....lastUpdatedByobjectUser who last updated the period.
.....idintegerUnique identifier of the user who last updated the period.
.....codestringCode of the user who last updated the period.
.....descriptionstringDescription of the user who last updated the period.
.....namestringName of the user who last updated the period.
.....typestringType of updater, e.g., "TILL".
....createdByobjectUser who created the period.
.....idintegerUnique identifier of the user who created the period.
.....codestringCode of the user who created the period.
.....descriptionstringDescription of the user who created the period.
.....namestringName of the user who created the period.
.....typestringType of creator, e.g., "TILL".
...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", "ENDED".
...targetGroupIdintegerIdentifier linking each period to a target group.
...descriptionstringDescription of each period.
...activebooleanIndicates if each period is active.
..totalPeriodsintegerTotal number of periods specified.
..descriptionstringDescription of the group.
..targetEvaluationTypestringType of target evaluation, e.g., "FIXED_CALENDAR_WINDOW".
..recurringCyclesintegerNumber of recurring cycles specified (if applicable).
..frequencyintegerFrequency value set for the setting (if applicable).
..targetCycleStartDatestring (date-time)Start date and time for the target cycle.
..targetCycleEndDatestring (date-time)End date and time for the target cycle (if applicable).
..targetCycleStartDateISOstring (date-time)Start date and time for the target cycle in ISO 8601 YYYY-MM-DDTHH:mm:ssZ format (UTC).
..targetCycleEndDateISOstring (date-time)End date and time for the target cycle in ISO 8601 YYYY-MM-DDTHH:mm:ssZ format with timezone included.
..frequencyTypestringFrequency type, e.g., "CUSTOM", "DAILY" (if applicable).
..trackingTypestringType of tracking, e.g., "STREAKS", "DEFAULT" (if applicable).
..targetsarray of objectsList of targets configured for the group.
...idintegerUnique identifier for each target.
...attributionobjectAudit information for each target.
....createdOnstring (date-time)Creation date and time of the target in ISO 8601 extended format.
....createdOnISOstring (date-time)Creation date and time of the target in ISO 8601 extended format with the timezone included.
....lastUpdatedOnstring (date-time)Date and time when the target was last updated in ISO 8601 extended format.
....lastUpdatedOnISOstring (date-time)Date and time when the target was last updated in ISO 8601 extended format with the timezone included.
....lastUpdatedByobjectUser who last updated the target.
.....idintegerUnique identifier of the user who last updated the target.
.....codestringCode of the user who last updated the target.
.....descriptionstringDescription of the user who last updated the target.
.....namestringName of the user who last updated the target.
.....typestringType of updater, e.g., "TILL".
....createdByobjectUser who created the target.
.....idintegerUnique identifier of the user who created the target.
.....codestringCode of the user who created the target.
.....descriptionstringDescription of the user who created the target.
.....namestringName of the user who created the target.
.....typestringType of creator, e.g., "TILL".
...namestringName of each target.
...emfRuleSetIdintegerIdentifier of the rule set used for evaluating the target.
...targetTypestringType of each target, e.g., "SALES", "COUNT".
...targetEntitystringType of entity targeted by each target, e.g., "EVENT".
...eventNamestringName of the event associated with each target.
...targetGroupIdintegerIdentifier linking each target to a target group.
...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.
...filtersarrayFilters applied to the target (if any).
...enrolmentMethodstringMethod of enrolment for each target.
...defaultValuesarray of objectsDefault values configured per period for the target.
....idintegerUnique identifier for each default value configuration.
....periodIdintegerIdentifier of the period the default value applies to.
....defaultValuefloatSpecifies a default value for the target criteria for each target.
...targetPeriodDefaultValuesMapobjectMap of period IDs to their default value configuration for the target.
....30160objectDefault value configuration for period ID 30160.
.....idintegerUnique identifier for the default value configuration for period ID 30160.
.....periodIdintegerPeriod ID (30160) that this default value configuration applies to.
.....defaultValuefloatDefault value configured for period ID 30160.
....30161objectDefault value configuration for period ID 30161.
.....idintegerUnique identifier for the default value configuration for period ID 30161.
.....periodIdintegerPeriod ID (30161) that this default value configuration applies to.
.....defaultValuefloatDefault value configured for period ID 30161.
...extendedFieldInfoobjectAdditional configuration for the aggregation field used by the target.
....namestringName of the extended field used for aggregation.
....aggregateFunctionstringAggregate function applied on the extended field, e.g., "SUM".
..leaderboardEnabledbooleanIndicates if leaderboard is enabled for this target group.
..userCreatedbooleanIndicates if the target group was created by a user.
..timeZoneNamestringTime zone used for date and time evaluation, e.g., "Asia/Kolkata".
.errorsarray of objects or nullList of errors, if any.
.warningsarray of objects or nullList of warnings, if any.

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
310101At least one streak should be present for streaks target group
310106Streak count is mandatory

Language
Credentials
Basic
base64
:
URL
Click Try It! to start a request and see the response here!