How rules work
Rules are conditions attached to a flag. All enabled rules must pass for the flag to be active.
If the client does not pass context, no rule can match — enabled: false, value: null is returned.
Rules only activate when the eval request body contains the keys they reference. A missing
key is treated as a non-match. Always handle null on the
client: result.value ?? yourLocalDefault.
Evaluation flow
- 1 Client calls
POST /eval/{flag_key}with an API key and context. - 2 Rules are sorted by priority (highest first).
- 3 Every enabled rule is evaluated. If all rules pass, the flag is active and its value is returned.
- 4 If any rule fails,
enabled: falseandvalue: nullare returned. - 5 If the flag has no rules: if enabled, its value
is returned; if disabled, returns
enabled: false, value: null.
Comparators
| Comparator | Passes when | Example |
|---|---|---|
eq | context value exactly equals rule value | country eq US |
neq | context value does not equal rule value | plan neq free |
gt / gte | numeric greater than / greater-or-equal | seats gt 0 |
lt / lte | numeric less than / less-or-equal | age lte 17 |
in | context value is in a comma-separated list | plan in pro,enterprise |
not_in | context value is not in the list | country not_in CN,RU |
contains | context value contains the substring | email contains @acme.com |
semver_gt / semver_gte | semantic version greater than / ≥ | app_version semver_gte 2.0.0 |
semver_lt / semver_lte | semantic version less than / ≤ | app_version semver_lt 3.0.0 |