Customer Segments

This endpoint is designed to update the segments property for customers that already exist in the database. The purpose of this operation is to replace any existing segments values for a customer. If a customer already has segments attached to them, this operation will completely replace all of the segments that they already have.

To validate the existing customer, the operation uses the document_id attribute, which uniquely identifies the customer in the database. Once the customer is validated, the operation will replace the customer's existing segments with the new segments provided in the request.


Environments

Production: https://deadpool.instaleap.io/api/v3/customers/segments

Staging: https://deadpool.xandar.instaleap.io/api/v3/customers/segments

Request Params

👍

HTTP Method: POST

HeadersDescription
AuthorizationA required header containing the Bearer access token for authentication.
BodyDescriptionValues
customersAn array of objects representing the customers whose segments should be updated.- Type: Array
- Required: yes
- Constraints: at least 1 element in the array
customers.[*].document_idA required property containing the unique identifier of the customer whose segments should be updated.- Type: String
- Required: yes
- Constraints: N/A
customers.[*].segmentsAn array of objects representing the new segments for the customer
Each object in the array should contain the following properties:
- type
- value
- Type: Null | Array
- Required: yes
- Constraints: objects if exist should contain properties type and value
customers.[*].segments.typeA required property containing the type of the segment.- Type: String
- Required: yes
- Constraints: N/A
customers.[*].segments.valueA required property containing the value of the segment.- Type: String
- Required: yes
- Constraints: N/A

Schema

{
  "customers": [
    {
      "document_id": string,
      "segments": [
        {
          "type": string,
          "value": string
        }
      ]
    }
  ]
}

🚧

If there are multiple entries with the same customer_id, only the first occurrence will be saved; the rest will be discarded.

For example, if you send an array of 10 segments for the same customer_id, only the first one in the array will be saved to the customer. Please keep this in mind when using this endpoint to update customer segments.

Expected Response

The response will be a JSON object with the following properties:

PropertyDescriptionValues
updatedCustomersan array of strings containing the unique identifiers of the customers whose segments were successfully updated.- Type: Array

📘

If a customer was not found in the database or for any other reason their segments were not updated, they will not be included in the response array of updated IDs.

For example, if the endpoint is called with the following customer IDs: "aa-bb-1", "cc-dd-2", "aa-bb-1", "ee-ff-3", if only the first occurrence of "aa-bb-1" do exist, it will be updated and included in the response array. Therefore, the response will be an array with only one element: , "ee-bb-1".

Example

Curl Request

curl --location --request POST 'https://deadpool.xandar.instaleap.io/api/v3/customers/segments' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer some_token' \
--data-raw '{
  "customers": [
    {
      "document_id": "1232-2323",
      "segments": [
        {
          "type": "a",
          "value": "b"
        }
      ]
    },
    {
      "document_id": "222-133",
      "segments": [
        {
          "type": "a",
          "value": "b"
        }
      ]
    }
  ]
}'

Response

{
  "updatedCustomers": [
    "1232-2323"
  ]
}