Docs

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

POST /v1/flags/evaluate Secret key
Evaluate all feature flags for a property and environment, applying targeting rules against the provided context.
ParameterTypeRequiredDescription
propertyId (body)stringProperty to evaluate flags for
environment (body)stringEnvironment name (e.g., production, staging)
context (body)objectEvaluation context for targeting rules
Response
{
  "flags": {
    "new-checkout": {
      "value": true,
      "type": "boolean"
    },
    "cta-color": {
      "value": "green",
      "type": "string"
    }
  }
}
Example
bash
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 FieldsTypeDescription
userIdstringYour user ID. Used for percentage rollouts and user targeting
visitorIdstringSessionSight visitor ID. Enables segment-based targeting
Custom fieldsstring \| number \| booleanAny 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:

FieldTypeDescription
valueboolean \| stringThe evaluated flag value
typestringEither "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

  1. All enabled flags for the property + environment are loaded
  2. For each flag, targeting rules are evaluated top-to-bottom against the context
  3. The first matching rule determines the flag’s value
  4. If no rules match, the flag’s default value is used
  5. If the flag is disabled in this environment, it’s omitted from the response