Create Labels

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

Create one or more labels for an organization in a single request. A label is a metadata tag that you can apply to customers, products, or stores to serve as a reusable building block for promotions and campaigns. You can create up to 10 labels per request.

Use case: A marketer labels a set of products as "Month-End-Promo". Instead of rewriting complex promotion rules each time, they reference this label in the promotion configuration, and all labelled products automatically qualify. Labels can also be used to segment audiences in campaigns and slice analytics reports.

Example request

curl -X POST "https://{host}/v2/labels" \
  -H "Authorization: Basic {base64_credentials}" \
  -H "Content-Type: application/json" \
  -d '{
    "labels": [
      {
        "name": "Summer Sale",
        "externalId": "summer-sale-2026",
        "description": "Labels for summer sale products",
        "entityType": "PRODUCT",
        "expiryConfig": {
          "type": "FIXED_DATE",
          "expiryDate": "2027-12-31T23:59:59+05:30"
        }
      }
    ]
  }'
curl --location 'https://eu.api.capillarytech.com/v2/labels' \
--header 'Content-Type: application/json' \
--header 'X-CAP-API-OAUTH-TOKEN: {{your_token_here}}' \
--data '{
  "labels": [
    {
      "name": "DocDemo-Flash-Sale",
      "externalId": "docdemo-flash-001",
      "entityType": "PRODUCT",
      "expiryConfig": { "type": "RELATIVE", "unit": "DAYS", "value": 90 }
    },
    {
      "name": "DocDemo-Loyalty-Gold",
      "externalId": "docdemo-loyalty-gold",
      "description": "Gold tier loyalty customers",
      "entityType": "CUSTOMER",
      "expiryConfig": { "type": "NONE" }
    },
    {
      "name": "DocDemo-Tier2-Store",
      "externalId": "docdemo-tier2-001",
      "entityType": "STORE",
      "expiryConfig": { "type": "RELATIVE", "unit": "YEARS", "value": 1 }
    }
  ]
}'

API Quick Reference

