Skip to main content
POST
/
api
/
v1
/
segments
Create Segment
curl --request POST \
  --url https://api.sequenzy.com/api/v1/segments \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "filters": [
    {}
  ],
  "filterJoinOperator": "<string>",
  "root": {}
}
'
{
  "success": true,
  "segment": {
    "id": "seg_active_non_buyers",
    "name": "Active non-buyers",
    "filters": [
      {
        "id": "filter-1",
        "field": "attribute",
        "operator": "gte",
        "value": "last_login_days_ago:90"
      },
      {
        "id": "filter-2",
        "field": "event",
        "operator": "is_not",
        "value": "saas.purchase:30d"
      },
      {
        "id": "filter-3",
        "field": "segment",
        "operator": "is_not",
        "value": "seg_paying_customers"
      }
    ],
    "filterJoinOperator": "and",
    "format": "v2",
    "root": {
      "kind": "group",
      "id": "root",
      "joinOperator": "and",
      "children": [
        {
          "kind": "filter",
          "id": "filter-1",
          "field": "attribute",
          "operator": "gte",
          "value": "last_login_days_ago:90"
        },
        {
          "kind": "group",
          "id": "group-1",
          "joinOperator": "or",
          "children": [
            {
              "kind": "filter",
              "id": "filter-2",
              "field": "event",
              "operator": "is_not",
              "value": "saas.purchase:30d"
            },
            {
              "kind": "filter",
              "id": "filter-3",
              "field": "segment",
              "operator": "is_not",
              "value": "seg_paying_customers"
            }
          ]
        }
      ]
    }
  }
}
Create a segment from either the legacy flat filter array or a nested root filter group. You must provide exactly one of filters or root, and it must contain at least one filter.

Request

name
string
required
Segment name.
filters
FilterLeaf[]
Legacy v1 filter array. Use with filterJoinOperator.
filterJoinOperator
string
default:"and"
and requires every v1 filter to match. or matches any v1 filter.
root
FilterGroup
Nested v2 filter group. Use this for nested AND/OR logic, event filters, or segment filters.
Stripe trial subfilters stay under field: "stripeTrialProduct": prod_123:is_canceled, prod_123:end_at:2026-05-26, or prod_123:start_at:7 days ago. Every filter field validates its own operator set:
  • status, segment: is, is_not
  • tag: contains, not_contains, is_empty, is_not_empty
  • email: contains, not_contains
  • emailProvider, list: is, is_not, is_empty, is_not_empty
  • firstName, lastName: contains, not_contains, is_empty, is_not_empty
  • added: less_than, more_than
  • attribute: equality, empty checks, numeric/date comparisons, and contains checks
  • event, email engagement fields: is, is_not, at_least, less_than_count
  • emailBounced: also supports is_temporary_bounce, is_permanent_bounce
  • Stripe product fields: product-specific purchase/current/trial/date operators
curl -X POST "https://api.sequenzy.com/api/v1/segments" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Active non-buyers",
    "root": {
      "kind": "group",
      "id": "root",
      "joinOperator": "and",
      "children": [
        {
          "kind": "filter",
          "id": "filter-1",
          "field": "attribute",
          "operator": "gte",
          "value": "last_login_days_ago:90"
        },
        {
          "kind": "group",
          "id": "group-1",
          "joinOperator": "or",
          "children": [
            {
              "kind": "filter",
              "id": "filter-2",
              "field": "event",
              "operator": "is_not",
              "value": "saas.purchase:30d"
            },
            {
              "kind": "filter",
              "id": "filter-3",
              "field": "segment",
              "operator": "is_not",
              "value": "seg_paying_customers"
            }
          ]
        }
      ]
    }
  }'

Responses

{
  "success": true,
  "segment": {
    "id": "seg_active_non_buyers",
    "name": "Active non-buyers",
    "filters": [
      {
        "id": "filter-1",
        "field": "attribute",
        "operator": "gte",
        "value": "last_login_days_ago:90"
      },
      {
        "id": "filter-2",
        "field": "event",
        "operator": "is_not",
        "value": "saas.purchase:30d"
      },
      {
        "id": "filter-3",
        "field": "segment",
        "operator": "is_not",
        "value": "seg_paying_customers"
      }
    ],
    "filterJoinOperator": "and",
    "format": "v2",
    "root": {
      "kind": "group",
      "id": "root",
      "joinOperator": "and",
      "children": [
        {
          "kind": "filter",
          "id": "filter-1",
          "field": "attribute",
          "operator": "gte",
          "value": "last_login_days_ago:90"
        },
        {
          "kind": "group",
          "id": "group-1",
          "joinOperator": "or",
          "children": [
            {
              "kind": "filter",
              "id": "filter-2",
              "field": "event",
              "operator": "is_not",
              "value": "saas.purchase:30d"
            },
            {
              "kind": "filter",
              "id": "filter-3",
              "field": "segment",
              "operator": "is_not",
              "value": "seg_paying_customers"
            }
          ]
        }
      ]
    }
  }
}