POST /api/v1/evaluate, Togul checks the flag’s state and any active targeting rules, then returns a boolean value and a reason explaining why that value was returned.
Authentication
The evaluation endpoint requires anX-API-Key header with a server or sdk scoped API key. Keys are environment-scoped, so you must also provide the matching environment_key in the request body.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
flag_key | string | Yes | The key of the flag to evaluate |
environment_key | string | Yes | The key of the environment the flag belongs to |
context | object | No | Key-value pairs of strings used for rule targeting |
context object is a flat map of string keys to string values. Common fields include user_id, country, and plan, but you can include any attribute your targeting rules reference.
Evaluation order
Togul evaluates each flag using the following order:- Flag disabled — If the flag’s
enabledfield isfalse, Togul immediately returnsdefault_valuewith reasondisabled. No rules are checked. - Active rules in priority order — Active rules are checked from lowest
prioritynumber to highest. The first rule that matches the provided context determines the result. - Rule match — When a rule matches, Togul returns the rule’s
return_valuewith reasonrule_match. - No match — If no active rule matches, Togul returns
default_valuewith reasondefault.
Response schema
Every evaluation returns anEvaluateResponse object:
| Field | Type | Description |
|---|---|---|
flag_key | string | The key of the evaluated flag |
enabled | boolean | Whether the flag is currently enabled |
value | boolean | The resolved value for this evaluation |
reason | string | One of disabled, rule_match, or default |
Example responses
Quotas and regional constraints
Evaluation quota — Each evaluation request counts against your subscription’s monthly evaluation quota. If the quota is exhausted, the endpoint returns403 Forbidden.
Multi-region — In non-primary regions, the target environment must be explicitly enabled for that region before evaluation requests will succeed. Requests to an environment that is not enabled in the current region return 403 Forbidden.
Error reference
| Status | Cause |
|---|---|
401 Unauthorized | The X-API-Key header is missing, invalid, or the key has been revoked |
403 Forbidden | Monthly evaluation quota exceeded, or the environment is not enabled in the current region |
404 Not Found | The specified flag key or environment key does not exist |