Create segment
Create a reusable segment on a list from conditions on tags, fields, dates, source or campaign and contact activity.
POST https://cotlet.dev/api/v1/emailoctopus/lists/{list_id}/segments
Saves a segment on the Segments tab of the Contacts page and returns it. match is all, any or none, as in the segment editor. Each condition has a type, an operator in the words of the editor (for example "did not open", "was sent", "active or added within") and a value such as a campaign name, a tag or a number of days. Contact activity looks back at most 365 days. The segment holds no email by itself, so creating it reaches no one; it only changes who a later campaign or bulk action can pick.
Parameters
| Name | Type | Description |
|---|---|---|
| list_id string required | string | List ID from list_lists. |
| name string required | string | Name of the segment. |
| match enum required | enum | all, any or none of the conditions must match. |
| conditions array required | array | Objects with type, operator and value. type: first_name, last_name, field, date_created, last_updated, source, segment, campaign_activity, contact_activity or tag. |
Request
curl -X POST https://cotlet.dev/api/v1/emailoctopus/lists/4d1c8e5a-7f2b-4c1e-9a63-0b5d2e8f1a37/segments \
-H "Authorization: Bearer $COTLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Did not open: Autumn offer","match":"all","conditions":[{"type":"campaign_activity","operator":"did not open","value":"Autumn offer"},{"type":"campaign_activity","operator":"was sent","value":"Autumn offer"}]}' result = client.call("emailoctopus", "create_segment", {"list_id":"4d1c8e5a-7f2b-4c1e-9a63-0b5d2e8f1a37","name":"Did not open: Autumn offer","match":"all","conditions":[{"type":"campaign_activity","operator":"did not open","value":"Autumn offer"},{"type":"campaign_activity","operator":"was sent","value":"Autumn offer"}]}) const result = await cotlet.call('emailoctopus', 'create_segment', {"list_id":"4d1c8e5a-7f2b-4c1e-9a63-0b5d2e8f1a37","name":"Did not open: Autumn offer","match":"all","conditions":[{"type":"campaign_activity","operator":"did not open","value":"Autumn offer"},{"type":"campaign_activity","operator":"was sent","value":"Autumn offer"}]}); cotlet call emailoctopus create_segment --data '{"list_id":"4d1c8e5a-7f2b-4c1e-9a63-0b5d2e8f1a37","name":"Did not open: Autumn offer","match":"all","conditions":[{"type":"campaign_activity","operator":"did not open","value":"Autumn offer"},{"type":"campaign_activity","operator":"was sent","value":"Autumn offer"}]}' Example response
{
"segment": "Did not open: Autumn offer",
"list_id": "4d1c8e5a-7f2b-4c1e-9a63-0b5d2e8f1a37",
"match": "all",
"conditions": [
"Campaign activity: did not open, Autumn offer",
"Campaign activity: was sent, Autumn offer"
],
"created": true
}