Skip to main content
POST
Create segment
Use this endpoint to create a Segment from an audience’s contacts or a campaign’s dial results, filtered by a set of conditions.

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):
  • CONDITIONLIST contains 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 OPRATER values: =, ==, ===, !=, !==, >, >=, <, <=, contains, startsWith, endsWith, like, plus the literal true/false shorthand.
  • An empty group (no conditions) is skipped; an entirely empty/absent filter_conditions matches every contact of the source.
  • For source_type: "audience", CONDITION field names are matched against each contact’s saved input fields (its input_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.
This is a different shape from the 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_name uniqueness 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 an audience_contacts row 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 own audience_id is left null).
  • total_contacts on 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

token
string
required

API token for authentication

Body

application/json
segment_name
string
required

Name for the segment. Must be unique within the workspace (among non-deleted segments).

source_type
enum<string>
required

What to build the segment from.

Available options:
audience,
campaign
audience_id
integer

ID of the audience to filter. Required when source_type is 'audience'.

campaign_id
integer

ID of the campaign whose dialed contacts to filter. Required when source_type is 'campaign'.

description
string

Free-text description of the segment.

filter_conditions
object

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
string[]

Tags for the segment. Accepts a real array, a JSON-stringified array, or a comma-separated string.

Response

Segment created successfully

message
string
data
object