Flag
Defined in: schema.ts:248
A feature flag definition. This is the unit edited in drafts and frozen into snapshots.
Example
Section titled “Example”// Boolean flagconst darkMode: Flag = { key: "dark-mode", type: "boolean", enabled: true, defaultVariant: "off", variants: { on: { value: true }, off: { value: false } }, fallthrough: { variant: "off" },};
// String flag with targeting ruleconst theme: Flag = { key: "ui-theme", type: "string", enabled: true, defaultVariant: "default", variants: { default: { value: "light" }, dark: { value: "dark" } }, fallthrough: { variant: "default" }, rules: [{ id: "rule-1", conditions: [{ attribute: "plan", operator: "equals", value: "pro" }], serve: { variant: "dark" }, }],};Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
archivedAt? |
string | null |
ISO-8601 timestamp marking the flag as archived, or null/absent if active. Archived flags are excluded from compiled snapshots (see ./snapshot.compileDraft), so they leave SDK payloads and stop being evaluated — but they remain in the draft for history/restore. The evaluator never sees this field. |
schema.ts:280 |
createdAt? |
string |
ISO-8601 timestamp set when the flag is first created (stamped by ./core.FlagsCore.upsertFlag). | schema.ts:282 |
defaultVariant |
string |
Key into variants; served when disabled or when nothing else matches and no fallthrough applies. | schema.ts:255 |
description? |
string |
- | schema.ts:253 |
enabled |
boolean |
When false, evaluation short-circuits to the default variant (reason DISABLED). | schema.ts:252 |
fallthrough |
Serve |
Served when the flag is enabled and no override/rule matched. | schema.ts:267 |
key |
string |
- | schema.ts:249 |
lifecycle? |
LifecyclePolicy |
Optional expiry policy for stale-flag detection (see ./lifecycle.flagStaleness). Purely organizational — it only drives the dashboard’s “stale” badge / health score. It never enables/disables/archives a flag, is never read by the evaluator, and is not part of the compiled snapshot. | schema.ts:291 |
overrides? |
Override[] |
Exact targeting-key assignments, checked before rules. | schema.ts:263 |
owner? |
FlagOwner |
Who owns/maintains this flag (name, optional email/team). | schema.ts:273 |
prerequisites? |
Prerequisite[] |
Other flags that must resolve to a required variant for this flag to be live. Checked right after the enabled gate, before overrides/rules. Acyclic. | schema.ts:261 |
rules? |
Rule[] |
Ordered targeting rules; first match wins. | schema.ts:265 |
salt? |
string |
Optional per-flag salt that perturbs split bucketing independently of the key. | schema.ts:269 |
schedule? |
FlagSchedule |
Optional active window (behavioral — enforced by the evaluator). Outside it the flag serves its default variant: reason SCHEDULED before FlagSchedule.enableAt, reason EXPIRED after FlagSchedule.disableAt. Unlike Flag.lifecycle (advisory), this actually changes what’s served — checked against the current time at each evaluation, so it flips live without a re-publish. Does not modify Flag.enabled or archive the flag. |
schema.ts:301 |
tags? |
string[] |
Free-form organizational labels (e.g. “beta”, “checkout”, “permanent”). | schema.ts:271 |
tests? |
FlagTest[] |
Pinned example evaluations used to gate publishing (see ./hooks/test-gate.createTestGate). Each case pairs a context with an expected variant and/or value; on publish, the gate re-evaluates the draft and denies if any case regresses. Dev/CI metadata only — stripped from compiled snapshots (never shipped to runtimes, never seen by the evaluator at request time). |
schema.ts:310 |
type |
FlagType |
- | schema.ts:250 |
updatedAt? |
string |
ISO-8601 timestamp updated on every change (stamped by ./core.FlagsCore.upsertFlag). | schema.ts:284 |
variants |
Record<string, Variant> |
- | schema.ts:256 |