The served value of every flag for a context
const url = 'https://example.com/sdk/v1/evaluate';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"context":{"units":{"additionalProperty":"example"},"attributes":{}},"flags":["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/sdk/v1/evaluate \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "context": { "units": { "additionalProperty": "example" }, "attributes": {} }, "flags": [ "example" ] }'Evaluates the environment’s ruleset for the context posted, against the whole server-side document, private segments included, and answers the served value of every flag, or of the flags named. A flag named that the ruleset does not hold is left out of the answer.
Attributes are typed against the project’s declarations: an
undeclared attribute, or one named like a unit type, is left out and
listed in ignored_attributes with undeclared; a value of the
wrong type is left out and listed with type_mismatch; null is
kept. A client key’s ignored_attributes is always empty, since it
would otherwise tell which attributes the project declares. A context over the limits (64 attributes, 256 characters per
string, 64 items per list, 256 bytes per unit ID) is
422 invalid_context, every violation pointing into the body with
too_long or too_many and params.max. A unit type given twice
is 422 invalid_context too, with duplicate at that unit type,
since which of its IDs to evaluate for would be a guess. The body
is at most 32 KiB after decompression.
A client key’s answer never says how a value was reached: the
reasons rule, rollout, fallthrough and prerequisite_failed
are answered targeting_match, and no rule_id is ever present;
off, override, experiment and error and the experiment block
stay. A server key’s answer carries the true reason and rule_id.
Evaluating records no exposure.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”The highest document schema the SDK reads; absent is 1.
gzip for a compressed body.
Request Bodyrequired
Section titled “Request Bodyrequired”object
object
The unit ID of each unit type, such as {"user":"u-1001"}; an empty ID is an absent unit.
object
The context’s attributes, by key.
object
The flags to evaluate; every flag when absent.
Example generated
{ "context": { "units": { "additionalProperty": "example" }, "attributes": {} }, "flags": [ "example" ]}Responses
Section titled “Responses”The served value of every flag evaluated, by flag key.
object
The version of the ruleset evaluated.
object
An SDK ignores local overrides in a protected environment.
The result of each flag evaluated, by flag key.
object
object
The served value; absent for error.
The served variation; absent for error.
Why the value was served. A client key receives targeting_match,
off, override, experiment or error; a server key the
true reason: rule, rollout, fallthrough,
prerequisite_failed, off, override, experiment or
error. An SDK passes a reason it does not know through with
the served value.
The rule that served, for a server key only.
Whether the SDK records an exposure after every evaluation carrying experiment.
Whether an override influenced the value, directly or through a prerequisite.
The running experiment the value comes from, which an exposure carries.
object
The served variation; an override’s when an override decided the value.
Whether an override influenced the value; analysis excludes such exposures.
For error: prerequisite_cycle or inconsistent_ruleset.
flag_not_found is the code of an SDK’s local evaluator for a flag
the ruleset does not hold; /evaluate never answers it, as it
leaves unknown flags out.
The attributes left out of the evaluation, and why; always empty for a client key.
object
undeclared or type_mismatch.
Example generated
{ "schema_version": 1, "ruleset_version": 1, "environment": { "key": "example", "protected": true }, "flags": { "additionalProperty": { "type": "example", "value": "example", "variation": "example", "reason": "example", "rule_id": "example", "automatic_exposure": true, "override_influenced": true, "experiment": { "key": "example", "variation": "example", "unit_type": "example", "unit_id": "example", "inclusion_salt": "example", "variation_salt": "example", "inclusion_bucket": 1, "variation_bucket": 1, "override": true }, "error_code": "example" } }, "ignored_attributes": [ { "name": "example", "code": "example" } ]}Headers
Section titled “Headers”no-store: one context’s values are never cached for another.
The requests the window allows.
The requests left in the window.
invalid_request: a body that is not JSON, or an events envelope that breaks its shape, with errors.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which an SDK branches on.
An English explanation for humans; never what an SDK branches on.
Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.
object
JSON Pointer into the request body.
The rule broken, such as too_long, too_many or duplicate.
The values of the rule broken, such as max, 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, "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}sdk_key_missing without a key, with WWW-Authenticate: Bearer;
sdk_key_invalid, sdk_key_revoked or sdk_key_expired, with
WWW-Authenticate: Bearer error="invalid_token".
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which an SDK branches on.
An English explanation for humans; never what an SDK branches on.
Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.
object
JSON Pointer into the request body.
The rule broken, such as too_long, too_many or duplicate.
The values of the rule broken, such as max, 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, "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}Headers
Section titled “Headers”key_kind_not_allowed (a client key at the ruleset),
server_key_in_query, server_key_from_browser or
origin_not_allowed.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which an SDK branches on.
An English explanation for humans; never what an SDK branches on.
Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.
object
JSON Pointer into the request body.
The rule broken, such as too_long, too_many or duplicate.
The values of the rule broken, such as max, 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, "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}schema_version_unsupported: Flagnetic-Schema-Version below 1, not an integer, or sent more than once.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which an SDK branches on.
An English explanation for humans; never what an SDK branches on.
Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.
object
JSON Pointer into the request body.
The rule broken, such as too_long, too_many or duplicate.
The values of the rule broken, such as max, 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, "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}request_too_large: the body is over its limit after decompression.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which an SDK branches on.
An English explanation for humans; never what an SDK branches on.
Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.
object
JSON Pointer into the request body.
The rule broken, such as too_long, too_many or duplicate.
The values of the rule broken, such as max, 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, "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}unsupported_media_type: the body is not application/json (the
events endpoint also takes text/plain, which a browser sends without
a preflight), or it arrives in a Content-Encoding other than gzip
or identity.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which an SDK branches on.
An English explanation for humans; never what an SDK branches on.
Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.
object
JSON Pointer into the request body.
The rule broken, such as too_long, too_many or duplicate.
The values of the rule broken, such as max, 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, "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}invalid_context: the context breaks a limit; errors names every violation.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which an SDK branches on.
An English explanation for humans; never what an SDK branches on.
Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.
object
JSON Pointer into the request body.
The rule broken, such as too_long, too_many or duplicate.
The values of the rule broken, such as max, 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, "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}rate_limited: the window is spent.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which an SDK branches on.
An English explanation for humans; never what an SDK branches on.
Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.
object
JSON Pointer into the request body.
The rule broken, such as too_long, too_many or duplicate.
The values of the rule broken, such as max, 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, "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}Headers
Section titled “Headers”Seconds to wait before trying again, at least 1.
The requests the window allows.
The requests left in the window.
Seconds until the window ends, at least 1.
ruleset_unavailable (this replica cannot load the environment’s
ruleset yet) or unavailable (the key could not be checked, or this
replica is shutting down and takes no new stream), with
Retry-After.
A problem document (RFC 9457). Code-specific values are further members.
object
Stable snake_case name of the problem, which an SDK branches on.
An English explanation for humans; never what an SDK branches on.
Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.
object
JSON Pointer into the request body.
The rule broken, such as too_long, too_many or duplicate.
The values of the rule broken, such as max, 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, "errors": [ { "pointer": "example", "code": "example", "detail": "example", "params": {} } ]}Headers
Section titled “Headers”Seconds to wait before trying again, at least 1.