Docs

Segments

POST

Create Segment

POST /v1/segments

Create a new dynamic segment using MongoDB-style filter conditions.

Use Cases:

  • Build audience segments for targeted campaigns
  • Create customer cohorts based on behavior
  • Segment by demographics or properties
  • Identify high-value or at-risk contacts
  • Automate audience targeting rules

Behavior:

  • Segments are dynamic - membership updates automatically as contact data changes
  • Conditions use MongoDB query syntax for flexible filtering
  • Contact count is calculated and cached (updates periodically)
  • Supports complex nested conditions with $and, $or, $not
  • Can filter on any contact property (default or custom)
  • Conditions are validated against property schemas

Required Scope: write:segments

Condition Operators:

  • Comparison: $eq, $ne, $gt, $gte, $lt, $lte
  • Arrays: $in, $nin
  • Logical: $and, $or, $not
  • Existence: $exists
  • Text: $regex (for pattern matching)

Example Conditions:

{
  "$and": [
    { "country": { "$eq": "US" } },
    { "lifetime_value": { "$gte": 100 } },
    { "last_purchase_date": { "$gte": "2024-01-01" } }
  ]
}

Best Practices:

  • Test conditions with /v1/contacts/search first
  • Keep conditions simple for better performance
  • Use indexed properties when possible
  • Document segment purpose in description

Bodyrequired

namestringrequired

Segment name (1-100 characters)

Min length: 1Max length: 100
descriptionstringnull

Optional description (max 500 characters)

Max length: 500
conditionsFieldCondition | TopicCondition | LogicalOperatorConditionrequired

A filter condition for segments and contact search. Can be a field comparison, topic subscription check, or logical operator combining multiple conditions.

Response

201Segment created successfully with generated ID, initial member count, and timestamps
object"segment"required

Object type identifier

idstringrequired

Unique segment identifier

namestringrequired

Segment name

descriptionstringnull

Segment description

conditionsFieldCondition | TopicCondition | LogicalOperatorConditionrequired

A filter condition for segments and contact search. Can be a field comparison, topic subscription check, or logical operator combining multiple conditions.

Copyright © 2026 Kibamail.·Privacy Policy