Evaluate flags for a context, as the environment's SDKs would
const url = 'https://example.com/api/v1/projects/example/environments/example/evaluate';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"context":{"units":{"additionalProperty":"example"},"attributes":{}},"flags":["example"],"draft":{"flag":"example","configuration":{"on":true,"off_variation":"example","fallthrough":"example","prerequisites":[{"flag":"example","variation":"example"}],"overrides":[{"unit_type":"example","unit_id":"example","variation":"example","note":"example"}],"rules":[{"id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","description":"example","conditions":[{"kind":"example","attribute":"example","op":"example","value":"example","segment":"example","flag":"example","variation":"example"}],"serve":{"kind":"example","variation":"example","experiment":"example","unit_type":"example","percentage":1,"salt":"example"}}]}}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/v1/projects/example/environments/example/evaluate \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "context": { "units": { "additionalProperty": "example" }, "attributes": {} }, "flags": [ "example" ], "draft": { "flag": "example", "configuration": { "on": true, "off_variation": "example", "fallthrough": "example", "prerequisites": [ { "flag": "example", "variation": "example" } ], "overrides": [ { "unit_type": "example", "unit_id": "example", "variation": "example", "note": "example" } ], "rules": [ { "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "description": "example", "conditions": [ { "kind": "example", "attribute": "example", "op": "example", "value": "example", "segment": "example", "flag": "example", "variation": "example" } ], "serve": { "kind": "example", "variation": "example", "experiment": "example", "unit_type": "example", "percentage": 1, "salt": "example" } } ] } } }'Evaluates the environment’s saved configuration for a context, with
the full reason of each result: the served value and variation,
the reason, the rule that served, the error code, and for a rollout
the unit’s bucket and the rollout’s salt. It evaluates every flag
that is not archived, or only the flags named, where a key the
ruleset does not hold answers error with flag_not_found.
A draft evaluates one flag’s unsaved configuration in place of
its saved one, every other flag seeing it as SDKs would once it is
saved. It is validated as replacing the configuration would
validate it (invalid_configuration, its pointers under
/draft/configuration), with no If-Match, and is never stored:
nothing changes and nothing is recorded. A context whose unit ID is
over 256 bytes, or whose attribute holds a string over 1,024 bytes,
is invalid_context. A flag named twice is evaluated once.
Evaluating records no exposure.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The project’s key.
The environment’s key.
Request Bodyrequired
Section titled “Request Bodyrequired”object
What flags are evaluated for: unit IDs by unit type, each of at most 256 bytes, an empty one counting as absent; and attribute values by key, as SDKs send them. A context with no units is valid: rules on attributes apply, while rollouts and overrides are skipped.
object
object
object
The keys of the flags to evaluate; absent for every flag that is not archived.
An unsaved configuration of one flag in the environment, evaluated in place of the saved one and never stored.
object
The key of a flag of the project that is not archived.
object
object
The key of another flag of the project, not archived.
One of that flag’s variations.
object
A unit type the project declares.
The unit’s ID, of 1 to 256 bytes, unique per unit type in the configuration.
At most 200 characters once trimmed; blank is none.
object
The rule of the current configuration this one is; omitted for a new rule.
One comparison inside a rule or a segment. An attribute condition
names an attribute or unit type, an operator (op) and a value
(none for exists, not_exists and is_empty); in_segment and
not_in_segment name a segment; prerequisite names a flag and
one of its variations. A segment holds attribute conditions only.
object
attribute, in_segment, not_in_segment or prerequisite.
A string, number, boolean or list, as the operator and the attribute’s type need; null is no value.
What a matching rule serves. variation serves variation;
rollout serves variation to percentage of the units of
unit_type, in basis points (0 to 10,000), the others continuing to
the next rule. A rollout’s salt is given by the server and changes
only through regenerating it, so a write omits it or sends it
unchanged. experiment serves the experiment experiment of the
flag, which assigns units to variations by its own weights; a rule
serves a draft or running experiment of its flag
(unknown_experiment, experiment_of_another_flag and
experiment_not_servable otherwise), and several rules may serve
the same one; a rule that served the experiment already keeps
serving it whatever its status, so stopping or archiving it never
blocks an edit of the other rules. While the experiment is a draft,
stopped or archived its rules are left out of the ruleset SDKs
receive; while it runs they carry its unit type, salts, traffic
allocation and weights.
object
variation, rollout or experiment.
The key of the experiment served, for kind experiment.
Example generated
{ "context": { "units": { "additionalProperty": "example" }, "attributes": {} }, "flags": [ "example" ], "draft": { "flag": "example", "configuration": { "on": true, "off_variation": "example", "fallthrough": "example", "prerequisites": [ { "flag": "example", "variation": "example" } ], "overrides": [ { "unit_type": "example", "unit_id": "example", "variation": "example", "note": "example" } ], "rules": [ { "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "description": "example", "conditions": [ { "kind": "example", "attribute": "example", "op": "example", "value": "example", "segment": "example", "flag": "example", "variation": "example" } ], "serve": { "kind": "example", "variation": "example", "experiment": "example", "unit_type": "example", "percentage": 1, "salt": "example" } } ] } }}Responses
Section titled “Responses”The result of every flag evaluated, by flag key.
object
The version of the environment’s saved ruleset, which a draft does not move.
The result of each flag evaluated, by flag key.
object
What one flag serves the context, and why, as the reference
evaluator computes it. type and automatic_exposure are absent
only for flag_not_found.
object
A JSON value of the flag’s type, never null, of at most 64 KiB once
compact (too_long), nesting arrays and objects at most 32 deep
(too_deep).
The served variation’s key; absent for an error.
off, override, rule, rollout, experiment, fallthrough, prerequisite_failed or error.
The rule that served, for reasons rule, rollout and experiment.
The running experiment a result comes from, as an SDK’s exposure
carries it: present with reason experiment, and with reason
override when the unit, without the override, would be in a
running experiment. Recomputing either bucket takes the salt and
the unit: murmur3_32(salt + "." + unit_id) % 10000.
object
The served variation; the override’s when an override decided the result.
The unit is included when it is below the traffic allocation.
Picks the variation by the weights’ cumulative ranges.
Whether an override influenced the result; analysis leaves such exposures out.
The key of the flag-level prerequisite that failed, for reason prerequisite_failed.
The unit’s bucket, 0 to 9,999, for reason rollout; the unit is in the rollout because its bucket is below the percentage.
The salt of the rollout that served, for reason rollout.
Why the result is an error: flag_not_found, prerequisite_cycle or inconsistent_ruleset.
Whether an override decided the result, directly or through a prerequisite.
Example
{ "flags": { "additionalProperty": { "type": "boolean" } }}invalid_request: a parameter that is malformed or out of its range, such as a cursor this API did not return.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which clients branch on.
An English explanation for humans; never what a client branches on.
Seconds to wait before retrying, for a rate limit.
The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.
The version the entity has now, for version_mismatch.
What still names what the write would remove or hide, for in_use.
object
What names it, such as flag, segment or experiment.
The key of the environment it is named in; null when it is named in every environment.
The slug of the auth provider to sign in through instead, for sso_required.
What keeps an auth provider from being deleted, disabled or edited, for provider_in_use, such as identities, enforced domains or only way in (the only enabled provider while local login is disabled).
Why a system the server asked did not answer as needed, for provider_unreachable; for sink_not_ready the failure class of the target’s check, such as connect or status.
The HTTP status the target answered, for sink_not_ready, when it answered.
The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.
object
JSON Pointer into the request body.
The values of the rule broken, such as the bounds of a length, for a client to explain the violation in its own language.
object
Example generated
{ "type": "example", "title": "example", "status": 1, "code": "example", "detail": "example", "request_id": "example", "retry_after": 1, "permission": "example", "current_version": 1, "references": [ { "kind": "example", "key": "example", "environment": "example" } ], "provider": "example", "used_by": [ "example" ], "failure": "example", "failure_status": 1, "failure_code": "example", "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}No credential, or one that is not accepted: unauthenticated without
a credential (a session cookie the server did not issue counts as
none); invalid_token, token_revoked or token_expired for an API
token, with a WWW-Authenticate header naming the code;
session_expired for a session that has ended, whose cookie is
cleared; invalid_credentials for a sign-in.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which clients branch on.
An English explanation for humans; never what a client branches on.
Seconds to wait before retrying, for a rate limit.
The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.
The version the entity has now, for version_mismatch.
What still names what the write would remove or hide, for in_use.
object
What names it, such as flag, segment or experiment.
The key of the environment it is named in; null when it is named in every environment.
The slug of the auth provider to sign in through instead, for sso_required.
What keeps an auth provider from being deleted, disabled or edited, for provider_in_use, such as identities, enforced domains or only way in (the only enabled provider while local login is disabled).
Why a system the server asked did not answer as needed, for provider_unreachable; for sink_not_ready the failure class of the target’s check, such as connect or status.
The HTTP status the target answered, for sink_not_ready, when it answered.
The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.
object
JSON Pointer into the request body.
The values of the rule broken, such as the bounds of a length, for a client to explain the violation in its own language.
object
Example generated
{ "type": "example", "title": "example", "status": 1, "code": "example", "detail": "example", "request_id": "example", "retry_after": 1, "permission": "example", "current_version": 1, "references": [ { "kind": "example", "key": "example", "environment": "example" } ], "provider": "example", "used_by": [ "example" ], "failure": "example", "failure_status": 1, "failure_code": "example", "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}Headers
Section titled “Headers”The caller may not perform the operation: forbidden (with the
missing permission), session_required, insufficient_scope,
cross_origin for a request signed in by the session cookie, a read
included, that the browser says comes from another origin, or, for a
write, change_request_required when it would change what a
protected environment’s SDKs receive; detail names those
environments.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which clients branch on.
An English explanation for humans; never what a client branches on.
Seconds to wait before retrying, for a rate limit.
The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.
The version the entity has now, for version_mismatch.
What still names what the write would remove or hide, for in_use.
object
What names it, such as flag, segment or experiment.
The key of the environment it is named in; null when it is named in every environment.
The slug of the auth provider to sign in through instead, for sso_required.
What keeps an auth provider from being deleted, disabled or edited, for provider_in_use, such as identities, enforced domains or only way in (the only enabled provider while local login is disabled).
Why a system the server asked did not answer as needed, for provider_unreachable; for sink_not_ready the failure class of the target’s check, such as connect or status.
The HTTP status the target answered, for sink_not_ready, when it answered.
The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.
object
JSON Pointer into the request body.
The values of the rule broken, such as the bounds of a length, for a client to explain the violation in its own language.
object
Example generated
{ "type": "example", "title": "example", "status": 1, "code": "example", "detail": "example", "request_id": "example", "retry_after": 1, "permission": "example", "current_version": 1, "references": [ { "kind": "example", "key": "example", "environment": "example" } ], "provider": "example", "used_by": [ "example" ], "failure": "example", "failure_status": 1, "failure_code": "example", "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}not_found: no such project, or nothing under that identifier in it. An unknown project is answered before any permission is judged.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which clients branch on.
An English explanation for humans; never what a client branches on.
Seconds to wait before retrying, for a rate limit.
The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.
The version the entity has now, for version_mismatch.
What still names what the write would remove or hide, for in_use.
object
What names it, such as flag, segment or experiment.
The key of the environment it is named in; null when it is named in every environment.
The slug of the auth provider to sign in through instead, for sso_required.
What keeps an auth provider from being deleted, disabled or edited, for provider_in_use, such as identities, enforced domains or only way in (the only enabled provider while local login is disabled).
Why a system the server asked did not answer as needed, for provider_unreachable; for sink_not_ready the failure class of the target’s check, such as connect or status.
The HTTP status the target answered, for sink_not_ready, when it answered.
The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.
object
JSON Pointer into the request body.
The values of the rule broken, such as the bounds of a length, for a client to explain the violation in its own language.
object
Example generated
{ "type": "example", "title": "example", "status": 1, "code": "example", "detail": "example", "request_id": "example", "retry_after": 1, "permission": "example", "current_version": 1, "references": [ { "kind": "example", "key": "example", "environment": "example" } ], "provider": "example", "used_by": [ "example" ], "failure": "example", "failure_status": 1, "failure_code": "example", "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}The change conflicts with what exists, such as already_exists for a key already in use.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which clients branch on.
An English explanation for humans; never what a client branches on.
Seconds to wait before retrying, for a rate limit.
The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.
The version the entity has now, for version_mismatch.
What still names what the write would remove or hide, for in_use.
object
What names it, such as flag, segment or experiment.
The key of the environment it is named in; null when it is named in every environment.
The slug of the auth provider to sign in through instead, for sso_required.
What keeps an auth provider from being deleted, disabled or edited, for provider_in_use, such as identities, enforced domains or only way in (the only enabled provider while local login is disabled).
Why a system the server asked did not answer as needed, for provider_unreachable; for sink_not_ready the failure class of the target’s check, such as connect or status.
The HTTP status the target answered, for sink_not_ready, when it answered.
The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.
object
JSON Pointer into the request body.
The values of the rule broken, such as the bounds of a length, for a client to explain the violation in its own language.
object
Example generated
{ "type": "example", "title": "example", "status": 1, "code": "example", "detail": "example", "request_id": "example", "retry_after": 1, "permission": "example", "current_version": 1, "references": [ { "kind": "example", "key": "example", "environment": "example" } ], "provider": "example", "used_by": [ "example" ], "failure": "example", "failure_status": 1, "failure_code": "example", "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}The request is well formed but breaks a rule; errors names each field to fix.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which clients branch on.
An English explanation for humans; never what a client branches on.
Seconds to wait before retrying, for a rate limit.
The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.
The version the entity has now, for version_mismatch.
What still names what the write would remove or hide, for in_use.
object
What names it, such as flag, segment or experiment.
The key of the environment it is named in; null when it is named in every environment.
The slug of the auth provider to sign in through instead, for sso_required.
What keeps an auth provider from being deleted, disabled or edited, for provider_in_use, such as identities, enforced domains or only way in (the only enabled provider while local login is disabled).
Why a system the server asked did not answer as needed, for provider_unreachable; for sink_not_ready the failure class of the target’s check, such as connect or status.
The HTTP status the target answered, for sink_not_ready, when it answered.
The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.
object
JSON Pointer into the request body.
The values of the rule broken, such as the bounds of a length, for a client to explain the violation in its own language.
object
Example generated
{ "type": "example", "title": "example", "status": 1, "code": "example", "detail": "example", "request_id": "example", "retry_after": 1, "permission": "example", "current_version": 1, "references": [ { "kind": "example", "key": "example", "environment": "example" } ], "provider": "example", "used_by": [ "example" ], "failure": "example", "failure_status": 1, "failure_code": "example", "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}