Update segment
Description
Updates segment building rules.
Request URL
Method: POST
https://example.com/api/v1.1/segments/update/
Request parameters
Parameter | Type | Example | Required | Description |
---|---|---|---|---|
token | string | "abcdefghijklmnqrstuvwxyz" | Yes | API token |
format | string | "json" | Yes | Response data format. By default – json |
id | int | 1 | Yes | Segment ID |
name | string | "New segment" | Yes | Segment name |
segment | JSON array | Yes | Queries to update |
Request example
For static segments
When updating 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
{
"id": 2,
"name": "Static segment 2",
"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_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 updating a dynamic segment, the presence of segmentation rules in the segment
field is required.
- JSON
- XML
{
"id": 3,
"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>
<id>3</id>
<name>Dynamic segment</name>
<segment>
<condition>and</condition>
<limit>0</limit>
<list_id>1</list_id>
<percent_from>0</percent_from>
<percent_to>99</percent_to>
<queries>
<query>
<compo>default</compo>
<name>statseg</name>
<operator>once</operator>
<type>statseg</type>
<value>
<name>segment_id</name>
<value>1</value>
</value>
</query>
<query>
<compo>default</compo>
<name>statseg</name>
<operator>once</operator>
<type>statseg</type>
<value>
<name>segment_id</name>
<value>2</value>
</value>
</query>
</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 code |
error_text | string | Error text |
saved_id | int | Segment ID |