Evaluate Endpoint
Evaluate a flag
Section titled “Evaluate a flag”Evaluates a single flag for the provided user context and returns the resolved variation.
POST /evaluateRequest body
Section titled “Request body”{ "flagKey": "dark-mode", "context": { "userId": "user-123", "attributes": { "plan": "pro", "country": "US" } }}| Field | Type | Required | Description |
|---|---|---|---|
flagKey | string | Yes | The flag to evaluate |
context | object | Yes | User context for targeting |
context.userId | string | No | Unique user identifier (used for percentage rollouts) |
context.attributes | object | No | Custom attributes for targeting rules |
Response
Section titled “Response”{ "key": "dark-mode", "variation": "on", "value": true, "reason": "Fallthrough"}| Field | Type | Description |
|---|---|---|
key | string | The flag key that was evaluated |
variation | string | Key of the variation that was served |
value | any | The resolved value (type depends on the flag’s type) |
reason | string | Why this variation was selected |
Evaluation reasons
Section titled “Evaluation reasons”| Reason | Description |
|---|---|
RuleMatch | A targeting rule matched the context |
Fallthrough | Flag is on but no rules matched; the fallthrough variation was served |
FlagDisabled | Flag is off; the off variation was served |
FlagNotFound | The flag key does not exist |
Error | An error occurred during evaluation |
Errors
Section titled “Errors”401 Unauthorized— Invalid or missing SDK key.404 Not Found— The flag key does not exist in this environment.
Evaluation logic
Section titled “Evaluation logic”When you call this endpoint, the server runs the following logic:
- Flag disabled — If
enabledisfalse, return theoffVariation. - Rules — Evaluate each rule in priority order. If a rule’s conditions match the context, serve according to the rule’s
serveconfig. - Fallthrough — If no rules match, serve according to the
fallthroughconfig.
For Rollout serve configs, the user is bucketed into a variation based on a hash of the bucketBy attribute (defaulting to userId) and the configured salt.
See also
Section titled “See also”- Targeting & Segments — how evaluation context and targeting rules work
- Rollout Strategies — how percentage rollouts determine variations
- Flags Endpoint — fetch flag configurations and data types
- API Overview — authentication, rate limiting, and all endpoints
- SDK Overview — use an official SDK for automatic evaluation