Skip to main content
PUT
/
segments
/
{segmentId}
Update segment
curl --request PUT \
  --url https://api.kameleoon.com/segments/{segmentId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "conditionsData": {
    "firstLevel": [
      {
        "conditions": [
          {
            "weight": 1,
            "count": 123,
            "include": true
          }
        ],
        "orOperators": [
          true
        ]
      }
    ],
    "firstLevelOrOperators": [
      true
    ]
  },
  "name": "My segment",
  "siteId": 8372,
  "audienceTracking": true,
  "conditionDataList": [
    {
      "id": 123,
      "parentId": 123,
      "targetingCondition": {
        "weight": 1,
        "count": 123,
        "include": true
      }
    }
  ],
  "conditionDataTree": {
    "targetingType": "<string>"
  },
  "description": "The segment is for new ab tests",
  "isFavorite": true,
  "tags": [
    "<string>"
  ],
  "userVisible": true
}
'
import requests

url = "https://api.kameleoon.com/segments/{segmentId}"

payload = {
    "conditionsData": {
        "firstLevel": [
            {
                "conditions": [
                    {
                        "weight": 1,
                        "count": 123,
                        "include": True
                    }
                ],
                "orOperators": [True]
            }
        ],
        "firstLevelOrOperators": [True]
    },
    "name": "My segment",
    "siteId": 8372,
    "audienceTracking": True,
    "conditionDataList": [
        {
            "id": 123,
            "parentId": 123,
            "targetingCondition": {
                "weight": 1,
                "count": 123,
                "include": True
            }
        }
    ],
    "conditionDataTree": { "targetingType": "<string>" },
    "description": "The segment is for new ab tests",
    "isFavorite": True,
    "tags": ["<string>"],
    "userVisible": True
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    conditionsData: {
      firstLevel: [{conditions: [{weight: 1, count: 123, include: true}], orOperators: [true]}],
      firstLevelOrOperators: [true]
    },
    name: 'My segment',
    siteId: 8372,
    audienceTracking: true,
    conditionDataList: [
      {
        id: 123,
        parentId: 123,
        targetingCondition: {weight: 1, count: 123, include: true}
      }
    ],
    conditionDataTree: {targetingType: '<string>'},
    description: 'The segment is for new ab tests',
    isFavorite: true,
    tags: ['<string>'],
    userVisible: true
  })
};

