Create Segment
Create a Segment — a saved filter over either an audience’s contacts (source_type=audience, SOURCE_TYPE=1) or a campaign’s dial results (source_type=campaign, SOURCE_TYPE=2). Matching contacts are evaluated immediately and materialized into the segment’s contact mapping.
Endpoint
POST/segment/create
Content-Type: application/json
Authentication: Required (workspace auth)
Request Body
Create from an Audience (source_type: "audience")
Create from a Campaign (source_type: "campaign")
Filter Conditions Format (CONDITIONLIST)
filter_conditions (or its alias conditions) is stored and evaluated as received, in the same nested tree format used by the product’s condition builder elsewhere (e.g. workflow branching):
CONDITIONLISTcontains numbered branches; each branch contains numbered groups; each group contains numbered conditions. The numbers themselves are arbitrary strings — only the nesting position matters.- Conditions within one group are AND’ed together. A contact matches the segment if any group in any branch has all of its conditions pass (OR of ANDs).
- Supported
OPRATERvalues:=,==,===,!=,!==,>,>=,<,<=,contains,startsWith,endsWith,like, plus the literaltrue/falseshorthand. - An empty group (no conditions) is skipped; an entirely empty/absent
filter_conditionsmatches every contact of the source. - For
source_type: "audience",CONDITIONfield names are matched against each contact’s saved input fields (itsinput_data). - For
source_type: "campaign", in addition to the dial row’s input fields, these computed fields are also available:status,status_label,first_status,call_status,last_status,last_disposition,total_attempt,total_duration,followup_count,mobile_no.
conditions array used by Preview Segment and Update Segment ([{ field, operator, value }]). Updating a segment’s filters through Update Segment rewrites filter_conditions into that flat shape, replacing whatever CONDITIONLIST tree was stored at creation.Response
Behavior
segment_nameuniqueness is checked across the whole workspace (non-deleted segments), regardless of source type.- Audience source (
SOURCE_TYPE = 1): every active contact of the audience is evaluated against the filter now; matches are written into the segment’s contact mapping (used later by List/Export Segment Contacts and by any campaign the segment is attached to). - Campaign source (
SOURCE_TYPE = 2): the campaign’s dial rows (campaign_audience_details) are evaluated instead — each row’s call-outcome fields merged with its input data. Only dial rows already linked to anaudience_contactsrow are eligible; matched contacts are de-duplicated and mapped with their own resolved source audience (a campaign can span multiple audiences, so the segment’s ownaudience_idis leftnull). total_contactson the created segment is the count of matched contacts at creation time (cached).- If at least one contact matched, the “On Segment Upload” workflow trigger fires for the workspace (failures here are logged but don’t fail the request).
Error Cases
Example cURL
Headers
API token for authentication
Body
Name for the segment. Must be unique within the workspace (among non-deleted segments).
What to build the segment from.
audience, campaign ID of the audience to filter. Required when source_type is 'audience'.
ID of the campaign whose dialed contacts to filter. Required when source_type is 'campaign'.
Free-text description of the segment.
Filter tree in CONDITIONLIST format: { CONDITIONLIST: { : { : { : { CONDITION, OPRATER, VALUE_MATCH } } } } }. Conditions within a group are AND'ed; any matching group in any branch is a match (OR of ANDs). OPRATER supports =, ==, ===, !=, !==, >, >=, <, <=, contains, startsWith, endsWith, like. Alias: conditions. Omitted/empty matches every contact of the source.
Tags for the segment. Accepts a real array, a JSON-stringified array, or a comma-separated string.

