Prerequisites
Prerequisites let you chain feature flags together so one flag depends on another being enabled first. Think of it as a dependency graph for your feature flags — flag B only activates if flag A is already ON.
What Are Prerequisite Flags?
A prerequisite is a flag that must evaluate to enabled (return a non-default value) before the dependent flag can activate. If any prerequisite is not met, the dependent flag returns its default value — regardless of its own enabled state, targeting rules, or percentage rollout configuration.
A flag can have multiple prerequisites. Allprerequisites must be met for the flag to evaluate normally — it's an AND relationship, not OR.
When to Use Prerequisites
- Infrastructure dependencies. A feature requires a new database migration or a third-party service that is gated behind its own ops toggle. The feature flag should depend on the infrastructure flag.
- Feature hierarchies. A premium analytics dashboard ("analytics v2") depends on the base analytics feature being enabled. If base analytics is off, analytics v2 should not activate.
- Platform migrations.You're moving from service A to service B. The new-service flag depends on the migration-complete ops flag. No one gets routed to the new service until the migration is confirmed.
- Compliance gates. A feature that handles PII requires a data-retention feature to be enabled. The prerequisite enforces the dependency at runtime.
How It Works
Prerequisites are checked early in the evaluation order — after the flag existence check, environment enabled check, and mutual exclusion, but before targeting rules. This means the engine doesn't waste cycles evaluating complex targeting rules for a flag whose prerequisites aren't met.
1. Flag exists? → No: NOT_FOUND
2. Flag environment enabled? → No: DISABLED
3. Mutual exclusion group? → Check group winner
4. Prerequisites met? → No: PREREQUISITE_FAILED (return default)
Yes: continue
5. Targeting rules match? → Yes: TARGETED
6. Percentage rollout? → In bucket: ROLLOUT / Out: FALLTHROUGH
7. None of the above → FALLTHROUGHExample: Infrastructure Dependency
Let's walk through a real scenario. Your team is introducing a new search backend powered by Elasticsearch. The rollout plan:
| Flag | Type | Role |
|---|---|---|
elasticsearch-migration-done | Ops toggle | Infrastructure gate — flipped ON after the migration is verified |
new-search-backend | Release toggle | Feature flag for the new search experience |
The new-search-backend flag has elasticsearch-migration-doneas a prerequisite. Here's what happens:
- Deploy the feature code. Both flags exist.
elasticsearch-migration-doneis OFF.new-search-backendis ON. Despite being ON,new-search-backendreturns its default value (old search path) because its prerequisite is not met. - Run the migration. Elasticsearch is populated and verified. The ops team flips
elasticsearch-migration-doneto ON. - Feature activates. Now that the prerequisite is met,
new-search-backendevaluates normally. If its targeting rules or rollout conditions match, users start seeing the new search experience. - Clean up. After a few weeks, the old search path is removed. The
elasticsearch-migration-doneflag is deprecated (it's permanently ON). Thenew-search-backendflag is removed from the codebase.
Configuring Prerequisites
Set prerequisites when creating or updating a flag. The prerequisites array contains flag keys that must be enabled first:
curl -X PATCH https://api.featuresignals.com/v1/projects/$PROJECT_ID/flags/$FLAG_ID \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"prerequisites": ["elasticsearch-migration-done"]
}'Best Practices
- Keep dependency chains short. Deep chains (A → B → C → D) are hard to reason about and debug. Prefer 1–2 levels of prerequisites.
- Use ops toggles as infrastructure gates.Separate infrastructure concerns from feature concerns. An ops toggle communicating "the migration is done" is clearer than a release toggle pulling double duty.
- Document the dependency. Add a description to the dependent flag explaining why it requires the prerequisite. This helps during cleanup.
- Avoid circular dependencies.The API rejects circular prerequisite chains at write time, but it's good practice to plan your dependency graph before creating flags.
- Clean up prerequisites when they're no longer needed. After the infrastructure migration is complete and the old code path is removed, update the dependent flag to remove the prerequisite.