Create a segment
Create a custom segment from conditions such as Did not open a campaign.
POST https://cotlet.dev/api/v1/privy/segments
write
Creates the segment and returns its id and current mailable_count. Privy cannot edit the conditions of a segment after creation, so a wrong condition means a new segment; a custom segment can be deleted in Contacts > Segments. It reaches no one, so it does not wait for your OK. Campaigns in a "Did not open" condition are listed by their name, not their subject line.
Parameters
| Name | Type | Description |
|---|---|---|
| name string required | string | Segment name. Only you see it, contacts do not |
| match string | string | all (Match all, the default) or any (Match any) |
| conditions array required | array | Objects with category, rule and value as in Privy's Choose Category picker, for example Email Engagement, Did not open, and a campaign name |
Request
curl -X POST https://cotlet.dev/api/v1/privy/segments \
-H "Authorization: Bearer $COTLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Jane Doe","conditions":"conditions"}' result = client.call("privy", "create_segment", {"name":"Jane Doe","conditions":"conditions"}) const result = await cotlet.call('privy', 'create_segment', {"name":"Jane Doe","conditions":"conditions"}); cotlet call privy create_segment --data '{"name":"Jane Doe","conditions":"conditions"}' Example response
{
"segment_id": "seg_7d20",
"name": "Did not open October sale",
"match": "all",
"conditions": [
{
"category": "Email Engagement",
"rule": "Did not open",
"value": "October sale announcement"
}
],
"mailable_count": 2890
}