Flag evaluation
Evaluates a flag for an identifier and attributes you send. Rules run in order and the first match wins; percentage conditions bucket the identifier deterministically. The response carries the value and the reason.
What flag evaluation does
Evaluates a flag for an identifier and attributes you send. Rules run in order and the first match wins; percentage conditions bucket the identifier deterministically. The response carries the value and the reason.
When to use flag evaluation
- Feature gating
- Remote configuration for applications and agents
- Per-plan behaviour
Authentication
Send an API key as a bearer token. Keys are shown once, belong in a server environment, and are bound to one environment: flw_test_ keys act in test and flw_live_ keys in live.
Authorization: Bearer flw_test_••••Endpoint
POST https://api.flowyn.dev/v1/flags/evaluateRequest
The body is JSON.
curl -X POST https://api.flowyn.dev/v1/flags/evaluate \
-H "Authorization: Bearer $FLOWYN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"key": "checkout-v2",
"identifier": "usr_142",
"attributes": {
"plan": "pro",
"country": "DE"
}
}'Response
Flowyn returns HTTP 200. The response is abridged here; the OpenAPI document lists every field.
{
"key": "checkout-v2",
"environment": "test",
"enabled": true,
"value": true,
"reason": "percentage_rollout",
"matched_rule_id": "rule_rollout_25",
"bucket": 1742,
"configuration_version": 7,
"algorithm_version": "v1"
}Lifecycle
- Create the flag with a
key,value_type(boolean, string, number, or json), adefault_value, and optional rules. - Your application sends the key, an
identifier, andattributes. - Rules are evaluated in order. The first rule whose conditions all match returns its value with
reason: targeting_match. - A
percentagecondition hashes the identifier into a bucket from 0 to 9,999 and matches below the configured basis points (reason: percentage_rollout). - Otherwise the default is returned with
reason: default.
Status values
| Status | Meaning |
|---|---|
| targeting_match | A rule matched; matched_rule_id names it. |
| percentage_rollout | A percentage rule matched; bucket is returned. |
| default | No rule matched. |
| disabled | The flag is turned off in this environment. |
| unconfigured | The flag has no value in this environment. |
| archived | The flag is archived. |
Retries
Evaluation is synchronous and read-only. Retry freely.
Idempotency
Not needed. The same configuration version, identifier, and attributes always return the same value.
Errors
| Status | type | Meaning |
|---|---|---|
| 400 | invalid_request | The body is not valid JSON, a field has the wrong type, or the body is over 1 MiB (body_too_large). |
| 401 | unauthorized | Missing, malformed, or revoked API key. |
| 402 | billing_error | The monthly credit allowance is used (credit_limit_exceeded). Reads keep working. |
| 403 | forbidden | The key lacks the ability this call needs (ability_required). |
| 404 | not_found | The id does not exist in this environment. |
| 409 | conflict | For example idempotency_mismatch: the Idempotency-Key was used with a different body. |
| 422 | invalid_request | A field value is out of range, for example invalid_timeout. |
| 429 | rate_limited | Too many requests (rate_limit_exceeded). Wait for Retry-After seconds. |
| 5xx | server_error | Flowyn failed. The body carries an error_id to quote to support. |
Limits
- Up to 20 attributes; string values up to 256 characters
- Up to 20 rules per flag, 8 conditions per rule
- Values up to 10 KB
Create a flag
curl -X POST https://api.flowyn.dev/v1/flags \
-H "Authorization: Bearer $FLOWYN_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: flag-checkout-v2" \
-d '{
"key": "checkout-v2",
"name": "Checkout v2",
"value_type": "boolean",
"enabled": true,
"default_value": false
}'Related
Next step
Read Percentage rollouts.
