Skip to main content

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 value
  • not_equals: Property does not equal value
  • contains: Property contains value (for arrays/strings)
  • not_contains: Property does not contain value
  • greater_than: Property is greater than value
  • less_than: Property is less than value
  • is_set: Property exists
  • is_not_set: Property does not exist

Best Practices

Cache feature flags to reduce database load. Refresh cache when flags are updated.
Use consistent hashing to ensure users always get the same variant.
Evaluate targeting rules based on user properties to determine flag values.

Events Endpoint

Identify Endpoint