Prerequisite Flags
Prerequisites let you create flag dependencies — a flag will only evaluate to its configured value if all its prerequisite flags are also enabled and evaluating to true.
Use Case
You're building a multi-step feature rollout:
new-api-v2— The new API must be enabled firstnew-dashboard— Depends on the new APInew-dashboard-analytics— Depends on the new dashboard
If new-api-v2 is disabled, both new-dashboard and new-dashboard-analytics automatically return their default values.
Setting Prerequisites
Via API
curl -X POST http://localhost:8080/v1/projects/$PROJECT_ID/flags \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"key": "new-dashboard",
"name": "New Dashboard",
"flag_type": "boolean",
"default_value": false,
"prerequisites": ["new-api-v2"]
}'
Via Dashboard
- Open the flag detail page
- In the Prerequisites section, select flags to depend on
- Save
Evaluation Behavior
During evaluation, each prerequisite is recursively evaluated:
- For each
prerequisitekey in the flag'sprerequisitesarray:- Evaluate the prerequisite flag with the same context
- If the result is
NOT_FOUND,DISABLED, or booleanfalse→ fail
- If any prerequisite fails → return
PREREQUISITE_FAILEDwith the flag's default value - If all pass → continue normal evaluation
Recursive Dependencies
Prerequisites are evaluated recursively. If flag A depends on B, and B depends on C, then A is only active when both B and C are enabled and evaluating to true.
Circular Dependencies
Avoid circular dependencies (A → B → A). The evaluation engine has no explicit cycle detection and will hit the Go stack limit, returning an error.
Example
Flag: "premium-feature"
prerequisites: ["billing-enabled", "premium-plan"]
Evaluation for user "alice":
1. Evaluate "billing-enabled" → true ✓
2. Evaluate "premium-plan" → false ✗
3. Result: PREREQUISITE_FAILED, value: false (default)
API Response
{
"flag_key": "premium-feature",
"value": false,
"reason": "PREREQUISITE_FAILED"
}