Evaluate
Evaluate feature flags for a given context
Last updated:
This endpoint is what the Feature Flags SDK calls under the hood. You can call it directly if you’re not using the SDK or need to evaluate flags from a language without an SDK.
Evaluate Flags
/v1/flags/evaluate Secret key| Parameter | Type | Required | Description |
|---|---|---|---|
| propertyId (body) | string | ✓ | Property to evaluate flags for |
| environment (body) | string | ✓ | Environment name (e.g., production, staging) |
| context (body) | object | Evaluation context for targeting rules |
{
"flags": {
"new-checkout": {
"value": true,
"type": "boolean"
},
"cta-color": {
"value": "green",
"type": "string"
}
}
}curl -X POST "https://api.sessionsight.com/v1/flags/evaluate" \
-H "x-api-key: YOUR_SECRET_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"propertyId": "",
"environment": "",
"context": ""
}'Context Object
The context object is used to evaluate targeting rules. Any key-value pairs can be included. They’re matched against the conditions you configure in the dashboard.
| Common Fields | Type | Description |
|---|---|---|
userId | string | Your user ID. Used for percentage rollouts and user targeting |
visitorId | string | SessionSight visitor ID. Enables segment-based targeting |
| Custom fields | string \| number \| boolean | Any additional properties for targeting rules |
Never send PII (emails, phone numbers, addresses, etc.) in the context object. Use opaque identifiers like user IDs instead.
Response Format
The response contains a flags object where each key is a flag key and the value includes:
| Field | Type | Description |
|---|---|---|
value | boolean \| string | The evaluated flag value |
type | string | Either "boolean" or "string" |
Only flags that are enabled in the requested environment are returned. Disabled flags are omitted, so your SDK or code should use default values for missing keys.
How Evaluation Works
- All enabled flags for the property + environment are loaded
- For each flag, targeting rules are evaluated top-to-bottom against the context
- The first matching rule determines the flag’s value
- If no rules match, the flag’s default value is used
- If the flag is disabled in this environment, it’s omitted from the response