Create segment
Create a segment from activity, list and contact property filters.
MCP tool mailjet_write → create_segment
write
Does what Create a segment does on the Segmentation page. match "all" combines the filters with AND and "any" with OR. Pass list_id to get the number of contacts that match, as Calculate number of contacts does. The segment reaches no one and is undone by deleting it in the Dashboard, so it does not wait for your OK. Mailjet recalculates it at send time.
Parameters
| Name | Type | Description |
|---|---|---|
| name string required | string | Name of the segment. |
| match enum | enum | all (AND) or any (OR). Default: all. |
| conditions array required | array | Filters as {type, value}. type: campaign_opened, campaign_not_opened, campaign_clicked or campaign_not_clicked (value: campaign_id); opened_last_days, not_opened_last_days, clicked_last_days or not_clicked_last_days (value: number of days); subscribed_to_list or not_subscribed_to_list (value: list_id); property (also field, operator and value). |
| list_id integer | integer | List to count the matching contacts against. |
tools/call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "mailjet_write",
"arguments": {
"operation": "create_segment",
"arguments": {
"name": "Did not open: Autumn offer",
"match": "all",
"conditions": [
{
"type": "campaign_not_opened",
"value": 7164820931
},
{
"type": "subscribed_to_list",
"value": 10234567
}
],
"list_id": 10234567
}
}
}
} Example response
{
"content": [
{
"type": "text",
"text": "{ ... same JSON as structuredContent ... }"
}
],
"structuredContent": {
"segment_id": 2938471,
"name": "Did not open: Autumn offer",
"match": "all",
"conditions": 2,
"matching_contacts": 1121,
"list_id": 10234567
},
"isError": false
}