Create targets (milestone)

This API is used to create targets in a target group. A target can be created only after a target group is created.

👍

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 .

API endpoint example

https://eu.api.capillarytech.com/v3/targetGroups/{groupId}/targets

Request path parameters

ParameterData typeDescription
groupIdIntegerUnique identifier of the group.

Request body parameters

ParameterData TypeDescription
activeBooleanIndicates whether the item is active or not.
descriptionStringA brief description of the item.
expressionStringA string representing the condition to meet the target.
expressionJsonStringA JSON expression that specifies the conditions required to achieve the target.
filtersArrayAn array of filters applied to the target.
entityIdsArrayThe IDs of the entities to which the is filter applied on.
entityTypeStringThe entity to which the specified expressions related to the target will be applied.

For example: The user has to make a purchase of shoes from ABC store. Here, purchase of shoes is the expression and the entity is ABC store.
Supported values: STORE, ZONE, CONCEPT.
name*StringThe name of the target/milestone.
targetEntity*StringThe KPI on which the target is tracked.
Supported values: TRANSACTION, LINEITEM, EVENT, REWARDS.

- To track the transactional KPIs, use TRANSACTION and LINEITEM .
- To track the tracking based on rewards such as points, use REWARDS.
- When creating an extended field, use TRANSACTION or LINEITEM.
enrolmentMethodStringThe method of enrolment for the target. Supported values: TRANSACTION, IMPORT
targetGroupId*IntegerThe ID of the target group associated with the item.
targetType*StringThe type of target.
Supported values: QUANTITY, SALES, COUNT, VISIT, GROSS_SALES,
REGULAR_POINTS, PROMOTIONAL_POINTS,
ALL_POINTS, EXTENDED_FIELD.

To create a target based on extended field, use EXTENDED_FIELD.
defaultValuesArrayAn array of objects providing default values related to the target.
targetNameStringThe name of the target for which the default value is specified.
periodIdIntegerThe ID of the period associated with the default value.
defaultValueIntegerA default value used within the target's context.
extendedFieldInfoObjectAn object containing additional information about an extended field. This object is mandatory to pass when targetType is EXTENDED_FIELD.
nameStringName of extended field to track.
aggregateFunctionStringThe aggregate function to be applied to the extended field. Supported values: SUM, COUNT

[
  {
    "active": true,
    "description": "string",
    "emfRuleSetId": 0,
    "emfUnrolledRulesetId": 0,
    "expression": "true",
    "expressionJson": "{\"arity\":\"literal\",\"value\":\"true\",\"type\":\"boolean:primitive\"}",
    "filters": [
      {
        "entityIds": [
          0
        ],
        "entityType": "STORE"
      }
    ],
    "name": "string13",
    "targetEntity": "TRANSACTION",
    "targetGroupId": 4,
    "targetType": "QUANTITY"
  }
]
 {
        "active": true,
        "description": "test210",
        "expression": "true",
        "expressionJson": "{\"arity\":\"literal\",\"value\":\"true\",\"type\":\"boolean:primitive\"}",
        "filters": [
            {
                "entityIds": [
                    0
                ],
                "entityType": "ZONE"
            }
        ],
        "name": "test_name",
        "targetEntity": "LINEITEM",
        "enrolmentMethod": "TRANSACTION",
        "targetGroupId": 1,
        "targetType": "EXTENDED_FIELD",
        "defaultValues": [
            {
                "targetName": "test2",
                "periodId": 1,
                "defaultValue": 20
            }
        ],
        "extendedFieldInfo":{
            "name": "tax_amount",
            "aggregateFunction": "SUM"
        }
    }

Response parameters

