Skip to content

Evaluate Endpoint

Evaluates a single flag for the provided user context and returns the resolved variation.

POST /evaluate
{
"flagKey": "dark-mode",
"context": {
"userId": "user-123",
"attributes": {
"plan": "pro",
"country": "US"
}
}
}
FieldTypeRequiredDescription
flagKeystringYesThe flag to evaluate
contextobjectYesUser context for targeting
context.userIdstringNoUnique user identifier (used for percentage rollouts)
context.attributesobjectNoCustom attributes for targeting rules
{
"key": "dark-mode",
"variation": "on",
"value": true,
"reason": "Fallthrough"
}
FieldTypeDescription
keystringThe flag key that was evaluated
variationstringKey of the variation that was served
valueanyThe resolved value (type depends on the flag’s type)
reasonstringWhy this variation was selected
ReasonDescription
RuleMatchA targeting rule matched the context
FallthroughFlag is on but no rules matched; the fallthrough variation was served
FlagDisabledFlag is off; the off variation was served
FlagNotFoundThe flag key does not exist
ErrorAn error occurred during evaluation
  • 401 Unauthorized — Invalid or missing SDK key.
  • 404 Not Found — The flag key does not exist in this environment.

When you call this endpoint, the server runs the following logic:

  1. Flag disabled — If enabled is false, return the offVariation.
  2. Rules — Evaluate each rule in priority order. If a rule’s conditions match the context, serve according to the rule’s serve config.
  3. Fallthrough — If no rules match, serve according to the fallthrough config.

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.