{{https://eu.api.capillarytech.com/v2/labels}}
   └─ {{labels}}
      ├─ {{createLabels}}({{CreateLabelsRequest}}) -> {{CreateLabelsResponse}}
      ├─ {{CreateLabelsRequest}}
      │   └─ {{labels}} []
      │       ├─ {{name}} (string, required)
      │       ├─ {{externalId}} (string)
      │       ├─ {{description}} (string)
      │       ├─ {{entityType}} (enum: PRODUCT | CUSTOMER | STORE, required)
      │       └─ {{expiryConfig}}
      │           ├─ {{type}} (enum: NONE | FIXED_DATE | RELATIVE, required)
      │           ├─ {{expiryDate}} (string, ISO-8601) [required if type = FIXED_DATE]
      │           ├─ {{unit}} (enum: DAYS | MONTHS | YEARS) [required if type = RELATIVE]
      │           └─ {{value}} (integer) [required if type = RELATIVE]
      └─ {{CreateLabelsResponse}}
          ├─ {{data}} []
          │   ├─ {{id}} (integer)
          │   └─ {{externalId}} (string)
          ├─ {{warnings}} []
          └─ {{errors}} []
              ├─ {{code}} (integer)
              ├─ {{field}} (string)
              └─ {{message}} (string)

Prerequisites

  • Basic authentication (Authorization: Basic {base64_credentials}) or OAuth (X-CAP-API-OAUTH-TOKEN).
  • Access to Labels access group resource

Body parameters

FieldTypeRequiredDescription
labelsarrayRequiredList of labels to create. Maximum 10 labels per request.
.namestringRequiredName of the label. Must be unique within the same entityType for the organization. Max 255 characters.
.externalIdstringConditionalExternal identifier for the label. Must be unique within the same entityType for the organization. Max 255 characters. Required when the org has external ID enforcement enabled.
.descriptionstringOptionalDescription of the label. Max 1,024 characters.
.entityTypeenumRequiredEntity type the label applies to. Supported values: CUSTOMER — applies the label to a customer. PRODUCT — applies the label to a product. STORE — applies the label to a store. Case-sensitive.
.expiryConfigobjectOptionalExpiry configuration for the label. If omitted, the label does not expire. Relative can be used if you want to expire the label for a certain number of days, months, or years from now.
..typeenumRequiredExpiry type. Supported values: NONE — the label does not expire. FIXED_DATE — the label expires on a specific date set in expiryDate. RELATIVE — the label expires after a set duration from creation, defined by unit and value. Case-sensitive.
..expiryDatestringConditionalExpiry date in ISO-8601 format: YYYY-MM-DDThh:mm:ssZ (for example, 2026-12-31T23:59:59+05:30). Required when type is FIXED_DATE. Must be a future date.
..unitenumConditionalDuration unit for the relative expiry. Required when type is RELATIVE. Supported values: DAYS — duration in days. MONTHS — duration in months. YEARS — duration in years.
..valuenumberConditionalDuration value for the relative expiry. Required when type is RELATIVE. Must be a non-negative integer.
..roundingUnitstringOptionalRounding unit for the expiry duration. Applicable when type is RELATIVE.

Example response

{
  "data": [
    {
      "id": 108,
      "externalId": "summer-sale-2026"
    }
  ],
  "warnings": [],
  "errors": []
}
{
  "data": [
    { "id": 116, "externalId": "docdemo-flash-001" },
    { "id": 117, "externalId": "docdemo-loyalty-gold" },
    { "id": 118, "externalId": "docdemo-tier2-001" }
  ],
  "warnings": [],
  "errors": []
}
{
  "data": [
    {
      "id": 108,
      "externalId": "summer-sale-2026"
    }
  ],
  "warnings": [],
  "errors": [
    {
      "code": 23019,
      "field": "name",
      "labelExternalId": "clearance-2026",
      "message": "A label with the name 'Clearance' already exists for entity type 'PRODUCT'."
    }
  ]
}

Response parameters

FieldTypeDescription
dataarrayList of successfully created labels.
.idnumberUnique identifier assigned to the created label.
.externalIdstringExternal identifier of the created label.
warningsarrayList of warnings. Empty when no warnings occur.
errorsarrayList of errors for labels that failed to create.
.codenumberNumeric error code.
.fieldstringName of the field that caused the error.
.labelExternalIdstringExternal ID of the label item that failed.
.messagestringDescription of the error.

Note: If some labels are created and others fail, the API returns HTTP 207. If all labels fail, the API returns HTTP 400. If all labels are created successfully, the API returns HTTP 201.

Error & warning codes

CodeError numberTypeDescription
LABEL_NAME_REQUIRED23001ErrorLabel name is required. HTTP 400.
LABEL_EXPIRY_DATE_PAST23004ErrorExpiry date must be a future date. HTTP 400.
LABEL_UNSUPPORTED_TIME_UNIT23005ErrorUnsupported time unit. Supported values: DAYS, MONTHS, YEARS. HTTP 400.
LABEL_INVALID_ENTITY_TYPE23006ErrorInvalid entity type. Supported values: CUSTOMER, PRODUCT, STORE. HTTP 400.
LABEL_NAME_TOO_LONG23007ErrorLabel name must not exceed 255 characters. HTTP 400.
LABEL_EXTERNAL_ID_TOO_LONG23008ErrorExternal ID must not exceed 255 characters. HTTP 400.
LABEL_DESCRIPTION_TOO_LONG23009ErrorDescription must not exceed 1,024 characters. HTTP 400.
LABEL_RELATIVE_EXPIRY_UNIT_REQUIRED23010Errorunit is required when expiryConfig.type is RELATIVE. HTTP 400.
LABEL_RELATIVE_EXPIRY_VALUE_REQUIRED23011Errorvalue must be a non-negative integer when expiryConfig.type is RELATIVE. HTTP 400.
LABEL_FIXED_EXPIRY_DATE_REQUIRED23012ErrorexpiryDate is required when expiryConfig.type is FIXED_DATE. HTTP 400.
LABEL_INVALID_EXPIRY_CONFIG_TYPE23013ErrorInvalid expiry config type. Supported values: NONE, FIXED_DATE, RELATIVE. HTTP 400.
LABEL_INVALID_EXPIRY_DATE_FORMAT23014ErrorInvalid expiry date format. Expected ISO-8601 format: YYYY-MM-DDThh:mm:ssZ. HTTP 400.
LABEL_LOCK_FAILED23015ErrorCould not acquire lock for the label. Another operation is in progress. Retry after a short delay. HTTP 409.
LABEL_DUPLICATE_NAME23019ErrorA label with the same name already exists for this entity type. HTTP 409.
LABEL_DUPLICATE_EXTERNAL_ID23020ErrorA label with the same external ID already exists for this entity type. HTTP 409.
LABEL_BATCH_SIZE_EXCEEDED23021ErrorMaximum 10 labels can be created in a single request. HTTP 400.
LABEL_REQUEST_BODY_EMPTY23022ErrorRequest body must contain at least one label. HTTP 400.
LABEL_ITEM_NULL23023ErrorLabel item must not be null. HTTP 400.
LABEL_EXTERNAL_ID_REQUIRED23030ErrorExternal ID is required. HTTP 400.

Body Params
labels
array of objects
length ≤ 10
labels
Headers
string
string
Responses

Language
Credentials
Basic
base64
:
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json