Create a segment

Create a live filter on a contact book.

POSThttps://app.usenotix.dev/api/v1/contactBooks/{contactBookId}/segments

Needs a full access key. Sending access keys cannot call this. Key permissions lists the extra rules some calls have.

Create a live filter on a contact book. A segment is evaluated whenever it is used, so contacts join and leave it as their details and behaviour change.

Definition

match is all or any, and conditions holds up to 20 conditions, counting those inside groups. A condition can be a group with its own match; groups do not nest.

typeOperatorsFields
emailequals, not_equals, contains, ends_withvalue
first_name, last_nameequals, not_equals, contains, is_set, is_emptyvalue, except for is_set and is_empty
subscribedisvalue: true or false
addedbefore, after, in_last_daysvalue: a date, or a number of days
propertyequals, not_equals, contains, is_set, is_empty, gt, gte, lt, ltekey (a variable on the book) and value
email_activityin_last_days, ever, neverevent: received, opened or clicked; optional campaignId; days for in_last_days
email_problemever, neverevent: bounced or complained
journeyis_in, completed, exited, not_injourneyId

Text comparisons ignore case. A contact book holds at most 100 segments.

json
{
  "name": "Engaged Pro users",
  "definition": {
    "version": 1,
    "match": "all",
    "conditions": [
      { "type": "property", "key": "plan", "op": "equals", "value": "Pro" },
      {
        "type": "group",
        "match": "any",
        "conditions": [
          { "type": "email_activity", "event": "opened", "op": "in_last_days", "days": 30 },
          { "type": "email_activity", "event": "clicked", "op": "in_last_days", "days": 30 }
        ]
      }
    ]
  }
}

Path parameters

contactBookIdstringrequired

Body parameters

namestringrequired

At most 80 characters.

descriptionstring

At most 280 characters. Can be null.

definitionobjectrequired
definition.versionnumberrequired

One of 1.

definition.matchstringrequired

One of all, any.

definition.conditionsobject[]required

Headers

Authorizationstringrequired

Bearer followed by your API key.

Errors

400

The definition is not valid, names something the book or team does not have, or the book already has 100 segments.

404

No contact book with this id for the calling team.

409

A segment with this name already exists in the contact book.

Every error has the same shape. See all error codes.

curl -X POST "https://app.usenotix.dev/api/v1/contactBooks/<contactBookId>/segments" \
  -H "Authorization: Bearer $NOTIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Engaged Pro users",
  "definition": {
    "version": 1,
    "match": "all",
    "conditions": [
      {
        "type": "property",
        "key": "plan",
        "op": "equals",
        "value": "Pro"
      },
      {
        "type": "email_activity",
        "event": "opened",
        "op": "in_last_days",
        "days": 30
      }
    ]
  }
}'
Response201
{
  "id": "cm1x8f3k20001qz7v5b9d2e4a",
  "contactBookId": "cm1x8f3k20001qz7v5b9d2e4a",
  "name": "Acme",
  "description": "string",
  "definition": {
    "version": 1,
    "match": "all",
    "conditions": [
      {
        "type": null,
        "match": null,
        "conditions": null
      }
    ]
  },
  "count": 1,
  "problems": [
    "string"
  ],
  "createdAt": "string",
  "updatedAt": "string"
}
Open in ClaudeOpen in ChatGPT