Skip to content

Create a segment

Request

Create a new segment (static or dynamic).

Dynamic Segments:

  • Auto-update based on filter conditions
  • Contacts added/removed automatically as they match/unmatch filters
  • Refresh on-demand or via cron

Static Segments:

  • Manual membership control
  • Contacts must be explicitly added/removed
  • Useful for one-time campaigns or curated lists

Available Filters:

System Fields:

  • status - Contact subscription status

    • Operators: equals, not_equals
    • Values: subscribed, unsubscribed, bounced, complained
  • source - How contact was added

    • Operators: equals, not_equals, contains, not_contains, starts_with, ends_with, is_empty, has_value
    • Values: api, import, form, manual, or any custom source

Contact Info Fields:

  • email, first_name, last_name, phone, city, country
    • Operators: equals, not_equals, contains, not_contains, starts_with, not_starts_with, ends_with, not_ends_with, is_empty, has_value
    • Values: Any text string, comma-separated string, or string array.
    • Multi-value examples:
      • {"field": "email", "operator": "equals", "value": ["a@example.com", "b@example.com"]}
      • {"field": "email", "operator": "contains", "value": "gmail.com, yahoo.com"}

Tag Filters:

  • tags - Contact has any of these tags

    • Operators: in, contains, starts_with
    • Values: Array of tag names ["tag1", "tag2"] or comma-separated string "tag1, tag2"
  • tags_has_all - Contact has ALL of these tags

    • Operator: has_all
    • Values: Array of tag names ["tag1", "tag2"] or comma-separated string "tag1, tag2"
  • tags_not - Contact does NOT have any of these tags

    • Operator: not_in
    • Values: Array of tag names ["tag1", "tag2"] or comma-separated string "tag1, tag2"

Campaign Engagement:

  • campaign_opened - Campaign open tracking

    • Operators: has_opened, has_not_opened, at_least, exactly, more_than, less_than, at_most, never
    • Value: Campaign ID (UUID) or count number
    • Additional filters: campaign_ids (array), time_period_days, exclude_scanner (boolean)
  • campaign_clicked - Campaign click tracking

    • Operators: has_clicked, has_not_clicked, at_least, exactly, more_than, less_than, at_most, never
    • Value: Campaign ID (UUID) or count number
    • Additional filters: campaign_ids (array), time_period_days, link_url, exclude_scanner (boolean)
  • campaign_sent - Campaign delivery tracking

    • Operators: has_received, has_not_received, was_sent, was_not_sent
    • Value: Campaign ID (UUID)
    • Additional filters: campaign_ids (array), time_period_days

Date Filters:

  • Built-in date fields: created_at, updated_at, last_sent_at
  • Custom date fields: custom_properties.<property_name> with property_type, value_type, data_type, or type set to date or datetime
  • Fixed date operators:
    • exact_date: one calendar date, value "2026-06-19"
    • before: before a date/datetime
    • after: after a date/datetime
    • on_or_before: on or before a date/datetime
    • on_or_after: on or after a date/datetime
    • fixed_period or between: inclusive date range, value { "start": "2026-06-01", "end": "2026-06-19" }
  • Dynamic date operators:
    • today
    • yesterday
    • in_last / within_last_days: value { "amount": 7, "unit": "days" }; unit can be days, weeks, or months
    • more_than: value { "amount": 30, "unit": "days" }
    • days_ago, weeks_ago, months_ago: value is the number of days/weeks/months ago
    • between_past_dates: value { "start": "2026-05-01", "end": "2026-05-31" }
  • Empty checks: is_empty, has_value, never

Custom Properties:

  • custom_properties.<property_name> - Filter by any custom property
    • Text operators: equals, not_equals, contains, not_contains, starts_with, not_starts_with, ends_with, not_ends_with, is_empty, has_value, exists, not_exists
    • Numeric operators: >, >=, <, <=, =
    • Values: Any text or number based on property type. Text operators accept a string array or comma-separated string for multiple values.

Multi-value Text Filters:

  • Text/tag filters accept up to 100 values per rule.
  • The backend accepts both arrays and comma-separated strings, but new UIs should send arrays.
  • For positive operators (equals, contains, starts_with, ends_with), a contact matches if any supplied value matches.
  • For negative operators (not_equals, not_contains, not_starts_with, not_ends_with, not_in), a contact matches only when none of the supplied values match.

Filter Structure:

{
  "filters": [
    {
      "field": "status",
      "operator": "equals",
      "value": "subscribed"
    },
    {
      "field": "email",
      "operator": "not_contains",
      "value": ["example.com", "testmail.com"]
    },
    {
      "field": "created_at",
      "operator": "in_last",
      "value": { "amount": 30, "unit": "days" }
    },
    {
      "field": "custom_properties.company_size",
      "operator": ">=",
      "value": 100
    }
  ],
  "match_type": "all"
}

Match Types:

  • all (AND) - Contact must match ALL filters
  • any (OR) - Contact must match ANY filter
Security
ApiKeyAuth
Bodyapplication/jsonrequired
namestringrequired

Unique segment name

Example:"VIP Customers"
descriptionstring
Example:"High-value customers with premium tag"
is_dynamicboolean

If true, segment auto-updates based on filters

Default:true
filter_conditionsobject

Filter rules (required for dynamic segments).

Can use either simple format or filter builder format:

  • Simple: {"status": "subscribed", "source": "form"}
  • Filter Builder: {"filters": [...], "match_type": "all"}
Example:
{ "filters": [ {}, {} ], "match_type": "all" }
contact_idsArray of strings, (uuid)

Initial contacts for static segments

Example:
[ "uuid1", "uuid2" ]
curl -i -X POST \
  https://api.mailerlogic.net/api/v1/contacts/segments \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY_HERE' \
  -d '{
    "name": "Engaged Newsletter Subscribers",
    "description": "Subscribed contacts who opened our welcome campaign",
    "is_dynamic": true,
    "filter_conditions": {
      "filters": [
        {
          "field": "status",
          "operator": "equals",
          "value": "subscribed"
        },
        {
          "field": "campaign_opened",
          "operator": "has_opened",
          "value": "aa53af3b-a5ea-4057-9618-88c5245b842a"
        },
        {
          "field": "tags",
          "operator": "in",
          "value": [
            "newsletter",
            "verified"
          ]
        }
      ],
      "match_type": "all"
    }
  }'

Responses

Segment created successfully

Response
No content