ParameterData TypeDescription
idIntegerThe unique identifier for the item.
attributionObjectAn object containing attribution details for the item.
createdOnStringThe creation timestamp of the item.
lastUpdatedOnStringThe last update timestamp of the item.
lastUpdatedByObjectAn object containing details about who last updated the item.
lastUpdatedBy.idIntegerThe unique identifier of the person who last updated the item.
lastUpdatedBy.codeStringA code associated with the person who last updated the item.
descriptionStringA description related to the last updater of the item (empty in this case).
nameStringThe name of the person who last updated the item.
typeStringThe type of updater (e.g., "TILL").
createdByObjectAn object containing details about who created the item.
idIntegerThe unique identifier of the person who created the item.
codeStringA code associated with the person who created the item.
descriptionStringA description related to the creator of the item (empty in this case).
nameStringThe name of the person who created the item.
typeStringThe type of creator (e.g., "TILL").
nameStringThe name of the item.
emfRuleSetIdIntegerThe ID of the rule set in the EMF (Entity Management Framework) system.
emfUnrolledRulesetIdIntegerThe ID of the unrolled rule set in the EMF system.
targetTypeStringThe type of target (e.g., "EXTENDED_FIELD").
targetEntityStringThe entity type that the item applies to (e.g., "LINEITEM").
targetGroupIdIntegerThe ID of the target group associated with the item.
descriptionStringA brief description of the item.
activeBooleanIndicates whether the item is active.
expressionStringA textual representation of the condition or rule, in this case, a simple "true".
expressionJsonStringA JSON string representing the logical structure of the condition or rule.
filtersArrayAn array of filter objects applied to the item.
filters[].entityTypeStringThe type of entity to which the filter applies (e.g., "ZONE").
filters[].entityIdsArrayAn array of entity IDs to which the filter applies.
enrolmentMethodStringThe method of enrolment for the target (e.g., "TRANSACTION").
defaultValuesArrayAn array of objects specifying default values, likely for some calculations or thresholds.
idIntegerThe unique identifier for each default value.
periodIdIntegerThe ID of the period associated with the default value.
defaultValueIntegerA default value used within the target's context.
extendedFieldInfoObjectAn object containing additional information about an extended field.
nameStringThe name of the extended field (e.g., "tax_amount").
aggregateFunctionStringThe aggregate function to be applied to the extended field (e.g., "SUM").
errorsNullPlaceholder for any errors (null in this case, indicating no errors).
warningsNullPlaceholder for any warnings (null in this case, indicating no warnings).
{
    "data": [
        {
            "id": 39,
            "attribution": {
                "createdOn": "2022-03-28T14:33:38.543+0000",
                "lastUpdatedOn": "2022-03-28T14:33:38.543+0000",
                "lastUpdatedBy": {
                    "id": 75040399,
                    "code": "bukl.till",
                    "description": "",
                    "name": "bukl.till",
                    "type": "TILL"
                },
                "createdBy": {
                    "id": 75040399,
                    "code": "bukl.till",
                    "description": "",
                    "name": "bukl.till",
                    "type": "TILL"
                }
            },
            "name": "string13",
            "emfRuleSetId": 13550,
            "emfUnrolledRulesetId": 0,
            "targetType": "QUANTITY",
            "targetEntity": "TRANSACTION",
            "targetGroupId": 20,
            "description": "string",
            "active": true,
            "expression": "true",
            "expressionJson": "{\"arity\":\"literal\",\"value\":\"true\",\"type\":\"boolean:primitive\"}",
            "filters": [
                {
                    "entityType": "STORE",
                    "entityIds": [
                        0
                    ]
                }
            ],
            "enrolmentMethod": "IMPORT"
        }
    ],
    "errors": null
}
{
    "data": [
        {
            "id": 9067,
            "attribution": {
                "createdOn": "2023-09-25T11:42:35.850+0530",
                "lastUpdatedOn": "2023-09-25T11:42:35.850+0530",
                "lastUpdatedBy": {
                    "id": 50666468,
                    "code": "amanv2",
                    "description": "",
                    "name": "amanv2",
                    "type": "TILL"
                },
                "createdBy": {
                    "id": 50666468,
                    "code": "amanv2",
                    "description": "",
                    "name": "amanv2",
                    "type": "TILL"
                }
            },
            "name": "test_name",
            "emfRuleSetId": 1246657,
            "emfUnrolledRulesetId": 1246656,
            "targetType": "EXTENDED_FIELD",
            "targetEntity": "LINEITEM",
            "targetGroupId": 5869,
            "description": "test210",
            "active": true,
            "expression": "true",
            "expressionJson": "{\"arity\":\"literal\",\"value\":\"true\",\"type\":\"boolean:primitive\"}",
            "filters": [
                {
                    "entityType": "ZONE",
                    "entityIds": [
                        0
                    ]
                }
            ],
            "enrolmentMethod": "TRANSACTION",
            "defaultValues": [
                {
                    "id": 10083,
                    "periodId": 1,
                    "defaultValue": 20
                }
            ],
            "extendedFieldInfo": {
                "name": "tax_amount",
                "aggregateFunction": "SUM"
            }
        }
    ],
    "errors": null,
    "warnings": null
}

API-specific error codes


Error codeDescription
310033The target entity and target type combination are not valid.
310094Extended field info is required in case of EXTENDED_FIELD target type
310092Invalid extended field name/ invalid extended field datatype.
Language
Authorization
Basic
base64
:
URL
Click Try It! to start a request and see the response here!