Skip to content

Evaluate flags for a context, as the environment's SDKs would

POST
/projects/{project}/environments/{environment}/evaluate
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.

project
required
string

The project’s key.

environment
required
string

The environment’s key.

Media typeapplication/json
object
context
required

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
units
object
key
additional properties
string
attributes
object
key
additional properties
any
flags

The keys of the flags to evaluate; absent for every flag that is not archived.

Array<string>
draft

An unsaved configuration of one flag in the environment, evaluated in place of the saved one and never stored.

object
flag
required

The key of a flag of the project that is not archived.

string
configuration
required
object
on
required
boolean
off_variation
required
string
fallthrough
required
string
prerequisites
Array<object>
<= 50 items
object
flag
required

The key of another flag of the project, not archived.

string
variation
required

One of that flag’s variations.

string
overrides
Array<object>
<= 200 items
object
unit_type
required

A unit type the project declares.

string
unit_id
required

The unit’s ID, of 1 to 256 bytes, unique per unit type in the configuration.

string
>= 1 characters
variation
required
string
note

At most 200 characters once trimmed; blank is none.

string
nullable
rules
Array<object>
<= 50 items
object
id

The rule of the current configuration this one is; omitted for a new rule.

string format: uuid
description
string
<= 2000 characters
conditions
Array<object>
<= 20 items

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
kind
required

attribute, in_segment, not_in_segment or prerequisite.

string
attribute
string
op
string
value

A string, number, boolean or list, as the operator and the attribute’s type need; null is no value.

nullable
segment
string
flag
string
variation
string
serve
required

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
kind
required

variation, rollout or experiment.

string
variation
string
experiment

The key of the experiment served, for kind experiment.

string
unit_type
string
percentage
integer
<= 10000
salt
string

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"
}
}
]
}
}
}

The result of every flag evaluated, by flag key.

Media typeapplication/json
object
ruleset_version
required

The version of the environment’s saved ruleset, which a draft does not move.

integer format: int64
flags
required

The result of each flag evaluated, by flag key.

object
key
additional properties

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
type
string
Allowed values: boolean string number json
value

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).

variation

The served variation’s key; absent for an error.

string
reason
required

off, override, rule, rollout, experiment, fallthrough, prerequisite_failed or error.

string
rule_id

The rule that served, for reasons rule, rollout and experiment.

string format: uuid
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
key
required
string
variation
required

The served variation; the override’s when an override decided the result.

string
unit_type
required
string
unit_id
required
string
inclusion_salt
required
string
variation_salt
required
string
inclusion_bucket
required

The unit is included when it is below the traffic allocation.

integer
variation_bucket
required

Picks the variation by the weights’ cumulative ranges.

integer
override
required

Whether an override influenced the result; analysis leaves such exposures out.

boolean
automatic_exposure
boolean
prerequisite

The key of the flag-level prerequisite that failed, for reason prerequisite_failed.

string
bucket

The unit’s bucket, 0 to 9,999, for reason rollout; the unit is in the rollout because its bucket is below the percentage.

integer
salt

The salt of the rollout that served, for reason rollout.

string
error_code

Why the result is an error: flag_not_found, prerequisite_cycle or inconsistent_ruleset.

string
override_influenced
required

Whether an override decided the result, directly or through a prerequisite.

boolean

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.

Media typeapplication/problem+json

A problem document (RFC 9457). Code-specific values are further members.

object
type
required
string
title
required
string
status
required
integer
code
required

Stable snake_case name of the problem, which clients branch on.

string
detail

An English explanation for humans; never what a client branches on.

string
request_id
required
string
retry_after

Seconds to wait before retrying, for a rate limit.

integer
permission

The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.

string
current_version

The version the entity has now, for version_mismatch.

integer format: int64
references

What still names what the write would remove or hide, for in_use.

Array<object>
object
kind
required

What names it, such as flag, segment or experiment.

string
key
required
string
environment
required

The key of the environment it is named in; null when it is named in every environment.

string
nullable
provider

The slug of the auth provider to sign in through instead, for sso_required.

string
used_by

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).

Array<string>
failure

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.

string
failure_status

The HTTP status the target answered, for sink_not_ready, when it answered.

integer
failure_code

The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.

string
errors
Array<object>
object
pointer
required

JSON Pointer into the request body.

string
code
required
string
detail
required
string
params

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
key
additional properties
any

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.

Media typeapplication/problem+json

A problem document (RFC 9457). Code-specific values are further members.

object
type
required
string
title
required
string
status
required
integer
code
required

Stable snake_case name of the problem, which clients branch on.

string
detail

An English explanation for humans; never what a client branches on.

string
request_id
required
string
retry_after

Seconds to wait before retrying, for a rate limit.

integer
permission

The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.

string
current_version

The version the entity has now, for version_mismatch.

integer format: int64
references

What still names what the write would remove or hide, for in_use.

Array<object>
object
kind
required

What names it, such as flag, segment or experiment.

string
key
required
string
environment
required

