Documentation Index
Fetch the complete documentation index at: https://docs.flagmint.com/llms.txt
Use this file to discover all available pages before exploring further.
Targeting Rules
Targeting rules let you control which users, organizations, or contexts receive a specific flag variation. Flagmint evaluates rules in priority order — the first rule that matches determines the result. If no rules match, the flag’s fallback value is returned.How Evaluation Works
When a flag is evaluated, Flagmint follows this sequence:- Flatten the context — The nested evaluation context (user, organization, custom) is flattened into a simple key-value map for attribute matching.
- Evaluate targeting rules in order — Rules are processed by
order_index, lowest first. The first matching rule wins. - Serve the matched rule’s result — A matched rule can return either a specific variation or a rollout result.
- Fall back — If no rules match, the flag’s fallback value is returned, coerced to the expected type.
Context Flattening
Before rules are evaluated, the nested evaluation context is flattened into a simple key-value map. This is how attribute paths in rules map to context values. Nested context:| Attribute | Value |
|---|---|
user.key | "user123" |
user.email | "alice@example.com" |
user.plan | "premium" |
organization.key | "org456" |
organization.country | "DE" |
organization.employeeCount | 50 |
custom.source | "mobile_app" |
user.plan or organization.country reference keys in this flattened map.
Rule Types
Flagmint supports two kinds of targeting rules: segment rules and custom rules. Each rule can optionally reference a variation (return a specific value) or a rollout (apply a rollout strategy).Segment Rules
Segment rules reference a predefined, reusable segment by ID. A segment contains its own set of conditions and a logical operator that determines how those conditions are combined.Segment Logical Operators
Segments support three logical operators that control how their conditions are combined:| Operator | Behavior | Description |
|---|---|---|
AND (default) | All conditions must match | User must match every condition |
OR | Any condition can match | User matches if at least one condition is true |
NOT | No conditions should match | User matches only if all conditions are false |
A segment with
force: true always matches regardless of its conditions. This is useful for testing or emergency overrides.Custom Rules
Custom rules define conditions inline on the targeting rule itself, without referencing a reusable segment. Like segments, custom rules support logical operators.AND, OR, and NOT logical operators as segments.
Operators
Conditions within segments and custom rules use operators to compare attribute values. All string comparisons are case-sensitive.| Operator | Description | Value Type | Example |
|---|---|---|---|
eq | Equals | Any | user.plan eq "premium" |
neq | Not equals | Any | user.plan neq "free" |
in | Is in list | Array | organization.country in ["DE", "FR", "NL"] |
nin | Not in list | Array | organization.country nin ["US", "CN"] |
gt | Greater than | Number | organization.employeeCount gt 10 |
lt | Less than | Number | organization.employeeCount lt 100 |
contains | String contains substring | String | user.email contains "@acme.com" |
not_contains | String does not contain substring | String | user.email not_contains "@test.com" |
startsWith | String starts with prefix | String | user.email startsWith "admin" |
endsWith | String ends with suffix | String | user.email endsWith "@flagmint.com" |
exists | Attribute is present | — | user.email exists |
not_exists | Attribute is absent | — | user.phone not_exists |
The
gt and lt operators coerce both sides to numbers. If either value cannot be parsed as a number, the condition does not match. The eq and neq operators include special handling for boolean and numeric string comparisons — for example, the string "true" will match a boolean true attribute.Rule Ordering and First-Match Wins
Targeting rules are evaluated inorder_index order (lowest first). The first rule that matches determines the result — subsequent rules are not evaluated.
This means rule order matters. Place more specific rules (like individual user overrides) before broader rules (like segment-based rollouts).
Example — override for a specific user before a general rollout:
eu_premium segment goes through the 50% rollout.
Rule Outcomes
When a rule matches, it must specify what to return. There are two options:Variation
Avariation_id returns a specific, predefined value. Variations are configured per flag and can be of any type (boolean, string, number, JSON).
Rollout
Arollout_id references a rollout configuration, which dynamically determines the value based on the user’s hash bucket. See Rollout Strategies below.
Rollout Strategies
Flagmint supports four rollout strategies: off, percentage, variant, and gradual.Off
Theoff strategy explicitly disables the rollout and returns the flag’s fallback value. Useful for pausing a rollout without deleting the configuration.
Percentage
Percentage rollouts are boolean-only. They determine whether a user is “in” (feature enabled) or “out” (fallback value). This is the simplest way to progressively enable a feature.- Users whose hash bucket falls below the percentage get
true - Users above the percentage get the flag’s fallback value
- A percentage of
100short-circuits and returnstruefor all targeted users
Variant
Variant rollouts split users into buckets, each receiving a different variation value. This is how you run A/B tests and multi-variant experiments. Variant rollouts work with any flag type (boolean, string, number, JSON).- The user’s stable key is combined with the salt
- A hash produces a deterministic bucket (0–99)
- The bucket maps to a variant based on cumulative weights
var_control, 50–79 get var_redesign, and 80–99 get var_minimal.
Variant rollouts reference
variation_id values, not raw values. The variation’s configured value and type are looked up and coerced to the flag’s expected type. If a variant references a missing variation, the fallback value is returned.Gradual
Gradual rollouts progressively increase the percentage of users who see a feature over time. Like percentage rollouts, they are boolean-only.| Day | Percentage |
|---|---|
| Day 0 (Apr 1) | 0% |
| Day 1 (Apr 2) | 10% |
| Day 2 (Apr 3) | 20% |
| … | … |
| Day 10 (Apr 11) | 100% |
| Day 11+ | 100% (capped at target) |
Gradual rollouts are computed based on elapsed time from
start_at. If start_at is in the future, the rollout returns 0% until that time. If start_at is omitted, the rollout starts immediately.target_percentagemust be between 0 and 100incrementmust be between 0 and 100interval_hoursmust be greater than 0start_at(if provided) must be a valid ISO 8601 date-time string
Consistent Hashing
All rollout strategies that involve user bucketing (percentage, variant, gradual) use consistent hashing to ensure stable assignment. The same user always receives the same rollout result as long as the salt remains unchanged. The stable key used for hashing is resolved in this order:user.key(fromkind: "user"orkind: "multi"with auserblock)user_id(legacy flat context)
Type Coercion
All flag values are coerced to the flag’s expected type before being returned. This ensures consistent types regardless of how the value is stored.| Expected Type | Coercion Behavior |
|---|---|
boolean | "true" → true, "false" → false, otherwise Boolean(value) |
number | Number(value), returns 0 if not a valid number |
string | String(value), returns "" for null/undefined |
json | Must be a non-null, non-array object, otherwise returns {} |
Examples
Feature gate for enterprise users
Gradual rollout to all users
A/B test for a segment with user override
Kill switch
A flag with no targeting rules, no rollout, andis_active = true acts as a simple on/off toggle. The base value is returned for every evaluation. Set is_active = false or use a rollout with strategy: "off" to disable it.
Email domain targeting
@acme.com email addresses see the feature.