Flags
Feature flags with rules and stable percentage rollouts. Change who sees a feature without a deploy.
Creating a flag
curl -X POST https://api.dianthan.com/v1/flags \
-H "X-API-Key: dn_live_…" -H "X-App-Id: app_…" \
-H "Content-Type: application/json" \
-d '{
"key": "editor.v2",
"description": "The new editor",
"default_value": false,
"rules": [
{ "conditions": [{ "attr": "plan", "op": "eq", "value": "pro" }], "value": true },
{ "conditions": [{ "attr": "user_id", "op": "percent", "value": 20 }], "value": true }
]
}'Rules are checked in order, and the first one whose conditions all match decides the value. If none match, the flag returns default_value. Values can be any JSON up to 4 KB, not just true and false.
Operators
op | Matches when the attribute |
|---|---|
eq, neq | equals, or doesn't equal, value |
in, not_in | is, or isn't, in the list value (up to 100 items) |
contains | contains the string value |
gt, gte, lt, lte | compares as a number |
percent | falls in the first value percent of a stable hash |
A flag can have up to 50 rules with up to 10 conditions each.
Stable rollouts
percent hashes the flag key together with the attribute's value. The same user always gets the same answer for the same flag. Raising a rollout from 20 to 50 keeps the first 20% and adds more, so nobody switches back and forth between versions. Different flags hash differently, so the same people aren't always the early group.
Evaluating
Evaluate every flag a page needs in one request:
curl -X POST https://api.dianthan.com/v1/flags/evaluate \
-H "X-API-Key: dn_live_…" -H "X-App-Id: app_…" \
-H "Content-Type: application/json" \
-d '{"keys":["editor.v2","export.batch"],"context":{"user_id":"usr_x81…","plan":"pro","country":"PT"}}'{ "flags": { "editor.v2": true, "export.batch": false } }Pass up to 100 keys, or a single key. The context holds up to 50 attributes to target on. Dianthan doesn't store them.
Kill switches
To turn a feature off for everyone, set its first rule to an empty condition list with value false, or change default_value and remove the rules. PATCH /v1/flags/:key takes effect on the next evaluation.
In preview: experiments that assign variants and compare them using the events Observe already collects.