To specify the segment of contacts you want to target with your campaign, you need to select the set of requirements to be fulfilled by those contacts. This is done via the Expression property in a contactfilter object.
curl -s \
-X POST \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/contactfilter \
-H 'Content-Type: application/json' \
-d '{
"Description":"Will send only to contacts under 35 years of age.",
"Expression":"(age<35)",
"Name":"Customers under 35"
}'{
"Count": 1,
"Data": [
{
"Description": "Will send only to contacts under 35 years of age.",
"Expression": "(age<35)",
"Name": "Customers under 35",
"ID": 123,
"Status": "unused"
}
],
"Total": 1
}You can create simple expressions using the =, <, > and != operators. Every single expression should be presented in parentheses.
"Expression": "(string_property=\"male\")"
"Expression": "(integer_property<40)"
"Expression": "(boolean_property=true)"
You can also apply the negative statement not. When using not, the expression should be surrounded by an additional set of parentheses:
"Expression": "((not IsProvided(date)))"
You can combine simple expressions using AND and OR operators to formulate complex ones. When entering more than two expressions, you need to specify the order of operations by adding additional sets of parentheses.
"Expression": "((string_property=\"male\") AND (integer_property<32)) OR (boolean_property=true)"
"Expression": "(string_property=\"male\") AND ((integer_property<32) OR (boolean_property=true))"