Skip to content

Flags Endpoint

Fetches the complete flag configuration for the authenticated environment. SDKs typically call this once during initialization and then keep the data in memory.

GET /flags
{
"environment": "env-abc123",
"version": 42,
"flags": [
{
"key": "dark-mode",
"version": 3,
"type": "Boolean",
"enabled": true,
"variations": [
{ "key": "on", "value": true },
{ "key": "off", "value": false }
],
"rules": [
{
"id": "rule-abc123",
"priority": 0,
"conditionGroups": [
{
"operator": "Or",
"conditions": [
{ "attribute": "country", "operator": "In", "values": ["US", "CA"], "negate": false },
{ "attribute": "email", "operator": "EndsWith", "values": ["@example.com"], "negate": false }
]
},
{
"operator": "And",
"conditions": [
{ "attribute": "plan", "operator": "Equals", "values": ["pro"], "negate": false }
]
}
],
"serve": {
"type": "Fixed",
"variation": "on"
}
}
],
"fallthrough": {
"type": "Fixed",
"variation": "off"
},
"offVariation": "off",
"prerequisites": [
{ "prerequisiteFlagKey": "new-theme-engine", "expectedVariationKey": "on" }
],
"clientSideVisible": true
}
],
"segments": [
{
"key": "beta-testers",
"version": 1,
"conditions": [
{
"attribute": "plan",
"operator": "In",
"values": ["pro", "enterprise"],
"negate": false
}
],
"conditionLogic": "And"
}
]
}
FieldTypeDescription
environmentstringEnvironment identifier for the SDK key
versionintConfiguration version (increments on any change)
flagsFlagDto[]All flags in this environment
segmentsSegmentDto[]All segments (referenced by targeting rules)

Fetches the configuration for one flag by its key.

GET /flags/{key}
ParameterTypeDescription
keystringThe flag key

Returns a single FlagDto object (see data types below). Returns 404 if the flag does not exist.


FieldTypeDescription
keystringUnique flag identifier
versionintFlag configuration version
typestring"Boolean", "String", "Number", or "Json"
enabledboolWhether the flag is on in this environment
variationsVariationDto[]All possible return values
rulesRuleDto[]Targeting rules, evaluated in priority order
fallthroughServeConfigDtoWhat to serve when the flag is on and no rules match
offVariationstringVariation key returned when the flag is off
prerequisitesPrerequisiteDto[]Flags that must serve a given variation before this flag’s rules run. Empty when the flag has none
clientSideVisibleboolWhether client-side SDKs may receive this flag. The Cloudflare Workers SDK reads it to decide which flags bootstrapValues returns
FieldTypeDescription
keystringVariation identifier
valueanyThe value (boolean, string, number, or JSON object)
FieldTypeDescription
prerequisiteFlagKeystringKey of the flag this one depends on
expectedVariationKeystringVariation the prerequisite flag must serve

Prerequisites are checked in order, after enabled and before any rule, against the same context. If one of those flags serves anything other than its expectedVariationKey, this flag serves its offVariation and no rule runs. A prerequisite can have prerequisites of its own. See Prerequisites for how to set them up.

FieldTypeDescription
idstringRule identifier
priorityintExecution order (lower = evaluated first)
conditionGroupsConditionGroupDto[]Groups of conditions. The rule matches when every group matches
serveServeConfigDtoWhat to serve if the rule matches
segmentKeystring?Segment key if the rule targets a segment. Omitted otherwise
FieldTypeDescription
operatorstring"And" (every condition in the group must match) or "Or" (any one is enough)
conditionsConditionDto[]The conditions in this group

Groups are ANDed together, and each group’s operator applies only to the conditions inside it. The example rule needs plan to equal pro, plus at least one of the two conditions in the first group: a country of US or CA, or an email ending in @example.com. A rule with an empty conditionGroups list matches every context.

When segmentKey is set, the segment’s own conditions and conditionLogic decide the match, and the rule’s conditionGroups are not read. Segments keep that flat shape (see SegmentDto below).

FieldTypeDescription
attributestringContext attribute to check (e.g., "user_id", "country")
operatorstringComparison operator (see below)
valuesstring[]Values to compare against
negateboolInvert the condition result

Condition operators: Equals, NotEquals, Contains, NotContains, StartsWith, EndsWith, In, NotIn, MatchesRegex, GreaterThan, LessThan, GreaterThanOrEqual, LessThanOrEqual, Before, After, SemverEquals, SemverGreaterThan, SemverGreaterThanOrEqual, SemverLessThan, SemverLessThanOrEqual

FieldTypeDescription
typestring"Fixed" or "Rollout"
variationstring?Variation key (when type is Fixed)
bucketBystring?Attribute to hash for rollout bucketing
saltstring?Hash salt for consistent bucketing
variationsWeightedVariationDto[]?Weighted variations (when type is Rollout)
FieldTypeDescription
keystringVariation identifier
weightintPercentage weight (0—100, must sum to 100 across all entries)
FieldTypeDescription
keystringSegment identifier
versionintConfiguration version
conditionsConditionDto[]Conditions that define segment membership
conditionLogicstring"And" or "Or"