Dynamic Segments
Dynamic segments allow for segment rules to be created within the Krestor platform. Currently these rules are available for specific geographic locations (country, state, region or city) at the global rule level.
Create dynamic segment
This method creates a new dynamic segment.
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X POST -H 'Content-Type: application/json' \
-u '[your token]:' \
"http://ac.cnstrc.com/v1/dynamic_segments?key=[your API key]§ion=[your section]"
-d '{
"display_name": "New York Segment",
"filter_expression": {
"name": "geo_city",
"value": "New York"
}
}'
// This method is not currently supported.
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
info
The above command returns a 201 Created response on success.
HTTP Request
POST http://ac.cnstrc.com/v1/dynamic_segments?key=[your API key]§ion=[your section]
{
"id": 19,
"display_name": "New York Segment",
"filter_expression": {
"name": "geo_city",
"value": "New York"
},
"created_at": "2022-05-30T18:42:57",
"updated_at": null
}
URL Parameters
Parameter | Required? | Description |
---|---|---|
section | Yes | The section that contains the dynamic segment. |
JSON Parameters
Parameter | Required? | Description |
---|---|---|
display_name | Yes | Name for a dynamic segment. Should be unique. |
filter_expression | Yes | The filter expression that defines this dynamic segment. |
Filter expression
Filter expression items with logical operators composed of filters via the filter_expression
.
- A
filter
can be of the form{"name": "geo_region", "value": "REGION"}
to match a single filter value. - A
filter
can havename
from one of:client_ip
,client_version
,geo_city
,geo_country
,geo_country_iso_code
,geo_region
,dt_weekday
,dt_timeofday
,user_segment
. - A single
filter
(as defined above) is a validfilter_expression
. - A
filter_expression
of the form{"and": [expr1, expr2, expr3, ...]}
matches all items that match all of the expressions in the list (whereexpr1
,expr2
,expr3
arefilter_expression
s). - A
filter_expression
of the form{"or": [expr1, expr2, expr3]}
matches all items that match any of the expressions in the list. - A
filter_expression
of the form{"not": expr}
matches all items that do not match the expressionexpr
. filter_expressions
may be nested (at most 2 levels).filter_expressions
may not contain more than 150expr
expressions (in total).
{
"and": [
{
"or": [
{
"name": "geo_country",
"value": "US"
},
{
"name": "geo_country",
"value": "Canada"
}
]
},
{
"or": [
{
"name": "geo_city",
"value": "New York"
},
{
"not": {
"name": "geo_city",
"value": "Austin"
}
}
]
}
]
}
Retrieve all dynamic segments
This method retrieves a list of dynamic segments
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X GET \
-u "[your token]:" \
"https://ac.cnstrc.com/v1/dynamic_segments?key=[your API key]§ion=[your section]&sort_by=display_name&sort_order=ascending&page=1&num_results_per_page=20&filters[display_name]=New%20York%20Segment"
// This method is not currently supported.
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
info
The above command returns a 200 OK response on success.
HTTP request
GET https://ac.cnstrc.com/v1/dynamic_segments?key=[your API key]§ion=[your section]&sort_by=display_name&sort_order=ascending&page=1&num_results_per_page=20
URL Parameters
Attribute | Required? | Description |
---|---|---|
section | Yes | The section that contains the dynamic segments. |
num_results_per_page | No | The number of dynamic segments to return. |
page | No | The page of results to return. Defaults to 1. Can't be used together with 'offset' |
offset | No | The number of results to skip from the beginning. Can't be used together with 'page' |
query | No | Search for dynamic segments with a matching display name |
sort_by | No | Field name to sort results by. One of display_name , created_at , updated_at |
sort_order | No | Sort order of results sorted by sort_by field. One of ascending , descending . Defaults to ascending if not provided |
filters[display_name] | No | Filter by display name (filters[display_name]=New York Segment ) |
{
"dynamic_segments": [
{
"id": 19,
"display_name": "New York Segment",
"filter_expression": {
"name": "geo_city",
"value": "New York"
},
"created_at": "2022-05-30T18:42:57",
"updated_at": null
}
],
"total_count": 1
}
Update dynamic segment
This method partially updates a dynamic segment.
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X PATCH -H 'Content-Type: application/json' \
-u '[your token]:' \
"http://ac.cnstrc.com/v1/dynamic_segments/[id]?key=[your API key]§ion=[your section]"
-d '{
"display_name": "New York Segment",
"filter_expression": {
"name": "geo_city",
"value": "New York"
}
}'
// This method is not currently supported.
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
info
The above command returns a 200 Ok response on success.
HTTP Request
PATCH http://ac.cnstrc.com/v1/dynamic_segments/[id]?key=[your API key]§ion=[your section]
{
"id": 19,
"display_name": "New York Segment",
"filter_expression": {
"name": "geo_city",
"value": "New York"
},
"created_at": "2022-05-30T18:42:57",
"updated_at": "2022-06-30T18:42:57"
}
URL Parameters
Attribute | Type | Required? | Description |
---|---|---|---|
id | number | Yes | The id of the dynamic segment to update. |
section | string | Yes | The section that contains the dynamic segment. |
JSON Parameters
Parameter | Required? | Description |
---|---|---|
display_name | Yes | Name for a dynamic segment. Should be unique. |
filter_expression | Yes | The filter expression that defines this dynamic segment. |
Retrieve one dynamic segment
This method retrieves a single dynamic segment.
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X GET \
-u "[your token]:" \
"https://ac.cnstrc.com/v1/dynamic_segments/[id]?key=[your API key]§ion=[your section]"
// This method is not currently supported.
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
info
The above command returns a 200 OK response on success.
HTTP request
GET https://ac.cnstrc.com/v1/dynamic_segments/[id]?key=[your API key]§ion=[your section]
{
"id": 19,
"display_name": "New York Segment",
"filter_expression": {
"name": "geo_city",
"value": "New York"
},
"created_at": "2022-05-30T18:42:57",
"updated_at": "2022-06-30T18:42:57"
}
URL Parameters
Attribute | Type | Required? | Description |
---|---|---|---|
id | number | Yes | The id of the dynamic segment to retrieve. |
section | string | Yes | The section that contains the dynamic segment. |
Remove dynamic segments
This method deletes a dynamic segment by unique identifier.
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X DELETE -u '[your token]:' \
"http://ac.cnstrc.com/v1/dynamic_segments/[id]?key=[your API key]§ion=[your section]"
// This method is not currently supported.
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
info
The above command returns a 204 No Content response on success.
HTTP Request
DELETE http://ac.cnstrc.com/v1/dynamic_segments/[id]?key=[your API key]§ion=[your section]
URL Parameters
Parameter | Required? | Description |
---|---|---|
id | Yes | Dynamic segment ID. |
section | Yes | The section that contains the dynamic segment. |