fetch('https://api.kameleoon.com/segments/{segmentId}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.kameleoon.com/segments/{segmentId}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => json_encode([
    'conditionsData' => [
        'firstLevel' => [
                [
                                'conditions' => [
                                                                [
                                                                                                                                'weight' => 1,
                                                                                                                                'count' => 123,
                                                                                                                                'include' => true
                                                                ]
                                ],
                                'orOperators' => [
                                                                true
                                ]
                ]
        ],
        'firstLevelOrOperators' => [
                true
        ]
    ],
    'name' => 'My segment',
    'siteId' => 8372,
    'audienceTracking' => true,
    'conditionDataList' => [
        [
                'id' => 123,
                'parentId' => 123,
                'targetingCondition' => [
                                'weight' => 1,
                                'count' => 123,
                                'include' => true
                ]
        ]
    ],
    'conditionDataTree' => [
        'targetingType' => '<string>'
    ],
    'description' => 'The segment is for new ab tests',
    'isFavorite' => true,
    'tags' => [
        '<string>'
    ],
    'userVisible' => true
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.kameleoon.com/segments/{segmentId}"

	payload := strings.NewReader("{\n  \"conditionsData\": {\n    \"firstLevel\": [\n      {\n        \"conditions\": [\n          {\n            \"weight\": 1,\n            \"count\": 123,\n            \"include\": true\n          }\n        ],\n        \"orOperators\": [\n          true\n        ]\n      }\n    ],\n    \"firstLevelOrOperators\": [\n      true\n    ]\n  },\n  \"name\": \"My segment\",\n  \"siteId\": 8372,\n  \"audienceTracking\": true,\n  \"conditionDataList\": [\n    {\n      \"id\": 123,\n      \"parentId\": 123,\n      \"targetingCondition\": {\n        \"weight\": 1,\n        \"count\": 123,\n        \"include\": true\n      }\n    }\n  ],\n  \"conditionDataTree\": {\n    \"targetingType\": \"<string>\"\n  },\n  \"description\": \"The segment is for new ab tests\",\n  \"isFavorite\": true,\n  \"tags\": [\n    \"<string>\"\n  ],\n  \"userVisible\": true\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.put("https://api.kameleoon.com/segments/{segmentId}")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"conditionsData\": {\n    \"firstLevel\": [\n      {\n        \"conditions\": [\n          {\n            \"weight\": 1,\n            \"count\": 123,\n            \"include\": true\n          }\n        ],\n        \"orOperators\": [\n          true\n        ]\n      }\n    ],\n    \"firstLevelOrOperators\": [\n      true\n    ]\n  },\n  \"name\": \"My segment\",\n  \"siteId\": 8372,\n  \"audienceTracking\": true,\n  \"conditionDataList\": [\n    {\n      \"id\": 123,\n      \"parentId\": 123,\n      \"targetingCondition\": {\n        \"weight\": 1,\n        \"count\": 123,\n        \"include\": true\n      }\n    }\n  ],\n  \"conditionDataTree\": {\n    \"targetingType\": \"<string>\"\n  },\n  \"description\": \"The segment is for new ab tests\",\n  \"isFavorite\": true,\n  \"tags\": [\n    \"<string>\"\n  ],\n  \"userVisible\": true\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.kameleoon.com/segments/{segmentId}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"conditionsData\": {\n    \"firstLevel\": [\n      {\n        \"conditions\": [\n          {\n            \"weight\": 1,\n            \"count\": 123,\n            \"include\": true\n          }\n        ],\n        \"orOperators\": [\n          true\n        ]\n      }\n    ],\n    \"firstLevelOrOperators\": [\n      true\n    ]\n  },\n  \"name\": \"My segment\",\n  \"siteId\": 8372,\n  \"audienceTracking\": true,\n  \"conditionDataList\": [\n    {\n      \"id\": 123,\n      \"parentId\": 123,\n      \"targetingCondition\": {\n        \"weight\": 1,\n        \"count\": 123,\n        \"include\": true\n      }\n    }\n  ],\n  \"conditionDataTree\": {\n    \"targetingType\": \"<string>\"\n  },\n  \"description\": \"The segment is for new ab tests\",\n  \"isFavorite\": true,\n  \"tags\": [\n    \"<string>\"\n  ],\n  \"userVisible\": true\n}"

response = http.request(request)
puts response.read_body
{
  "conditionsData": {
    "firstLevel": [
      {
        "conditions": [
          {
            "weight": 1,
            "count": 123,
            "include": true,
            "htmlDescription": "<string>",
            "id": 123
          }
        ],
        "orOperators": [
          true
        ]
      }
    ],
    "firstLevelOrOperators": [
      true
    ]
  },
  "name": "My segment",
  "siteId": 8372,
  "audienceTracking": true,
  "audienceTrackingEditable": true,
  "conditionDataList": [
    {
      "id": 123,
      "isConditionBlock": true,
      "parentId": 123,
      "targetingCondition": {
        "weight": 1,
        "count": 123,
        "include": true,
        "htmlDescription": "<string>",
        "id": 123
      }
    }
  ],
  "conditionDataTree": {
    "targetingType": "<string>",
    "conditionData": [
      "<unknown>"
    ],
    "isConditionBlock": true
  },
  "createdBy": 123,
  "dateCreated": "2023-11-07T05:31:56Z",
  "dateModified": "2023-11-07T05:31:56Z",
  "description": "The segment is for new ab tests",
  "experimentAmount": 123,
  "experiments": [
    123
  ],
  "featureFlagAmount": 123,
  "hasSegmentCondition": true,
  "id": 123,
  "isFavorite": true,
  "links": [
    {
      "domainId": 123,
      "domainStatus": "<string>"
    }
  ],
  "personalizationAmount": 123,
  "personalizations": [
    123
  ],
  "tags": [
    "<string>"
  ],
  "usedBySegmentCondition": true,
  "userVisible": true
}
{
  "code": "<string>",
  "impersonator": "<string>",
  "message": "<string>",
  "name": "<string>",
  "sub": "<string>",
  "time": 123,
  "timestamp": "2023-11-07T05:31:56Z"
}
{
  "code": "<string>",
  "impersonator": "<string>",
  "message": "<string>",
  "name": "<string>",
  "sub": "<string>",
  "time": 123,
  "timestamp": "2023-11-07T05:31:56Z"
}
{
  "code": "<string>",
  "impersonator": "<string>",
  "message": "<string>",
  "name": "<string>",
  "sub": "<string>",
  "time": 123,
  "timestamp": "2023-11-07T05:31:56Z"
}
{
  "code": "<string>",
  "impersonator": "<string>",
  "message": "<string>",
  "name": "<string>",
  "sub": "<string>",
  "time": 123,
  "timestamp": "2023-11-07T05:31:56Z"
}
{
  "code": "<string>",
  "impersonator": "<string>",
  "message": "<string>",
  "name": "<string>",
  "sub": "<string>",
  "time": 123,
  "timestamp": "2023-11-07T05:31:56Z"
}
{
  "code": "<string>",
  "impersonator": "<string>",
  "message": "<string>",
  "name": "<string>",
  "sub": "<string>",
  "time": 123,
  "timestamp": "2023-11-07T05:31:56Z"
}
{
  "code": "<string>",
  "impersonator": "<string>",
  "message": "<string>",
  "name": "<string>",
  "sub": "<string>",
  "time": 123,
  "timestamp": "2023-11-07T05:31:56Z"
}
{
  "code": "<string>",
  "impersonator": "<string>",
  "message": "<string>",
  "name": "<string>",
  "sub": "<string>",
  "time": 123,
  "timestamp": "2023-11-07T05:31:56Z"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

segmentId
integer<int64>
required

Body

application/json
conditionsData
Conditions data · object
required

Conditions according to which visitors will be segmented

name
string
required

Name of the segment

Example:

"My segment"

segmentType
enum<string>
required

Segment type refers to the classification of segments based on their usage.

Available options:
STANDARD,
KEY_MOMENT,
FEATURE_FLAG,
ALL
siteId
integer<int64>
required

Site Id of the project where the segment is created

Example:

8372

audienceTracking
boolean

Specifies whether the segment is tracking an audience.

conditionDataList
Conditions data node · object[]

Conditions by which visitors will be segmented in list form

conditionDataTree
Conditions data level · object

Conditions by which visitors will be segmented in tree form

description
string

Description of the segment

Example:

"The segment is for new ab tests"

isFavorite
boolean

Indicates whether the segment has been marked as a favorite.

tags
string[]
userVisible
boolean

Indicates whether the segment has been marked as hidden from the user

Response

OK

conditionsData
Conditions data · object
required

Conditions according to which visitors will be segmented

name
string
required

Name of the segment

Example:

"My segment"

segmentType
enum<string>
required

Segment type refers to the classification of segments based on their usage.

Available options:
STANDARD,
KEY_MOMENT,
FEATURE_FLAG,
ALL
siteId
integer<int64>
required

Site Id of the project where the segment is created

Example:

8372

audienceTracking
boolean

Specifies whether the segment is tracking an audience.

audienceTrackingEditable
boolean
read-only

This flag shows if audienceTracking can be enabled/disabled. In some cases, audienceTracking cannot be disabled. E.g. a segment has predictive conditions, such segments are tracked by default.

conditionDataList
Conditions data node · object[]

Conditions by which visitors will be segmented in list form

conditionDataTree
Conditions data level · object

Conditions by which visitors will be segmented in tree form

createdBy
integer<int64>
read-only

Account Id of the creator of the segment

dateCreated
string<date-time>
read-only

Date when the segment was created

dateModified
string<date-time>
read-only

Date when the segment was modified

description
string

Description of the segment

Example:

"The segment is for new ab tests"

experimentAmount
integer<int64>
read-only

Number of experiments using this segment. This is an optional field that is included in the request body

experiments
integer<int64>[]
read-only

List of experiment ids using this segment. This is an optional field that is included in the request body

featureFlagAmount
integer<int64>
read-only

Number of feature flags being used in this goal. This is an optional field that must be specified in request params.

hasSegmentCondition
boolean
read-only

Indicates if the segment has conditions

id
integer<int64>
read-only

Unique Id of the segment

isFavorite
boolean

Indicates whether the segment has been marked as a favorite.

List of links to related entities.This is an optional field that is included in the request body.

personalizationAmount
integer<int64>
read-only

Number of personalizations using this segment. This is an optional field that is included in the request body

personalizations
integer<int64>[]
read-only

List of personalization ids using this segment. This is an optional field that is included in the request body

tags
string[]
usedBySegmentCondition
boolean
read-only
userVisible
boolean

Indicates whether the segment has been marked as hidden from the user