Segments: Create v2

You can create dynamic segments using segments create api so here is some of the information

String

For string values you can use these match_types:

  • equal
  • not_equal
  • starts_with
  • ends_with
  • contains

Number Fields

For number values you can use these match_types:

  • less
  • more
  • between
  • equal
  • not_equal

Datetime Fields
To manage DateTime specific fields you can utilize it like this
Let's suppose last_contacted is a datetime field
You can add rules like we mentioned below

  • less than 2 minutes ago, rules can be specified as this
    rules: [ { "type": "last_contacted", "match_type": "less", "match_value": "2", "time_frame": "minutes" } ]
  • more than 2 hours ago
    rules: [ { "type": "last_contacted", "match_type": "more", "match_value": "2", "time_frame": "hours" } ]
  • equal to 34 weeks ago
    rules: [ { "type": "last_contacted", "match_type": "equal", "match_value": "34", "time_frame": "weeks" } ]
  • not equal to 33 months ago
    rules: [ { "type": "last_contacted", "match_type": "not_equal", "match_value": "33", "time_frame": "months" } ]
  • between 3 and 4 days ago
    rules: { "type": "last_contacted", "match_type": "between", "match_value": "3", "time_frame": "days", "match_end_value": "4" }

Alias

To create segment to target users with specific aliases, you can simply use all match_types that are available for string

Let's take an example of below rule:
it will pick all users whose:

Alias contains test string OR those whose alias starts with j OR those whose alias ends with l

"rules": [
        {
          "type": "alias",
          "match_value": "test",
          "match_type": "contains"
        },
        {
          "type": "alias",
          "match_value": "j",
          "match_type": "starts_with"
        },
        {
          "type": "alias",
          "match_value": "l",
          "match_type": "ends_with"
        }
      ]

Note
You can use OR operator by adding more objects under rules array like we are doing in sample request

if signup is less than 1 day ago or if last_active is less than 12 hours ago

For AND operator, you can add more join types and rules objects that we did in our sample request

Our sample request results into this:

Segment all users

whose email contains value test

AND

whose signup is less than 1 day ago OR last_active is less than 12 hours ago

AND

whose age is between 20 and 40

Language
Credentials
Header
Click Try It! to start a request and see the response here!