GET /api/feature-flags
Fetches feature flags and experiments for a user. This endpoint is called by the SDK to get the current state of feature flags.Request
Headers
string
required
Your API key
Query Parameters
string
The user’s ID (if user is identified)
string
The anonymous ID
string
JSON-encoded user properties for targeting (optional)
Example Request
Response
Success Response
object
required
Object mapping flag keys to flag objects
object
Object mapping experiment keys to experiment objects
string
required
ISO 8601 timestamp
Flag Object
string
required
Flag key
boolean
required
Whether the flag is enabled
string
Assigned variant (for experiments)
boolean | string | number | object
Flag value
number
Rollout percentage (0-100)
Experiment Object
string
required
Experiment key
string
required
Experiment name
Array<{ key: string; value: any }>
required
Available variants
string
Assigned variant for this user
'draft' | 'running' | 'paused' | 'completed'
required
Experiment status
Example Response
Feature Flag Evaluation
Consistent Hashing
For percentage-based rollouts, use consistent hashing to ensure the same user always gets the same variant:Targeting Rules
Support targeting based on user properties:equals: Property equals valuenot_equals: Property does not equal valuecontains: Property contains value (for arrays/strings)not_contains: Property does not contain valuegreater_than: Property is greater than valueless_than: Property is less than valueis_set: Property existsis_not_set: Property does not exist
Best Practices
Caching
Caching
Cache feature flags to reduce database load. Refresh cache when flags are updated.
Consistent Assignment
Consistent Assignment
Use consistent hashing to ensure users always get the same variant.
Targeting
Targeting
Evaluate targeting rules based on user properties to determine flag values.
