Flags Endpoint
Get all flags
Section titled “Get all flags”Fetches the complete flag configuration for the authenticated environment. SDKs typically call this once during initialization and then keep the data in memory.
GET /flagsResponse
Section titled “Response”{ "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" } ]}Response fields
Section titled “Response fields”| Field | Type | Description |
|---|---|---|
environment | string | Environment identifier for the SDK key |
version | int | Configuration version (increments on any change) |
flags | FlagDto[] | All flags in this environment |
segments | SegmentDto[] | All segments (referenced by targeting rules) |
Get a single flag
Section titled “Get a single flag”Fetches the configuration for one flag by its key.
GET /flags/{key}Path parameters
Section titled “Path parameters”| Parameter | Type | Description |
|---|---|---|
key | string | The flag key |
Response
Section titled “Response”Returns a single FlagDto object (see data types below). Returns 404 if the flag does not exist.
Data types
Section titled “Data types”FlagDto
Section titled “FlagDto”| Field | Type | Description |
|---|---|---|
key | string | Unique flag identifier |
version | int | Flag configuration version |
type | string | "Boolean", "String", "Number", or "Json" |
enabled | bool | Whether the flag is on in this environment |
variations | VariationDto[] | All possible return values |
rules | RuleDto[] | Targeting rules, evaluated in priority order |
fallthrough | ServeConfigDto | What to serve when the flag is on and no rules match |
offVariation | string | Variation key returned when the flag is off |
prerequisites | PrerequisiteDto[] | Flags that must serve a given variation before this flag’s rules run. Empty when the flag has none |
clientSideVisible | bool | Whether client-side SDKs may receive this flag. The Cloudflare Workers SDK reads it to decide which flags bootstrapValues returns |
VariationDto
Section titled “VariationDto”| Field | Type | Description |
|---|---|---|
key | string | Variation identifier |
value | any | The value (boolean, string, number, or JSON object) |
PrerequisiteDto
Section titled “PrerequisiteDto”| Field | Type | Description |
|---|---|---|
prerequisiteFlagKey | string | Key of the flag this one depends on |
expectedVariationKey | string | Variation 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.
RuleDto
Section titled “RuleDto”| Field | Type | Description |
|---|---|---|
id | string | Rule identifier |
priority | int | Execution order (lower = evaluated first) |
conditionGroups | ConditionGroupDto[] | Groups of conditions. The rule matches when every group matches |
serve | ServeConfigDto | What to serve if the rule matches |
segmentKey | string? | Segment key if the rule targets a segment. Omitted otherwise |
ConditionGroupDto
Section titled “ConditionGroupDto”| Field | Type | Description |
|---|---|---|
operator | string | "And" (every condition in the group must match) or "Or" (any one is enough) |
conditions | ConditionDto[] | 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).
ConditionDto
Section titled “ConditionDto”| Field | Type | Description |
|---|---|---|
attribute | string | Context attribute to check (e.g., "user_id", "country") |
operator | string | Comparison operator (see below) |
values | string[] | Values to compare against |
negate | bool | Invert 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
ServeConfigDto
Section titled “ServeConfigDto”| Field | Type | Description |
|---|---|---|
type | string | "Fixed" or "Rollout" |
variation | string? | Variation key (when type is Fixed) |
bucketBy | string? | Attribute to hash for rollout bucketing |
salt | string? | Hash salt for consistent bucketing |
variations | WeightedVariationDto[]? | Weighted variations (when type is Rollout) |
WeightedVariationDto
Section titled “WeightedVariationDto”| Field | Type | Description |
|---|---|---|
key | string | Variation identifier |
weight | int | Percentage weight (0—100, must sum to 100 across all entries) |
SegmentDto
Section titled “SegmentDto”| Field | Type | Description |
|---|---|---|
key | string | Segment identifier |
version | int | Configuration version |
conditions | ConditionDto[] | Conditions that define segment membership |
conditionLogic | string | "And" or "Or" |
See also
Section titled “See also”- API Overview — authentication, rate limiting, and all endpoints
- Evaluate Endpoint — evaluate flags for user contexts
- Streaming Endpoint — receive real-time
flag.updatedevents - Targeting & Segments — understand rules, conditions, and segments
- SDK Overview — official SDKs fetch and cache flags automatically