curl --request POST \
--url https://cloudapi.mailercloud.com/v1/segments \
--header 'Authorization: <api-key>' \
--header 'Content-Type: <content-type>' \
--data '
{
"name": "Active gmail subscribers",
"match": "all",
"lists": [
"Newsletter Subscribers"
],
"rules": [
{
"filter_type": "contact_details",
"field": "email_status",
"operator": "equal_to",
"value": "valid"
},
{
"filter_type": "contact_details",
"field": "email_domain",
"operator": "contains",
"value": "gmail"
}
]
}
'{
"id": "EKZwS"
}{
"errors": [
{
"field": "rules[0].field",
"message": "Unknown contact_details field 'foo'"
},
{
"field": "rules[1].value",
"message": "between requires { from, to }"
}
]
}{
"errors": [
{
"field": "",
"message": "Authorization failed"
}
]
}{
"errors": [
{
"field": "",
"message": "Plan does not include segmentation"
}
]
}{
"message": "Internal server error"
}Create Segment
API to create a segment in a single request. name, match and rules are required. lists is optional - if omitted, the segment evaluates against all contacts.
A segment is a dynamic contact filter built from a list of rules. Each rule belongs to one of 4 filter_types: contact_details (built-in contact fields), contact_property (custom properties), tag (contact tags), or activity (campaign / automation / engagement events). The match field controls whether ALL rules must match (all) or ANY rule is enough (any).
POST
/
segments
curl --request POST \
--url https://cloudapi.mailercloud.com/v1/segments \
--header 'Authorization: <api-key>' \
--header 'Content-Type: <content-type>' \
--data '
{
"name": "Active gmail subscribers",
"match": "all",
"lists": [
"Newsletter Subscribers"
],
"rules": [
{
"filter_type": "contact_details",
"field": "email_status",
"operator": "equal_to",
"value": "valid"
},
{
"filter_type": "contact_details",
"field": "email_domain",
"operator": "contains",
"value": "gmail"
}
]
}
'{
"id": "EKZwS"
}{
"errors": [
{
"field": "rules[0].field",
"message": "Unknown contact_details field 'foo'"
},
{
"field": "rules[1].value",
"message": "between requires { from, to }"
}
]
}{
"errors": [
{
"field": "",
"message": "Authorization failed"
}
]
}{
"errors": [
{
"field": "",
"message": "Plan does not include segmentation"
}
]
}{
"message": "Internal server error"
}Authorizations
Body
application/json
Response
Created
The response is of type object.