Update Segment API

Learn how to manage user segments in CleverTap with API for seamless audience targeting and engagement.

Overview

The Update Segment API allows you to manage and update user profiles within CleverTap by adding or removing users from API segments only. It does not apply to segments created via the dashboard or partner segments. This API allows bulk updates to user segments, ensuring profiles stay accurate in the relevant segments based on updated behavior, preferences, or attributes.

With this API, you can:

  • Update multiple user profiles simultaneously, adding or removing them from various segments.
  • Refine segments based on changing user data or actions.
  • Manage and maintain dynamic user segments for better targeting and engagement.
  • Simplify the user segmentation process by using either CleverTap segment IDs that is, ct_segment_id or customer-defined segment IDs, that is, customer_segment_id.

Base URL

Here is an example base URL from the account in the India region:

https://in1.api.clevertap.com/api/updateSegment

Region

To identify the API endpoint for the region of your account, refer to Region.

Headers

For more information about API headers used while processing API requests, refer to Headers.

HTTP Method

POST

Body Parameters

The request body contains an array of bulk_profiles, where each entry consists of user profile details and segment information.

ParameterDescriptionRequired/OptionalTypeSample Value
bulk_profilesA list containing multiple user profile updates in bulk.RequiredArray
user_profilesA list of user identity data specifying either guid or identity.RequiredArray
guidA unique identifier for an anonymous user. Checked only if identity is not provided.Optional if identity is present.Stringabcde12345
identityThe CleverTap identity of the user. Checked only if guid is not present.Optional if guid is present.StringCT123456
segmentsA list of segments to which the user profiles must be added or removed.RequiredArray
ct_segment_idThe internal CleverTap segment ID.Optional if customer_segment_id is present.Integer1234
customer_segment_idA unique identifier for a customer-defined segment.Optional if ct_segment_id is present.Stringabc123
actionDefines whether the user should be added or removed from the segment.RequiredStringADD or REMOVE

Each bulk_profiles entry updates multiple user profiles and assigns them to specified segments using either a CleverTap segment ID (ct_segment_id) or a customer-defined segment ID (customer_segment_id).

πŸ“˜

Request Payload

If both ct_segment_id and customer_segment_id are provided in the request payload, they must match. If they do not match, the segment update request will fail.

Sample Request

{
  "bulk_profiles": [
    {
      "user_profiles": [
        {
          "guid": "abcde12345",
          "identity": "[email protected]"
        },
        {
          "guid": "fghij67890",
          "identity": "[email protected]"
        }
      ],
      "segments": [
        {
          "ct_segment_id": "1234",
          "customer_segment_id": "abc123",
          "action": "ADD"
        },
        {
          "ct_segment_id": "5678",
          "action": "Remove"
        },
        {
          "customer_segment_id": "customer_id_123",
          "action": "ADD"
        }
      ]
    }
  ]
}

Sample Response

{
  "success": true
}

Errors

The following are the API errors that you may receive upon failure requests of the Update Segments API:

Error CodesError CaseError Description
401Authentication FailureUser authentication failed. Ensure all authentication values are entered and correct.
400Incorrect Request ParametersParameters entered for uploading profiles are invalid. Verify the parameters and try again.
100Maximum number of profile updates reachedA maximum of 100 profiles can be uploaded in one request.
100No user profiles are providedNo profiles are available for upload. Add profiles and try again.
500Unknown causeThe request could not be processed due to a system error. Try again.