What is a rule?
A rule is a conditional expression attached to a flag. When a flag is evaluated, its active rules are checked in priority order. The first rule whose condition matches the evaluation context determines the returned value. Each rule has:- A type that determines how the condition is evaluated
- A priority that controls the order rules are checked
- A return_value (boolean) that is returned when the rule matches
- An is_active toggle that lets you disable individual rules without deleting them
Priority
Thepriority field is an integer where lower numbers are checked first. If two rules have priority 1 and 2, the rule with priority 1 is evaluated first. The first matching rule wins — subsequent rules are not evaluated.
Set priorities intentionally. A broad rule with a low priority number can shadow more specific rules that have higher priority numbers.
is_active
Whenis_active is false, the rule is skipped entirely during evaluation. Inactive rules do not affect the result. Use this to temporarily disable a rule without deleting it.
Rule types
- boolean
- attribute
- percentage
A Because this rule always matches, place it at the lowest priority number (highest precedence) only when you intend it to override all other rules. Give it a higher priority number (lower precedence) if you want other rules to be evaluated first.
boolean rule always matches, regardless of the evaluation context. It is the simplest rule type and is commonly used as a kill switch — when you need to force a flag to return a specific value for all users.Required fields: flag_id, priority, rule_type, return_valueExample: force a flag off for all usersRule schema
| Field | Type | Description |
|---|---|---|
id | UUID | Unique rule identifier |
flag_id | UUID | The flag this rule belongs to |
priority | integer | Evaluation order — lower number is checked first |
rule_type | string | boolean, attribute, or percentage |
attribute | string | Context field to match against (attribute rules only; nullable) |
operator | string | Comparison operator (attribute rules only; nullable) |
value_json | string | JSON-encoded target value (attribute rules only; nullable) |
rollout_percentage | integer | Inclusion threshold 0–100 (percentage rules only; nullable) |
bucket_by | string | Context field used for hashing; defaults to user_id |
return_value | boolean | Value returned when this rule matches |
is_active | boolean | When false, this rule is skipped during evaluation |
created_at | datetime | ISO 8601 creation timestamp |
updated_at | datetime | ISO 8601 last-updated timestamp |
Endpoints
| Method | Endpoint | Permission | Description |
|---|---|---|---|
POST | /api/v1/projects/{project_id}/rules | rules.write | Create a new rule |
PATCH | /api/v1/projects/{project_id}/rules/{id} | rules.write | Update a rule |
DELETE | /api/v1/projects/{project_id}/rules/{id} | rules.delete | Delete a rule |
Required permissions
rules.read— Read rules (returned alongside flags viaGET /api/v1/projects/{project_id}/flags/{id})rules.write— Create and update rulesrules.delete— Delete rules