Create segment
Create a segment from activity, list and contact property filters.
POST https://cotlet.dev/api/v1/mailjet/segments
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. |
Request
curl -X POST https://cotlet.dev/api/v1/mailjet/segments \
-H "Authorization: Bearer $COTLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Did not open: Autumn offer","match":"all","conditions":[{"type":"campaign_not_opened","value":7164820931},{"type":"subscribed_to_list","value":10234567}],"list_id":10234567}' result = client.call("mailjet", "create_segment", {"name":"Did not open: Autumn offer","match":"all","conditions":[{"type":"campaign_not_opened","value":7164820931},{"type":"subscribed_to_list","value":10234567}],"list_id":10234567}) const result = await cotlet.call('mailjet', 'create_segment', {"name":"Did not open: Autumn offer","match":"all","conditions":[{"type":"campaign_not_opened","value":7164820931},{"type":"subscribed_to_list","value":10234567}],"list_id":10234567}); cotlet call mailjet create_segment --data '{"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
{
"segment_id": 2938471,
"name": "Did not open: Autumn offer",
"match": "all",
"conditions": 2,
"matching_contacts": 1121,
"list_id": 10234567
}