Segments API
Rule-based groups of contacts. 8 ops: get_segment_fields, list_segments, get_segment, preview_segment, create_segment, update_segment, delete_segment, explain_segment_membership.
Rule-based groups of contacts.
Get segment fields · POST /api/v1/get_segment_fields · scope segments:read or GET …?input=
The fields, field families (attributes.<key>, consent.<purpose>, event.<name>) and operators a segment definition may use, with what each means.
curl -X POST https://getwabi.dev/api/v1/get_segment_fields \ -H "Authorization: Bearer wabi_…"npx @meterapp/wabi get_segment_fields{
"type": "object",
"properties": {}
}list_segments
readList segments · POST /api/v1/list_segments · scope segments:read or GET …?input=
Saved segments (with their last computed member count) and the built-in ones (builtin:needs_reply, builtin:window_expiring, builtin:marketing_eligible…). Use a segment id in list_contacts, export_contacts or create_campaign. plan_allows_saving says whether create_segment works on this plan.
curl -X POST https://getwabi.dev/api/v1/list_segments \ -H "Authorization: Bearer wabi_…"npx @meterapp/wabi list_segments{
"type": "object",
"properties": {}
}get_segment
readGet a segment · POST /api/v1/get_segment · scope segments:read or GET …?input=
A segment's definition with its live member count and the first members.
curl -X POST https://getwabi.dev/api/v1/get_segment \ -H "Authorization: Bearer wabi_…" \ -H "Content-Type: application/json" \ -d '{"segment":"segment"}'npx @meterapp/wabi get_segment --json '{"segment":"segment"}'{
"type": "object",
"properties": {
"segment": {
"type": "string",
"maxLength": 64
},
"limit": {
"default": 20,
"type": "integer",
"minimum": 1,
"maximum": 100
}
},
"required": [
"segment"
]
}preview_segment
readPreview a segment · POST /api/v1/preview_segment · scope segments:read or GET …?input=
Counts and lists the contacts an unsaved definition matches, to try rules before saving. Works on every plan.
curl -X POST https://getwabi.dev/api/v1/preview_segment \ -H "Authorization: Bearer wabi_…" \ -H "Content-Type: application/json" \ -d '{"definition":null}'npx @meterapp/wabi preview_segment --json '{"definition":null}'{
"type": "object",
"properties": {
"definition": {
"description": "Rule tree: { op: \"and\"|\"or\", rules: [ { field, operator, value?, unit?, within_days? } | <nested group> ] }. Fields: name, wa_id, email, locale, timezone, source, external_id, tags, created_at, last_inbound_at, last_outbound_at, opted_out, window.open, window.expires_at, conversation.needs_reply, conversation.escalated, conversation.open, template.unanswered, attributes.<key>, consent.<purpose>, event.<name>. get_segment_fields lists operators per field."
},
"limit": {
"default": 20,
"type": "integer",
"minimum": 1,
"maximum": 100
},
"offset": {
"default": 0,
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"definition"
]
}create_segment
writeCreate a segment · POST /api/v1/create_segment · scope segments:write
Saves a named segment (Growth plan and up). Membership stays live: it is computed when read. Returns the segment with its member count.
curl -X POST https://getwabi.dev/api/v1/create_segment \ -H "Authorization: Bearer wabi_…" \ -H "Content-Type: application/json" \ -d '{"name":"Support","definition":null}'npx @meterapp/wabi create_segment --json '{"name":"Support","definition":null}'{
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"description": {
"default": "",
"type": "string",
"maxLength": 500
},
"definition": {
"description": "Rule tree: { op: \"and\"|\"or\", rules: [ { field, operator, value?, unit?, within_days? } | <nested group> ] }. Fields: name, wa_id, email, locale, timezone, source, external_id, tags, created_at, last_inbound_at, last_outbound_at, opted_out, window.open, window.expires_at, conversation.needs_reply, conversation.escalated, conversation.open, template.unanswered, attributes.<key>, consent.<purpose>, event.<name>. get_segment_fields lists operators per field."
}
},
"required": [
"name",
"definition"
]
}update_segment
writeUpdate a segment · POST /api/v1/update_segment · scope segments:write
Renames a saved segment or replaces its definition. Returns it with a fresh count.
curl -X POST https://getwabi.dev/api/v1/update_segment \ -H "Authorization: Bearer wabi_…" \ -H "Content-Type: application/json" \ -d '{"segment":"6f1c2e0a-4b7d-4c2e-9a51-0d3b8e7f9a10"}'npx @meterapp/wabi update_segment --json '{"segment":"6f1c2e0a-4b7d-4c2e-9a51-0d3b8e7f9a10"}'{
"type": "object",
"properties": {
"segment": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"description": {
"type": "string",
"maxLength": 500
},
"definition": {
"description": "Rule tree: { op: \"and\"|\"or\", rules: [ { field, operator, value?, unit?, within_days? } | <nested group> ] }. Fields: name, wa_id, email, locale, timezone, source, external_id, tags, created_at, last_inbound_at, last_outbound_at, opted_out, window.open, window.expires_at, conversation.needs_reply, conversation.escalated, conversation.open, template.unanswered, attributes.<key>, consent.<purpose>, event.<name>. get_segment_fields lists operators per field."
}
},
"required": [
"segment"
]
}delete_segment
writeDelete a segment · POST /api/v1/delete_segment · scope segments:write
Deletes a saved segment (contacts are untouched; campaigns keep their recipients).
curl -X POST https://getwabi.dev/api/v1/delete_segment \ -H "Authorization: Bearer wabi_…" \ -H "Content-Type: application/json" \ -d '{"segment":"6f1c2e0a-4b7d-4c2e-9a51-0d3b8e7f9a10"}'npx @meterapp/wabi delete_segment --json '{"segment":"6f1c2e0a-4b7d-4c2e-9a51-0d3b8e7f9a10"}'{
"type": "object",
"properties": {
"segment": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
}
},
"required": [
"segment"
]
}Why a contact qualifies · POST /api/v1/explain_segment_membership · scope segments:read or GET …?input=
Evaluates a segment (or an unsaved definition) on one contact and returns every rule with matched true/false and the contact's actual value, so you can see why they are in or out.
curl -X POST https://getwabi.dev/api/v1/explain_segment_membership \ -H "Authorization: Bearer wabi_…"npx @meterapp/wabi explain_segment_membership{
"type": "object",
"properties": {
"segment": {
"type": "string",
"maxLength": 64
},
"definition": {
"description": "Rule tree: { op: \"and\"|\"or\", rules: [ { field, operator, value?, unit?, within_days? } | <nested group> ] }. Fields: name, wa_id, email, locale, timezone, source, external_id, tags, created_at, last_inbound_at, last_outbound_at, opted_out, window.open, window.expires_at, conversation.needs_reply, conversation.escalated, conversation.open, template.unanswered, attributes.<key>, consent.<purpose>, event.<name>. get_segment_fields lists operators per field."
},
"contact": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
"description": "Contact id."
},
"wa_id": {
"type": "string",
"maxLength": 32
}
}
}