Create unified target group

Unified Target Group API

👍

Note

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

A unified target is a combination of two or more targets within a target group. You can combine individual targets that involve different customer activities and tracking configurations (KPIs). You can also define an overall target that a user must achieve along with the defined targets.

API endpoint example

POST https://eu.api.capillarytech.com/v3/targetGroups

Prerequisites

  • Authentication: Basic authentication details
  • Access: WRITE access to the target loyalty access group resource

Resource information

URI/v3/targetGroups
HTTP methodPOST
Rate limitN/A
Batch supportN/A

Request body parameters

Parameter (*required)TypeDescription
activeBooleanIndicates whether the group is active.
descriptionStringA brief description of the group.
fromDateStringThe start date and time of the target (ISO 8601).
name*StringThe name of the target group (max 200 characters).
preferredTillIdIntegerThe TILL associated with points issued on completing the target.
toDateStringThe end date and time of the target (ISO 8601).
trackingType*EnumType of activity tracking: UNIFIED, DEFAULT, STREAKS, CAPPING.
- UNIFIED: multiple targets in a single milestone.
- DEFAULT: single target milestone.
- STREAKS: continuous activity streaks.
- CAPPING: apply capping on benefits.
totalPeriods*IntegerTotal number of periods in the group.
frequency*IntegerFrequency of the target.
recurringCycles*IntegerNumber of cycles for CYCLIC_WINDOW or PERIOD_AGNOSTIC_WINDOW.
periodsArrayArray of period objects:
- activeBooleanIndicates if the period is active.
- descriptionStringA brief description of the period.
- startDateStringStart date and time (ISO 8601).
- endDateStringEnd date and time (ISO 8601).
- refCodeStringReference code of the target period.
- periodStatusEnumStatus of the period: RUNNING, ENDED, NOT_STARTED.
targetsArrayArray of target objects:
- activeBooleanIndicates if the target is active.
- nameStringThe name of the target.
- descriptionStringA brief description of the target.
- expressionStringA string representation of the target condition rule.
- expressionJsonStringA JSON representation of the target's rule.
- filtersArrayArray of filter objects:
- entityTypeEnumEntity type for the filter: Transaction, Line item, STORE, etc.
- entityIdsArrayArray of entity IDs for the filter.
- targetEntityEnumEntity that defines the target condition:
TRANSACTION, LINEITEM, POINTS, EVENT, ALTERNATE_CURRENCIES, REWARDS.
- enrolmentMethodEnumMethod to enroll: TRANSACTION (auto-enroll on transaction), IMPORT (import custom values).
- targetTypeEnumTarget type:
– Transactional: QUANTITY, SALES, COUNT, VISIT.
– Behavioral: EVENT_ATTRIBUTE.
- defaultValuesArrayArray of default value objects:
- defaultValueIntegerDefault value for the period.
combinationType*EnumLogical operator between targets: ANY (any one target), ALL (all targets).
unifiedTargetExpressionObjectUnified expression for evaluation:
- aggregationEnumAggregation type: SUM, COUNT. (Required if used.)
- thresholdValueIntegerThreshold for the unified expression. (Required if aggregation is set.)

Sample request – Combination type ALL with aggregation

{
  "active": true,
  "description": "unified group",
  "fromDate": "2023-09-25T13:45:12.063Z",
  "name": "demo-unified1",
  "preferredTillId": 50679771,
  "toDate": "2024-10-31T08:41:00.529Z",
  "trackingType": "UNIFIED",
  "totalPeriods": 1,
  "frequency": 0,
  "recurringCycles": 0,
  "periods": [
    {
      "active": true,
      "description": "p1",
      "startDate": "2023-09-25T13:45:12.063Z",
      "endDate": "2023-10-31T23:45:12.063Z",
      "refCode": "period44",
      "periodStatus": "RUNNING"
    }
  ],
  "targets": [
    {
      "active": true,
      "description": "uni15",
      "expression": "currentTxn.value>500",
      "expressionJson": "{...}",
      "filters": [{ "entityType": "STORE", "entityIds": [50679757, 50679770] }],
      "name": "t4",
      "targetEntity": "TRANSACTION",
      "enrolmentMethod": "TRANSACTION",
      "targetType": "SALES",
      "defaultValues": [{ "defaultValue": 2000 }]
    },
    {
      "active": true,
      "description": "uni25",
      "expression": "true",
      "expressionJson": "{...}",
      "filters": [{ "entityType": "STORE", "entityIds": [50679757,50679770] }],
      "name": "t5",
      "targetEntity": "TRANSACTION",
      "enrolmentMethod": "TRANSACTION",
      "targetType": "SALES",
      "defaultValues": [{ "defaultValue": 2000 }]
    }
  ],
  "combinationType": "ALL",
  "unifiedTargetExpression": { "aggregation": "SUM", "thresholdValue": 5000 }
}

Response parameters

ParameterTypeDescription
dataObjectMain object containing details.
idIntegerUnique identifier for the target group.
nameStringName of the target group.
fromDate, toDateStringStart/end dates for the group (ISO 8601).
activeBooleanWhether the group is active.
preferredTillIdIntegerIdentifier of the associated till.
periodsArrayArray of period objects (see above).
totalPeriodsIntegerTotal number of periods.
trackingTypeStringActivity tracking type: UNIFIED, DEFAULT, STREAKS, CAPPING.
targetsArrayArray of target objects (see above).
combinationTypeStringLogical operator: ANY, ALL.
unifiedTargetExpressionObjectUnified expression (see above).

API error codes

CodeDescription
310069Target group name already exists
300004Invalid input; check all values and ensure correctness
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!