Targeting & Segments
Targeting lets you deliver different flag values to different users based on their attributes. Segments are reusable groups of targeting conditions.
Create and manage segments in the Flag Engine →
Targeting Rules
| Component | Description |
|---|---|
| Conditions | Attribute-based filters (e.g., country equals "US") |
| Segment Keys | Reference to reusable segments |
| Value | The value to return when the rule matches |
| Percentage | Percentage of matching users to target (basis points: 0–10000) |
| Priority | Evaluation order (lower = evaluated first) |
| Match Type | all (AND logic) or any (OR logic) |
Operators
| Operator | Key | Description |
|---|---|---|
| Equals | eq | Exact match |
| Not Equals | neq | Inverse match |
| Contains | contains | Substring match |
| Starts With | startsWith | Prefix match |
| Ends With | endsWith | Suffix match |
| In | in | Value is in the list |
| Not In | notIn | Value is not in the list |
| Greater Than | gt | Numeric comparison |
| Less Than | lt | Numeric comparison |
| Regex | regex | Regular expression match |
| Exists | exists | Attribute is present |
Example: Target Beta Users in the US
json
{
"rules": [
{
"priority": 1,
"description": "Beta users in US",
"match_type": "all",
"conditions": [
{"attribute": "country", "operator": "eq", "values": ["US"]},
{"attribute": "beta", "operator": "eq", "values": ["true"]}
],
"value": true,
"percentage": 10000
}
]
}Segments
Segments are reusable groups of conditions that can be referenced by multiple flags.
bash
curl -X POST https://api.featuresignals.com/v1/projects/$PROJECT_ID/segments \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"key": "enterprise-users",
"name": "Enterprise Users",
"description": "Users on enterprise plan",
"match_type": "all",
"rules": [
{"attribute": "plan", "operator": "eq", "values": ["enterprise"]}
]
}'Evaluation Order
- Sort rules by
priority(lowest first) - For each rule: check segments, then conditions
- If match and
percentage == 10000: return rule value (TARGETED) - If match and
percentage > 0: check user's hash bucket (ROLLOUTif in range) - If no rule matches: check default percentage rollout
- If nothing matches: return flag's default value (
FALLTHROUGH)