Skip to main content

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

The priority 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

When is_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

A 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 users
{
  "flag_id": "550e8400-e29b-41d4-a716-446655440000",
  "priority": 1,
  "rule_type": "boolean",
  "bucket_by": "user_id",
  "return_value": false
}
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.

Rule schema

FieldTypeDescription
idUUIDUnique rule identifier
flag_idUUIDThe flag this rule belongs to
priorityintegerEvaluation order — lower number is checked first
rule_typestringboolean, attribute, or percentage
attributestringContext field to match against (attribute rules only; nullable)
operatorstringComparison operator (attribute rules only; nullable)
value_jsonstringJSON-encoded target value (attribute rules only; nullable)
rollout_percentageintegerInclusion threshold 0–100 (percentage rules only; nullable)
bucket_bystringContext field used for hashing; defaults to user_id
return_valuebooleanValue returned when this rule matches
is_activebooleanWhen false, this rule is skipped during evaluation
created_atdatetimeISO 8601 creation timestamp
updated_atdatetimeISO 8601 last-updated timestamp

Endpoints

MethodEndpointPermissionDescription
POST/api/v1/projects/{project_id}/rulesrules.writeCreate a new rule
PATCH/api/v1/projects/{project_id}/rules/{id}rules.writeUpdate a rule
DELETE/api/v1/projects/{project_id}/rules/{id}rules.deleteDelete a rule

Required permissions

  • rules.read — Read rules (returned alongside flags via GET /api/v1/projects/{project_id}/flags/{id})
  • rules.write — Create and update rules
  • rules.delete — Delete rules

Build docs developers (and LLMs) love