curl --request POST \
--url https://dash.dmly.io/api/v1/segments \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"name": "VIP clients gone quiet",
"stage": "9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90",
"include_tags": [
"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31"
],
"exclude_tags": [
"a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82"
],
"min_days_inactive": 30,
"conditions": {
"match": "any",
"groups": [
{
"match": "all",
"rules": [
{
"field": "lifecycle_stage",
"op": "equals",
"value": "client"
},
{
"field": "spend",
"op": "gte",
"value": "500"
}
]
},
{
"match": "all",
"rules": [
{
"field": "has_tag",
"op": "has",
"value": "3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31"
}
]
}
]
}
}
'import requests
url = "https://dash.dmly.io/api/v1/segments"
payload = {
"name": "VIP clients gone quiet",
"stage": "9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90",
"include_tags": ["3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31"],
"exclude_tags": ["a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82"],
"min_days_inactive": 30,
"conditions": {
"match": "any",
"groups": [
{
"match": "all",
"rules": [
{
"field": "lifecycle_stage",
"op": "equals",
"value": "client"
},
{
"field": "spend",
"op": "gte",
"value": "500"
}
]
},
{
"match": "all",
"rules": [
{
"field": "has_tag",
"op": "has",
"value": "3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31"
}
]
}
]
}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'VIP clients gone quiet',
stage: '9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90',
include_tags: ['3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31'],
exclude_tags: ['a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82'],
min_days_inactive: 30,
conditions: {
match: 'any',
groups: [
{
match: 'all',
rules: [
{field: 'lifecycle_stage', op: 'equals', value: 'client'},
{field: 'spend', op: 'gte', value: '500'}
]
},
{
match: 'all',
rules: [{field: 'has_tag', op: 'has', value: '3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31'}]
}
]
}
})
};
fetch('https://dash.dmly.io/api/v1/segments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://dash.dmly.io/api/v1/segments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'VIP clients gone quiet',
'stage' => '9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90',
'include_tags' => [
'3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31'
],
'exclude_tags' => [
'a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82'
],
'min_days_inactive' => 30,
'conditions' => [
'match' => 'any',
'groups' => [
[
'match' => 'all',
'rules' => [
[
'field' => 'lifecycle_stage',
'op' => 'equals',
'value' => 'client'
],
[
'field' => 'spend',
'op' => 'gte',
'value' => '500'
]
]
],
[
'match' => 'all',
'rules' => [
[
'field' => 'has_tag',
'op' => 'has',
'value' => '3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://dash.dmly.io/api/v1/segments"
payload := strings.NewReader("{\n \"name\": \"VIP clients gone quiet\",\n \"stage\": \"9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90\",\n \"include_tags\": [\n \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n ],\n \"exclude_tags\": [\n \"a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82\"\n ],\n \"min_days_inactive\": 30,\n \"conditions\": {\n \"match\": \"any\",\n \"groups\": [\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"lifecycle_stage\",\n \"op\": \"equals\",\n \"value\": \"client\"\n },\n {\n \"field\": \"spend\",\n \"op\": \"gte\",\n \"value\": \"500\"\n }\n ]\n },\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"has_tag\",\n \"op\": \"has\",\n \"value\": \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n }\n ]\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://dash.dmly.io/api/v1/segments")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"VIP clients gone quiet\",\n \"stage\": \"9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90\",\n \"include_tags\": [\n \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n ],\n \"exclude_tags\": [\n \"a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82\"\n ],\n \"min_days_inactive\": 30,\n \"conditions\": {\n \"match\": \"any\",\n \"groups\": [\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"lifecycle_stage\",\n \"op\": \"equals\",\n \"value\": \"client\"\n },\n {\n \"field\": \"spend\",\n \"op\": \"gte\",\n \"value\": \"500\"\n }\n ]\n },\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"has_tag\",\n \"op\": \"has\",\n \"value\": \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n }\n ]\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dash.dmly.io/api/v1/segments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"VIP clients gone quiet\",\n \"stage\": \"9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90\",\n \"include_tags\": [\n \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n ],\n \"exclude_tags\": [\n \"a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82\"\n ],\n \"min_days_inactive\": 30,\n \"conditions\": {\n \"match\": \"any\",\n \"groups\": [\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"lifecycle_stage\",\n \"op\": \"equals\",\n \"value\": \"client\"\n },\n {\n \"field\": \"spend\",\n \"op\": \"gte\",\n \"value\": \"500\"\n }\n ]\n },\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"has_tag\",\n \"op\": \"has\",\n \"value\": \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n }\n ]\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>"
}Creates a new contact filter. name is required (max 80). stage is an optional stage uuid. include_tags/exclude_tags are arrays of tag uuids (contacts must have ALL include tags and NONE of the exclude tags). min_days_inactive filters to contacts with no interaction for at least N days. conditions is the grouped rule tree: a top-level match of all or any, plus up to 20 groups, each with its own match and up to 30 rules. Groups combine by the top-level match and the rules inside a group by that group’s match, which gives one level of OR of AND. A rule is field, op and value, plus value2 for a range and name for the custom-field key. The fields and the operators each accepts are: lifecycle_stage and source (equals, not_equals, contains, not_contains, has_value, is_empty); custom_field (equals, not_equals, contains, not_contains, has_value, is_empty, greater_than, less_than, gte, lte, with name set to the custom-field key); channel_reachable (reachable, not_reachable, with value a platform such as whatsapp); opt_in (opted_in, opted_out, value unused); spend, order_count, loyalty_points and credit_balance (equals, not_equals, greater_than, less_than, gte, lte, between, where between needs a numeric value2); last_purchase (within, older, never, with value a number of days); birthday_month (is, is_not, with value the month number); has_tag (has, not_has, with value a tag uuid). Rules are sanitised on save: a rule with an unrecognised field, an operator that field does not accept, a custom_field rule with no name, or a between rule without a numeric value2 is DROPPED rather than rejected, and the request still succeeds. If every rule is dropped the segment is saved with no conditions at all, so confirm the audience afterwards with the segment’s contacts endpoint or contacts_count. conditions is combined with stage, include_tags, exclude_tags and min_days_inactive using AND, not instead of them: when moving a segment onto conditions, clear the flat fields in the same request or it will narrow by both. conditions is write-only, accepted here but never returned in a segment response.
curl --request POST \
--url https://dash.dmly.io/api/v1/segments \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"name": "VIP clients gone quiet",
"stage": "9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90",
"include_tags": [
"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31"
],
"exclude_tags": [
"a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82"
],
"min_days_inactive": 30,
"conditions": {
"match": "any",
"groups": [
{
"match": "all",
"rules": [
{
"field": "lifecycle_stage",
"op": "equals",
"value": "client"
},
{
"field": "spend",
"op": "gte",
"value": "500"
}
]
},
{
"match": "all",
"rules": [
{
"field": "has_tag",
"op": "has",
"value": "3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31"
}
]
}
]
}
}
'import requests
url = "https://dash.dmly.io/api/v1/segments"
payload = {
"name": "VIP clients gone quiet",
"stage": "9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90",
"include_tags": ["3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31"],
"exclude_tags": ["a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82"],
"min_days_inactive": 30,
"conditions": {
"match": "any",
"groups": [
{
"match": "all",
"rules": [
{
"field": "lifecycle_stage",
"op": "equals",
"value": "client"
},
{
"field": "spend",
"op": "gte",
"value": "500"
}
]
},
{
"match": "all",
"rules": [
{
"field": "has_tag",
"op": "has",
"value": "3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31"
}
]
}
]
}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'VIP clients gone quiet',
stage: '9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90',
include_tags: ['3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31'],
exclude_tags: ['a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82'],
min_days_inactive: 30,
conditions: {
match: 'any',
groups: [
{
match: 'all',
rules: [
{field: 'lifecycle_stage', op: 'equals', value: 'client'},
{field: 'spend', op: 'gte', value: '500'}
]
},
{
match: 'all',
rules: [{field: 'has_tag', op: 'has', value: '3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31'}]
}
]
}
})
};
fetch('https://dash.dmly.io/api/v1/segments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://dash.dmly.io/api/v1/segments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'VIP clients gone quiet',
'stage' => '9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90',
'include_tags' => [
'3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31'
],
'exclude_tags' => [
'a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82'
],
'min_days_inactive' => 30,
'conditions' => [
'match' => 'any',
'groups' => [
[
'match' => 'all',
'rules' => [
[
'field' => 'lifecycle_stage',
'op' => 'equals',
'value' => 'client'
],
[
'field' => 'spend',
'op' => 'gte',
'value' => '500'
]
]
],
[
'match' => 'all',
'rules' => [
[
'field' => 'has_tag',
'op' => 'has',
'value' => '3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://dash.dmly.io/api/v1/segments"
payload := strings.NewReader("{\n \"name\": \"VIP clients gone quiet\",\n \"stage\": \"9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90\",\n \"include_tags\": [\n \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n ],\n \"exclude_tags\": [\n \"a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82\"\n ],\n \"min_days_inactive\": 30,\n \"conditions\": {\n \"match\": \"any\",\n \"groups\": [\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"lifecycle_stage\",\n \"op\": \"equals\",\n \"value\": \"client\"\n },\n {\n \"field\": \"spend\",\n \"op\": \"gte\",\n \"value\": \"500\"\n }\n ]\n },\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"has_tag\",\n \"op\": \"has\",\n \"value\": \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n }\n ]\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://dash.dmly.io/api/v1/segments")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"VIP clients gone quiet\",\n \"stage\": \"9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90\",\n \"include_tags\": [\n \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n ],\n \"exclude_tags\": [\n \"a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82\"\n ],\n \"min_days_inactive\": 30,\n \"conditions\": {\n \"match\": \"any\",\n \"groups\": [\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"lifecycle_stage\",\n \"op\": \"equals\",\n \"value\": \"client\"\n },\n {\n \"field\": \"spend\",\n \"op\": \"gte\",\n \"value\": \"500\"\n }\n ]\n },\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"has_tag\",\n \"op\": \"has\",\n \"value\": \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n }\n ]\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dash.dmly.io/api/v1/segments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"VIP clients gone quiet\",\n \"stage\": \"9b1d3f2a-7c4e-4a11-8f0a-2d6e5c4b1a90\",\n \"include_tags\": [\n \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n ],\n \"exclude_tags\": [\n \"a17e2b09-44cd-4e8f-9b21-0c3d5e6f7a82\"\n ],\n \"min_days_inactive\": 30,\n \"conditions\": {\n \"match\": \"any\",\n \"groups\": [\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"lifecycle_stage\",\n \"op\": \"equals\",\n \"value\": \"client\"\n },\n {\n \"field\": \"spend\",\n \"op\": \"gte\",\n \"value\": \"500\"\n }\n ]\n },\n {\n \"match\": \"all\",\n \"rules\": [\n {\n \"field\": \"has_tag\",\n \"op\": \"has\",\n \"value\": \"3f8c1a02-9d44-4b6e-bb12-7a9e0c5d2f31\"\n }\n ]\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>"
}Authorizations
Your workspace API key. It both authenticates the caller and selects the workspace.
Body
Response
Success.
Was this page helpful?

