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 |
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.
- JSON
- XML
{
"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"
}
<?xml version="1.0" encoding="UTF-8" ?>
<xml>
<id>2</id>
<name>New segment 2</name>
<is_static>true</is_static>
<is_refresh_daily>true</is_refresh_daily>
<segment>
<condition>and</condition>
<limit>0</limit>
<list_id>1</list_id>
<percent_from>0</percent_from>
<percent_to>99</percent_to>
<queries>
<compo>domaingroup</compo>
<name>email</name>
<operator>equal</operator>
<type>email</type>
<value>
<name>domaingroup</name>
<value>Yahoo! (US)</value>
</value>
</queries>
</segment>
<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
{
"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"
}
<?xml version="1.0" encoding="UTF-8" ?>
<xml>
<name>New segment</name>
<segment>
<condition>or</condition>
<limit>0</limit>
<list_id>1</list_id>
<percent_from>0</percent_from>
<percent_to>99</percent_to>
<queries>
<child/>
<compo>dataurl</compo>
<condition>
</condition>
<name>subscription_email</name>
<operator>in_data</operator>
<type>subscription_email</type>
<value>
<name>field</name>
<value>subscriptions</value>
</value>
<value>
<name>resource_id</name>
<value>1</value>
</value>
<value>
<name>url</name>
<value>http://127.0.0.1:8080/json.email.subscriptions</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 |