Platform
Flags
Feature flags support four types — boolean, string, number, and JSON — with per-environment configuration.
Overview
Feature flags are the core primitive in Switchflag. A flag has a key, a type, a default value, and per-environment configuration (enabled state + targeting rules).
Creating a flag
| Field | Description | Validation |
|---|---|---|
| Name | Display name | 1-100 characters |
| Key | Code identifier | Lowercase, numbers, hyphens. Unique per project. |
| Type | Value type | boolean, string, number, json |
| Default Value | Fallback value | Must be valid for the type |
| Description | Optional notes | Up to 500 characters |
Flag types
| Type | Default Value | SDK Type | Use Case |
|---|---|---|---|
| boolean | true or false | getFlag<boolean> | On/off toggles |
| string | Any string | getFlag<string> | A/B variants, theme names |
| number | Any number | getFlag<number> | Limits, thresholds |
| json | Valid JSON | getFlag<{ ... }> | Complex configs |
Flag key
The key is what you use in code:
const result = await client.getFlag<boolean>('new-checkout-flow', ctx)Keys must be:
- Lowercase letters, numbers, and hyphens only (
^[a-z0-9-]+$) - Unique within the project
- 1-100 characters
Default value
The default value is the fallback when:
- The flag is enabled but no targeting rules match (non-boolean types)
- The flag has no environment configuration
For boolean flags, when the flag is enabled and no rules match, the value is true (not the default value). When disabled, boolean flags return false.
Per-environment state
When a flag is first created, it's disabled in all environments. You control:
- Enabled/disabled — toggle independently per environment
- Targeting rules — different rules per environment
See Targeting Rules for configuring rules.