Create Segment
create-segmentBuild a dynamic, rules-based audience for campaigns using contact attributes, lists, tags, engagement, or events. The audience is recomputed regularly and before each campaign send.
Instructions
Create a segment: a dynamic audience defined by rules, which campaigns target through segment_ids. Its members are recomputed regularly, and again before a campaign sends to it.
Look up what the rules will name before writing them. Property keys come from list-contact-properties, event names and their fields from list-events, list and tag ids from list-lists and list-tags, and campaign ids from the channel's campaign list tool. A filter naming a property or an event field the organization has not defined is refused.
Shape. filter is a tree whose root is always a group. A group joins its conditions with and or or, and a condition is a rule or another group, so "A and (B or C)" is an and group holding A and an or group of B and C. A filter needs at least one rule and holds at most 100, in groups nested at most 10 deep.
Choosing a rule.
Who they are, or a custom property:
attribute.The lists they are in or the tags they carry:
list_membership,tag.Whether a channel can reach them (subscribed, deliverable):
channel_status.How often they engaged with messages, optionally in a recent window:
engagement_count.When they last engaged, or that they never did:
last_engagement.What they did with one specific campaign or automation:
message_engagement.What they did in the app, site or store:
event.
Recent activity. Only engagement_count and event take a rolling time_window. Dates in attribute and last_engagement are fixed and do not move with time, so "opened an email in the last 30 days" is an engagement_count of at least 1 with a 30-day window, not a last_engagement date.
Absence. negate: true on list_membership, tag, message_engagement or event matches the contacts the rule would leave out, and last_engagement with does_not_exist matches contacts who never did the action. "Ordered before, but not in the last 90 days" is an and group of a plain event rule and the same rule with a 90-day window and negate: true.
Reaching people. A segment holds every contact its rules match, whatever their consent. Add a channel_status rule when it should hold only contacts a channel can message.
If the filter is refused, the error gives the path of each problem inside the tree (e.g. conditions.1.operator). Fix those and call again.
The segment comes back with status: processing while its members are computed in the background. Call get-segment until it is ready, then tell the user its contact_count. Creating a segment messages nobody.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"name": "<name>",
"filter": "<filter>"
},
"name": "create-segment"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| filter | Yes | ||
| description | No |