Skip to content

Flag Version History and Restore

Someone changed a rule on Tuesday and checkout got worse on Wednesday. You don’t need to work out the old rule from the audit log. Every flag keeps a numbered version history per environment, and any version can be put back after a preview shows what would change.

History is on every plan. Restoring is on Pro, Business and Enterprise. Previews work everywhere, so a lower plan can see what a restore would do.

A version is a snapshot of one flag’s configuration in one environment. Each time a change alters what that environment serves, the flag gets the next number. Staging and production count separately, so production can be on version 14 while staging is on version 31.

A version holds:

  • on/off
  • the default variation
  • the strategy, a single variation or a percentage rollout
  • the targeting rules and their order
  • prerequisites

Each version also records who made the change, when, and the reason if one was given. It records where the change came from too: the dashboard, the API, the MCP server, a scheduled change, a rollout ramp, a flag trigger, or the system itself. A version made by a restore says which version it restored.

A save that changes nothing a user can see makes no version, so setting a flag to the value it already has leaves the history alone.

Segment contents. A rule that targets a segment stores a reference to it, so a restored rule uses the segment as it is today. If you restored version 9 and the “beta-testers” segment has gained 200 members since, those 200 are in the restored rule. If you need to know what a segment looked like, the audit log has its changes.

Flag-wide fields. The name, description, tags and the definitions of the variations belong to the flag and not to one environment. A restore never renames a flag or edits a variation. It only points the environment’s configuration back at variations that exist.

Open a flag and go to the History tab. Pick an environment to see its versions, newest first. Each row shows the version number, the time, the actor, the source and any reason. A version marked Baseline is where the kept history starts. It records the configuration as it was when tracking began or when older versions were pruned, so nothing earlier exists to compare it with.

Select a version to see its diff against the one before it, section by section, or pick any other version on the page with Compare with. The page’s environment is the one the history follows, so switching environments switches the list.

Anyone in the organization can read it, Viewers included.

Press Restore on a version’s row. The current version has none. A dialog shows a preview: which sections would change, with before and after, and any warnings. Nothing is saved until you confirm.

A restore is an ordinary change. It writes a new version on top of the current one, so the version you restored from stays in the list and you can undo a restore with another restore. Restoring a version identical to the current state does nothing and creates no version.

Restoring needs the Member role or above. Viewers can browse but not restore.

By default a restore brings back the rules, the default variation, the strategy and the prerequisites, and leaves the flag’s on/off state alone. Putting back last month’s rules shouldn’t silently turn on a flag that someone switched off this morning. The preview shows a STATE_NOT_RESTORED warning when the version’s on/off differs from the current one.

Tick Also restore on/off state to bring the state back as well.

A version can point at things that no longer exist. The restore checks all of them before it saves anything, and if any are missing it refuses the whole restore. It never half-applies. The error lists each missing item. Missing means:

  • a variation that was deleted, even if you recreated one with the same key
  • a segment that was deleted
  • a prerequisite flag that was archived or deleted
  • a prerequisite’s expected variation that was removed

Fix the gap, say by recreating the segment, and try again. The variations a version serves are matched by identity, so a new one with the old key doesn’t count. A prerequisite’s expected variation is matched by key.

A version can also be refused because today’s rules wouldn’t accept it, such as a rule set that would now create a prerequisite cycle. That comes back as a validation_failed error with a message starting FLAG_VERSION_NOT_RESTORABLE under fields.version.

A restore goes through the same gates as any other change.

  • In a critical environment, it needs a written reason, and the dashboard asks for the environment key as well if that setting is on.
  • During a change freeze, it is refused with 423 change_frozen. An Owner or Admin can break the freeze for that one restore with a reason, and the override is audited.
  • The preview warns about pending scheduled changes on the flag, and about a frozen or critical target, before you apply.

History follows your plan’s audit log retention: 7 days on Free, 30 on Team and Pro, 90 on Business and 365 on Enterprise.

