Targeting rules
Attributes, operators, and how rule groups combine.
Targeting rules turn a flag on for specific users based on attributes you pass at evaluation time — plan, country, email, internal team, anything. A user who matches a rule gets the enabled value; everyone else gets the default.
The user context
You describe the current user with a plain object of attributes:
user = {"user_id": "42","plan": "enterprise","country": "US",}client.enabled("advanced_analytics", user=user)
The keys are entirely up to you — they just have to match the attribute names you
target on in the dashboard. user_id (or id) is special: it's the input to
percentage rollouts.
Conditions
A condition tests one attribute with one operator:
planequalsenterprise
The operators are equals, not_equals, contains, ends_with, in_list,
gt, and lt. Each is defined with an example in
Rule operators.
How conditions combine: AND within a group, OR across groups
Targeting is built from rule groups. The logic is two levels:
- Within a group, all conditions must be true — they're ANDed.
- Across groups, any group matching is enough — they're ORed.
So this set of groups:
Group 1: country equals "US" AND device equals "mobile"Group 2: plan equals "enterprise"
means (country = US and device = mobile) or (plan = enterprise). A user matches if they satisfy either group in full.
This "OR of ANDs" shape (formally, disjunctive normal form) can express any combination of conditions. A group with no conditions never matches.
Segments: define an audience once
If you find yourself repeating the same conditions across many flags — "internal staff", "EU users" — define them once as a segment and attach the segment to a rule group. Segments are project-scoped and reusable; editing a segment updates every flag that references it. They're expanded inline when the config is published, so the SDK only ever sees plain conditions. See Rules & rollouts in the UI.
Targeting and rollouts together
A flag can have both rules and a rollout. Rules are checked first: a user who matches any rule gets the enabled value regardless of the rollout percentage. Only users who match no rule are then subject to the rollout. The full precedence is on the Evaluation order page.
Next
- Rule operators — every operator, with examples.
- Percentage rollouts — release to a fraction of users.