The key of the environment it is named in; null when it is named in every environment.

string
nullable
provider

The slug of the auth provider to sign in through instead, for sso_required.

string
used_by

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).

Array<string>
failure

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.

string
failure_status

The HTTP status the target answered, for sink_not_ready, when it answered.

integer
failure_code

The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.

string
errors
Array<object>
object
pointer
required

JSON Pointer into the request body.

string
code
required
string
detail
required
string
params

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
key
additional properties
any

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": {}
}
]
}
WWW-Authenticate
string

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.

Media typeapplication/problem+json

A problem document (RFC 9457). Code-specific values are further members.

object
type
required
string
title
required
string
status
required
integer
code
required

Stable snake_case name of the problem, which clients branch on.

string
detail

An English explanation for humans; never what a client branches on.

string
request_id
required
string
retry_after

Seconds to wait before retrying, for a rate limit.

integer
permission

The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.

string
current_version

The version the entity has now, for version_mismatch.

integer format: int64
references

What still names what the write would remove or hide, for in_use.

Array<object>
object
kind
required

What names it, such as flag, segment or experiment.

string
key
required
string
environment
required

The key of the environment it is named in; null when it is named in every environment.

string
nullable
provider

The slug of the auth provider to sign in through instead, for sso_required.

string
used_by

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).

Array<string>
failure

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.

string
failure_status

The HTTP status the target answered, for sink_not_ready, when it answered.

integer
failure_code

The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.

string
errors
Array<object>
object
pointer
required

JSON Pointer into the request body.

string
code
required
string
detail
required
string
params

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
key
additional properties
any

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.

Media typeapplication/problem+json

A problem document (RFC 9457). Code-specific values are further members.

object
type
required
string
title
required
string
status
required
integer
code
required

Stable snake_case name of the problem, which clients branch on.

string
detail

An English explanation for humans; never what a client branches on.

string
request_id
required
string
retry_after

Seconds to wait before retrying, for a rate limit.

integer
permission

The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.

string
current_version

The version the entity has now, for version_mismatch.

integer format: int64
references

What still names what the write would remove or hide, for in_use.

Array<object>
object
kind
required

What names it, such as flag, segment or experiment.

string
key
required
string
environment
required

The key of the environment it is named in; null when it is named in every environment.

string
nullable
provider

The slug of the auth provider to sign in through instead, for sso_required.

string
used_by

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).

Array<string>
failure

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.

string
failure_status

The HTTP status the target answered, for sink_not_ready, when it answered.

integer
failure_code

The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.

string
errors
Array<object>
object
pointer
required

JSON Pointer into the request body.

string
code
required
string
detail
required
string
params

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
key
additional properties
any

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.

Media typeapplication/problem+json

A problem document (RFC 9457). Code-specific values are further members.

object
type
required
string
title
required
string
status
required
integer
code
required

Stable snake_case name of the problem, which clients branch on.

string
detail

An English explanation for humans; never what a client branches on.

string
request_id
required
string
retry_after

Seconds to wait before retrying, for a rate limit.

integer
permission

The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.

string
current_version

The version the entity has now, for version_mismatch.

integer format: int64
references

What still names what the write would remove or hide, for in_use.

Array<object>
object
kind
required

What names it, such as flag, segment or experiment.

string
key
required
string
environment
required

The key of the environment it is named in; null when it is named in every environment.

string
nullable
provider

The slug of the auth provider to sign in through instead, for sso_required.

string
used_by

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).

Array<string>
failure

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.

string
failure_status

The HTTP status the target answered, for sink_not_ready, when it answered.

integer
failure_code

The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.

string
errors
Array<object>
object
pointer
required

JSON Pointer into the request body.

string
code
required
string
detail
required
string
params

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
key
additional properties
any

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.

Media typeapplication/problem+json

A problem document (RFC 9457). Code-specific values are further members.

object
type
required
string
title
required
string
status
required
integer
code
required

Stable snake_case name of the problem, which clients branch on.

string
detail

An English explanation for humans; never what a client branches on.

string
request_id
required
string
retry_after

Seconds to wait before retrying, for a rate limit.

integer
permission

The permission the caller lacks, for forbidden, or the role’s permission the caller lacks, for role_not_allowed.

string
current_version

The version the entity has now, for version_mismatch.

integer format: int64
references

What still names what the write would remove or hide, for in_use.

Array<object>
object
kind
required

What names it, such as flag, segment or experiment.

string
key
required
string
environment
required

The key of the environment it is named in; null when it is named in every environment.

string
nullable
provider

The slug of the auth provider to sign in through instead, for sso_required.

string
used_by

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).

Array<string>
failure

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.

string
failure_status

The HTTP status the target answered, for sink_not_ready, when it answered.

integer
failure_code

The target’s own error code, for sink_not_ready, when it speaks one, such as a ClickHouse exception or an S3 error code.

string
errors
Array<object>
object
pointer
required

JSON Pointer into the request body.

string
code
required
string
detail
required
string
params

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
key
additional properties
any

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": {}
}
]
}