Targeting and rollouts
Targeting is configured per environment with a management key (vsk_live_…) against the REST base https://statskit.ai/api/v1. The server applies these rules and returns only resolved values to browser clients, the rules themselves never cross the wire to public keys.
Evaluation order
Section titled “Evaluation order”For a given context, an environment resolves a flag in this order:
-
Off? If the flag is disabled in this environment, serve its
offVariation. -
A rule matches? Serve that rule’s variation (or its weighted rollout).
-
Fallthrough. Serve the environment’s default variation (or its rollout).
Environment config
Section titled “Environment config”Set the on/off state, the off variation, and the fallthrough for one environment:
{ "enabled": true, "offVariation": 1, "fallthrough": { "variation": 0 }}{ "enabled": true, "offVariation": 1, "fallthrough": { "rollout": [ { "idx": 0, "weight": 10 }, { "idx": 1, "weight": 90 } ] }}A weighted rollout splits traffic across variations by weight. Bucketing is deterministic on the context key, so a given user stays in the same bucket as you dial the weights up.
Targeting rules
Section titled “Targeting rules”Rules serve a specific variation (or rollout) to contexts that match a set of clauses. A clause is either attribute op values or a segment match, and rules combine clauses with and/or.
{ "rules": [ { "clauses": [ { "attribute": "plan", "op": "in", "values": ["pro", "enterprise"] }, { "attribute": "country", "op": "in", "values": ["US", "CA"] } ], "serve": { "variation": 0 } }, { "clauses": [ { "segment": "beta-testers", "op": "segmentMatch" } ], "serve": { "rollout": [ { "idx": 0, "weight": 50 }, { "idx": 1, "weight": 50 } ] } } ]}Rules are evaluated top to bottom; the first match wins. A context that matches no rule falls through.
Segments
Section titled “Segments”A segment is a reusable targeting group, define who’s in it once and reference it from any flag’s clauses with segmentMatch. Update the segment and every flag that references it changes at the next publish. See the segments API.
Kill switch
Section titled “Kill switch”Flip a flag off (or back on) in one environment without touching its config:
When off, the flag serves its offVariation to everyone, bypassing all rules. This is the fast path to disable a feature in production.
Defining a flag
Section titled “Defining a flag”Before you target it, a flag must exist. Create one with:
{ "key": "new-checkout", "name": "New checkout", "description": "Redesigned checkout flow", "type": "boolean", "variations": [ { "idx": 0, "value": true, "name": "on" }, { "idx": 1, "value": false, "name": "off" } ], "temporary": true, "bucketBy": "key", "tags": ["checkout"]}See the full flags API reference for every field and endpoint.