Build your first segment
Describe a group of people by what they did and who they are, preview it, save it and watch it update.
A segment is a saved rule. People join and leave it by themselves as events and profile changes arrive.
What you need first
Some people and events (see Track events).
A key with
segments:write.
1. Write the rule and preview it
This finds people who signed up but have not sent a first campaign in the last 60 days:
DEF='{"type":"group","op":"and","children":[
{"type":"event","name":"Signed up"},
{"type":"event","name":"Sent first campaign","negate":true,"window":{"kind":"last_days","days":60}}]}'
curl -s -X POST "$BASE/v1/segments/preview" \
-H "Authorization: Bearer $HERMETICA_API_KEY" -H "Content-Type: application/json" \
-d "{\"definition\":$DEF}"You get a count and a sample of people.
2. Save it
curl -s -X POST "$BASE/v1/segments" \
-H "Authorization: Bearer $HERMETICA_API_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: seg-not-activated" \
-d "{\"name\":\"Signed up, not activated\",\"folder\":\"Funnel\",\"definition\":$DEF}"
curl -s -X POST "$BASE/v1/segments/<segmentId>/evaluate" \
-H "Authorization: Bearer $HERMETICA_API_KEY" -H "Content-Type: application/json" -d '{}'
# 202: the first fill runs in the background3. See who is in it
curl -s "$BASE/v1/segments/<segmentId>/members" -H "Authorization: Bearer $HERMETICA_API_KEY"
curl -s "$BASE/v1/segments/<segmentId>/explain-match/<profileId>" -H "Authorization: Bearer $HERMETICA_API_KEY"explain-match says why one person is in or out. GET /v1/segments/<id>/translate reads the rule back in plain English.
Other conditions
Want | Condition |
|---|---|
A profile field |
|
A tag |
|
Can get marketing email now |
|
You do not need the last one to protect consent. Every send checks consent and suppression anyway. It is useful for counting who you can reach.
Next: Send your first campaign.