Segment Operators
All 12 operators supported by the Amba segment rule evaluator, with examples of the fields each one works on.
This page lists every operator the segment rule evaluator supports, the fields each one is valid against, and the exact SQL that gets emitted. All identifiers are whitelisted — admin-authored rules cannot inject arbitrary SQL.
Operator reference
| Operator | Valid on | Example |
|---|---|---|
eq | any | properties.plan eq "premium" |
neq | any | properties.plan neq "free" |
gt | numeric / timestamp | properties.total_xp gt 1000 |
gte | numeric / timestamp | properties.streak_count gte 7 |
lt | numeric / timestamp | properties.age lt 25 |
lte | numeric / timestamp | properties.age lte 25 |
contains | string / text-castable field | email contains "@example.com" |
not_contains | string / text-castable field | email not_contains "spam" |
exists | any | email exists |
not_exists | any | email not_exists |
within | date column only | last_seen_at within "7d" |
not_within | date column only | last_seen_at not_within "30d" |
Field domains
The evaluator resolves field into one of four target surfaces. Anything outside the whitelists silently falls back to FALSE (the condition never matches) rather than raising — an admin typo in a rule won't take the workflow down.
Direct user fields
Whitelisted: id, external_id, anonymous_id, email, phone, display_name, first_seen_at, last_seen_at, created_at.
Custom properties (properties.*)
Any path matching [a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*. Nested keys are safe to address with dot notation:
within / not_within are not supported on property fields — promote the value to a typed column if you need time-based filtering.
Entitlements (entitlements.*)
Whitelisted columns: entitlement_id, product_id, is_active, store, period_type, purchase_date, expiration_date.
A user matches the clause if they hold any entitlement satisfying it.
Unknown fields
Treated as never-matching. No error is raised — the condition simply evaluates to false. This keeps a misconfigured rule from taking the whole segment evaluation down.
Duration literals (within / not_within)
Values are parsed as <number><unit>:
| Unit | Meaning |
|---|---|
m | minutes |
h | hours |
d | days |
w | weeks |
Examples: "15m", "24h", "7d", "2w". Invalid literals (bad unit, non-numeric) fall back to FALSE.
within matches values from the last N <unit>; not_within matches values older than that.
contains / not_contains
Case-insensitive substring match. The value must be a string — a numeric value on a contains clause never matches.
On entitlement fields the same substring check runs against each of the user's entitlements; a user matches if any one of them does.
exists / not_exists
On direct user fields: matches when the field is set (exists) or unset (not_exists).
On property paths: works the same way over nested property keys.
On entitlements: matches when the user has any entitlement with that field populated.
Composing rules
A rule is a tree of boolean groups. Each group has an operator (AND / OR) and a conditions array; entries in conditions are either leaf conditions or further nested groups. The evaluator wraps each group in parens, so operator precedence is explicit — you don't have to memorise that AND binds tighter than OR.
Flat (single group) rules are still the common case:
Nested boolean groups
Mix groups to express things like "active iOS users AND (Pro OR Enterprise plan)":
Depth is capped at 5 (the top-level group counts as depth 1). Rules deeper than the cap are rejected with SEGMENT_RULES_TOO_DEEP. An empty inner AND group evaluates to TRUE; an empty inner OR group evaluates to FALSE — algebraic identity, so adding an empty branch never changes the truth value of an enclosing group of the same operator.
Evaluation cadence
Every 15 minutes, Amba re-evaluates every non-system segment and recomputes segment_memberships. Manual POST /admin/segments/:id/evaluate triggers a one-off immediate run against that segment only.
Next
- Quickstart — create + target your first segment.
- Remote config — segment-gated feature flags.
- Push campaigns — segment-targeted pushes.