Context
Context is the set of key-value pairs the client passes with each eval request. Rules match against these keys.
What is context?
Context describes the environment of an evaluation: who is asking, where they are, what version they run, what plan they're on. Every key-value pair you include is available to rules.
There is no fixed schema — you define your own context keys and reference them in rule field definitions. Common keys:
| Example key | Example value | Typical use |
|---|---|---|
| country | DE | Geo-targeting, GDPR jurisdiction |
| plan | pro | Feature gating by subscription tier |
| user_id | usr_01HXYZ | Per-user flag overrides |
| app_version | 2.5.0 | Semver-based rollouts |
| alice@acme.com | Internal / beta user targeting |
Setting context at runtime
Use setContext / removeContext after the client is initialized — e.g. once the
user logs in.
// After the user logs in:
flags.setContext('user_id', user.id);
flags.setContext('plan', user.plan);
// Remove a key from context:
flags.removeContext('country');Per-call override
Pass a second argument to eval() to add or override context for
a single call without mutating the client instance.
// Override or add context for a single call — does not mutate the client:
const result = await flags.eval('beta_features', { user_id: 'usr_01' });Raw HTTP
When calling the API directly, every key in the JSON body (other than api_key) is treated as context.
# Every key in the JSON body (except api_key) is treated as context:
curl -X POST https://your-ftflg-instance.com/eval/dark_mode \
-H 'Content-Type: application/json' \
-d '{
"api_key": "ff_your_api_key",
"country": "DE",
"plan": "pro",
"app_version": "2.5.0"
}'Missing keys
If a rule references country but the eval request does not
include country, that rule fails. This means the flag returns enabled: false, value: null. Always send the full context
your rules depend on, or handle null gracefully on the client.