Skip to main content

Create segment

Description

Creates a new segment.

Request URL

Method: POST

https://example.com/api/v1.1/segments/add/

Request parameters

ParameterTypeExampleRequiredDescription
tokenstring"abcdefghijklmnqrstuvwxyz"YesAPI token
formatstring"json"NoResponse data format.
By default – json
namestring"New segment"YesNew segment name
segmentJSON array
Yes

Request example

For static segments

When creating a static segment with the is_refresh_daily flag set to true, the presence of segmentation rules in the segment field is required.

{
"name": "Segment 2",
"is_static": true,
"is_refresh_daily": true,
"segment": [
{
"condition": "and",
"limit": 0,
"list_id": 1,
"percent_from": 1,
"percent_to": 99,
"queries": [
{
"compo": "domaingroup",
"name": "email",
"operator": "equal",
"type": "email",
"value": [
{
"name": "domaingroup",
"value": "Yahoo! (US)"
}
]
}
]
}
],
"token": "abcdefghijklmnqrstuvwxyz"
}

For dynamic segments

When creating a dynamic segment, the presence of segmentation rules in the segment field is required.

{
"name": "Dynamic segment",
"segment": [
{
"condition": "and",
"limit": 0,
"list_id": 1,
"percent_from": 0,
"percent_to": 99,
"queries": [
{
"compo": "default",
"name": "statseg",
"operator": "once",
"type": "statseg",
"value": [
{
"name": "segment_id",
"value": 1
}
]
},
{
"compo": "default",
"name": "statseg",
"operator": "once",
"type": "statseg",
"value": [
{
"name": "segment_id",
"value": 2
}
]
}
]
}
],
"token": "abcdefghijklmnqrstuvwxyz"
}

Response example

{
"data": {
"saved_id": 1
},
"error": 0,
"error_text": "Successful operation"
}

Response parameters

ParameterTypeDescription
errorintКод ошибки
error_textstringТекст ошибки
saved_idintNew segment ID