Two adjustments apply on top of that. The latest 20 versions of each flag in each environment are always kept, up to 365 days, so a flag that rarely changes keeps its recent history on every plan. And a flag keeps at most 1,000 versions per environment, oldest dropped first, so a script toggling a flag in a loop can’t grow its history without limit.

Pruned versions can’t be restored.

The versions endpoints sit under a flag’s environment. {flag} and {env} take a key or an ID.

OperationEndpoint
List versionsGET /api/v1/orgs/{org}/projects/{project}/flags/{flag}/environments/{env}/versions
Get one versionGET …/versions/{number}
Diff two versionsGET …/versions/{number}/diff?against=
Preview or apply a restorePOST …/versions/{number}/restore

The list takes limit (1 to 100) and cursor, and returns items and next_cursor. The diff compares against the latest version unless you pass against. Any organization member can read these, Viewers included. An unknown or pruned version returns a 404 not_found whose message starts with FLAG_VERSION_NOT_FOUND.

The restore body takes dryRun, includeState and expectedETag. dryRun defaults to true, so a call with an empty body previews and changes nothing. Even a preview needs Member or above.

Terminal window
# Preview. Nothing is saved.
curl -X POST "https://api.featureflip.io/api/v1/orgs/acme/projects/checkout/flags/new-checkout/environments/production/versions/12/restore" \
-H "Authorization: Bearer $FEATUREFLIP_TOKEN" \
-H "Content-Type: application/json" \
-d '{"dryRun": true, "includeState": false}'

The response carries changed, changedSections, before, after, warnings and a targetETag. To apply, send the same request with dryRun set to false. Add expectedETag set to that targetETag so a stale preview is refused. If the environment changed since the preview, the call fails with 412 precondition_failed and you preview again. The precondition goes in the body, the same as the copy endpoint, and not in an If-Match header. A successful apply returns the newVersion. An apply that changes nothing returns changed: false and newVersion: null.

For a critical environment, send the reason in the X-Intent-Reason header, as with any other write. During a change freeze, an Owner or Admin can add X-Freeze-Override: true alongside the reason to break it for that one call. Request and response shapes are in the Management API Reference.

Errors you can expect:

A refused restore looks like this, with one message per missing item:

{
"error": "validation_failed",
"message": "One or more fields are invalid.",
"fields": {
"version": ["FLAG_VERSION_MISSING_REFERENCES: segment 'beta-testers' (3f2a9c1e-0000-0000-0000-000000000000)"]
}
}

The error field carries the category. Our codes start a message. For validation_failed that message sits under fields.version, because the top-level message is always the generic “One or more fields are invalid.”

Status and errorMessage starts withMeaning
400 bad_requestPLAN_FEATURE_UNAVAILABLEApplying needs Pro or above. Previews work on every plan
400 validation_failedFLAG_VERSION_MISSING_REFERENCES (in fields.version)A variation, segment or prerequisite the version uses is gone. Each missing item is named
400 validation_failedFLAG_VERSION_NOT_RESTORABLE (in fields.version)Today’s rules reject this version
404 not_foundFLAG_VERSION_NOT_FOUNDThe version doesn’t exist or has been pruned
412 precondition_failedThe expectedETag is stale
423 change_frozenA change freeze covers the environment

Two tools in the MCP server cover history.

  • list_flag_versions takes project, flag and environment, with optional limit and cursor. It is read-only.
  • restore_flag_version takes the same three plus version, and optional include_state, dry_run, etag, reason and freeze_override. It previews by default.

To apply a restore, call it first with dry_run: true, read the preview, then call it again with dry_run: false and etag set to the preview’s targetETag. A critical environment needs a reason. An Owner or Admin token can pass freeze_override: true with a reason to break a freeze for that one call.

CapabilityPlans
Version history, diffs and previewsEvery plan
Applying a restorePro, Business and Enterprise

On a plan without restore, the dialog shows the preview and explains that applying needs Pro or above.