/Docs
IntroductionHow FeatureGate worksQuickstart
OrganisationsProjectsEnvironments
OverviewTypes and valuesConfigure across environmentsTargeting rulesPercentage rolloutsDesign evaluation contextLifecycle and intentTags and discovery
Choose an evaluation approachEvaluation credentialsNode.js SDKEvaluate over HTTPEvaluate in browsersSnapshots and configuration freshnessErrors and fallbacksTest flags locallyProduction integration checklist
Run a controlled rolloutKill switchesProject insightsActivity and audit historyReview and clean up flagsEnvironment readinessTroubleshooting and limits
Members, roles, and permissionsInvite and manage a teamOrganisation settings and operational defaultsProject lifecycle and transferPlans, billing, and team organisationsOrganisation closure and reactivationAccount settings and security
Management API overviewPreviewProvision flags through automationPreviewRotate runtime keys through automationPreviewAudit project changes through automationPreview
DocsAPI Reference

Automation/Rotate runtime keys through automation

Get access
/Docs
Get access
  1. Docs
  2. Automation
  3. Rotate runtime keys through automation

Rotate runtime keys through automation

Preview

Replace an environment key without avoidable evaluation downtime.

MarkdownFeedback
PreviousProvision flags through automationNextAudit project changes through automation

On this page

Required scopesInventory the old keyCreate the replacementDeploy with overlapRevoke the old keyRecover from failureRotation ownership

Runtime-key rotation follows create, store, deploy, verify, then revoke. The Management API can create and revoke server runtime keys but never returns an existing raw secret.

Use overlap for planned rotation. Revoke immediately only when suspected compromise outweighs availability.

Required scopes

Use management:runtime-keys:read to inventory metadata and management:runtime-keys:write to create or revoke. Discovery can also require project and environment read scopes.

The management key and new runtime key are different secrets. Keep both out of command output and logs.

Inventory the old key

Resolve the project ID and environment key through Management reads. List runtime-key metadata and identify the old key by stable ID, name, prefix, scopes, and revocation state.

Do not select a key only by array position or display name. Confirm it belongs to the intended project environment before rotation.

Create the replacement

Create a replacement with the minimum scopes needed by the caller:

curl -X POST \
  "https://api.featuregate.dev/v1/projects/$FEATUREGATE_PROJECT_ID/environments/production/runtime-keys" \
  -H "Authorization: Bearer $FEATUREGATE_MANAGEMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "checkout-api rotation 2026-07",
    "scopes": ["runtime:snapshot"]
  }'

The response contains rawKey once. Write it directly to the deployment secret store. Avoid shell arguments, temporary files, CI annotations, and JSON debug output that could retain it.

If secure direct transfer is unavailable, stop. Do not print the secret for later manual copying from logs.

Deploy with overlap

Deploy or reload consumers while the old key remains active. Account for rolling deployments, queued jobs, warm serverless instances, and processes that refresh snapshots on different schedules.

Verify the replacement through the actual integration path:

  • Direct callers receive a successful evaluation.
  • Snapshot clients complete a successful refresh.
  • The response binds to the expected environment.
  • Authentication errors do not increase.
  • Application defaults are not activated unexpectedly.

Observe an overlap window long enough for the deployment topology, not an arbitrary fixed delay.

Revoke the old key

Call the owner route for the exact old key ID:

curl -X POST \
  "https://api.featuregate.dev/v1/projects/$FEATUREGATE_PROJECT_ID/environments/production/runtime-keys/$FEATUREGATE_OLD_KEY_ID/revoke" \
  -H "Authorization: Bearer $FEATUREGATE_MANAGEMENT_KEY"

Confirm revoked metadata and project activity. Test that current callers continue through the new key.

Revocation blocks future API requests. It cannot erase a snapshot already held in process memory.

Recover from failure

FailureRecovery
New secret lost before deploymentCreate another key and revoke the unused record
Verification failsKeep the old key active and inspect scope, binding, and deployment
Old key revoked too earlyDeploy a newly created key and accept caller-default behaviour during recovery
Suspected compromiseRevoke immediately, rotate management access if exposed, and review activity
Snapshot process still uses old stateRefresh successfully with the replacement or restart it

Do not attempt to recover a one-time raw secret from list or audit endpoints.

Rotation ownership

Document who owns the deployment, verification, revocation, and incident response. Use separate keys for independently deployed callers so one rotation does not coordinate unrelated systems.

Related pages: Evaluation credentials, Activity and audit history, and Errors and fallbacks.