Flags

Flags

Create and manage typed feature flags and per-environment targeting

Overview

The Flags resource manages typed feature flags within a project. A flag has a stable key, a display name, an optional description, a type, and one or more named variations. Supported flag types are boolean, string, number, and json.

Creating a flag also creates a default disabled configuration in every environment. Use the flag endpoints to manage the flag definition and its variations. Use the targeting endpoint separately to replace the configuration for one environment, including its enabled state, fallback variations, and ordered targeting rules.

Note:

Targeting is configured per environment. Updating a flag's metadata or variations with PATCH does not replace its targeting configuration; use the dedicated targeting endpoint for that operation.

Schema

The following fields are accepted by the flag definition and targeting requests or returned by the flag endpoints. A variation is referenced by its unique key; the complete variation object is defined by the API's variation schema.

FieldTypeRequiredDescription
keystringCreate: yes; response: yesStable flag key referenced by clients, such as new-checkout.
namestringCreate: yes; update: optional; response: yesFlag name. The API accepts 1–120 characters.
descriptionstringCreate: optional; update: optional; response: nullableAdditional flag description. The API accepts up to 500 characters.
typeboolean | string | number | jsonCreate: yes; response: yesType of value the flag serves.
variationsarray of variation objectsCreate: yes; update: optional; response: yesNamed values the flag can serve. The array must contain at least one variation, and variation keys must be unique.
idstringResponse: yesFlag identifier.
projectIdstringResponse: yesIdentifier of the project that owns the flag.
configsarray of environment configuration objectsResponse: yesPer-environment configurations embedded in the flag response.
createdAtstringResponse: yesFlag creation timestamp.
updatedAtstringResponse: yesTime the flag was last updated.
environmentstringTargeting request: yesEnvironment key whose targeting configuration is replaced.
environmentKeystringConfiguration response: yesEnvironment key for a returned configuration.
enabledbooleanTargeting request and configuration response: yesWhether the flag is enabled in the environment.
defaultVariationKeystringTargeting request and configuration response: yesVariation key served when targeting rules fall through.
offVariationKeystringTargeting request and configuration response: yesVariation key served when the flag is disabled.
rulesarray of targeting rule objectsTargeting request and configuration response: yesOrdered targeting rules for the environment.

Endpoints

All paths use the project identifier in {projectId}. Flag keys are supplied in {flagKey} for operations on an existing flag.

MethodPathDescription
POST/v1/projects/{projectId}/flagsCreate a typed flag with named variations. A default disabled configuration is created in every environment.
GET/v1/projects/{projectId}/flagsList the flags for a project.
GET/v1/projects/{projectId}/flags/{flagKey}Fetch one flag by key within a project, including its per-environment configurations.
PATCH/v1/projects/{projectId}/flags/{flagKey}Update a flag's name, description, or variations. Targeting is updated separately.
DELETE/v1/projects/{projectId}/flags/{flagKey}Delete a flag by key.
PUT/v1/projects/{projectId}/flags/{flagKey}/targetingReplace the enabled state, default and off variation keys, and ordered targeting rules for the flag in one environment.