Documentation for version v74
Create segment
Description
Creates a new segment.
Request URL
Method: POST
https://example.com/api/v1.1/segments/add/
Request parameters
| Parameter | Type | Example | Required | Description |
|---|---|---|---|---|
| token | string | "abcdefghijklmnqrstuvwxyz" | Yes | API token |
| format | string | "json" | No | Response data format. By default – json |
| name | string | "New segment" | Yes | New segment name |
| segment | JSON array | Yes |
Segment type is determined by a combination of parameters:
is_staticisfalse— the segment is dynamicis_staticistrueandis_refresh_dailyisfalse— the segment is staticis_staticistrueandis_refresh_dailyistrue— the segment is updatable
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.
- JSON
- XML
{
"name": "Segment 2",
"is_static": true,
"list_id": 5
"is_refresh_daily": false,
"token": "abcdefghijklmnqrstuvwxyz"
}
<xml>
<list_id>2</list_id>
<name>New segment 2</name>
<is_static>true</is_static>
<is_refresh_daily>false</is_refresh_daily>
<token>abcdefghijklmnqrstuvwxyz</token>
</xml>
For dynamic segments
When creating a dynamic segment, the presence of segmentation rules in the segment field is required.
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz"
"name": "Dynamic segment",
"is_static": false,
"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
}
]
}
]
}
],
}
<xml>
<name>Dynamic segment</name>
<is_static>false</is_static>
<segment array="true">
<condition>and</condition>
<limit>0</limit>
<list_id>1</list_id>
<percent_from>0</percent_from>
<percent_to>99</percent_to>
<queries>
<compo>default</compo>
<name>statseg</name>
<operator>once</operator>
<type>statseg</type>
<value array="true">
<name>segment_id</name>
<value>1</value>
</value>
</queries>
<queries>
<compo>default</compo>
<name>statseg</name>
<operator>once</operator>
<type>statseg</type>
<value array="true">
<name>segment_id</name>
<value>2</value>
</value>
</queries>
</segment>
<token>abcdefghijklmnqrstuvwxyz</token>
</xml>
For updatable segments
When creating an updatable segment, segmentation rules in the segment field are required.
- JSON
- XML
{
"name": "Updatable segment",
"is_static": true,
"is_refresh_daily": true,
"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"
}
<name>New segment 2</name>
<is_static>true</is_static>
<is_refresh_daily>true</is_refresh_daily>
<list_id>1</list_id>
<segment array="">
<condition>and</condition>
<limit>0</limit>
<list_id>1</list_id>
<percent_from>0</percent_from>
<percent_to>99</percent_to>
<queries array="">
<compo>domaingroup</compo>
<name>email</name>
<operator>equal</operator>
<type>email</type>
<value array="">
<name>domaingroup</name>
<value>Yahoo! (US)</value>
</value>
</queries>
</segment>
<token>abcdefghijklmnqrstuvwxyz</token>
</xml>
Response example
- JSON
- XML
{
"data": {
"saved_id": 1
},
"error": 0,
"error_text": "Successful operation"
}
<xml>
<data>
<saved_id>14</saved_id>
</data>
<error>0</error>
<error_text>Successful operation</error_text>
</xml>
Response parameters
| Parameter | Type | Description |
|---|---|---|
| error | int | Код ошибки |
| error_text | string | Текст ошибки |
| saved_id | int | New segment ID |