Evaluate flags
Evaluates one or more flag keys for the project environment bound to the presented key. Server runtime keys can evaluate all configured flags. Browser client keys must be used from an allowed Origin and can evaluate only flags explicitly exposed to clients.
POSThttps://api.featuregate.dev/v1/evaluate
Authenticate with either a server runtime key or a publishable browser client key in the Authorization header.runtime:evaluateclient:evaluate
Body parameters
flagsstring[]optional
Simple flag-key batch. Send either flags or evaluations, not both.
Items: 1-100
evaluationsobject[]optional
Flag-key batch with per-flag fallbacks. Send either evaluations or flags, not both.
Items: 1-100
keystringrequired
Flag key to evaluate.
Length: 1-128
defaultValueboolean | string | number | objectoptional
Typed fallback returned when the flag is missing or archived.
contextobjectoptional
Targeting context. FeatureGate never stores raw context from evaluation requests.
Request
sh
curl -X POST https://api.featuregate.dev/v1/evaluate \
-H "Authorization: Bearer fg_sk_test_0123456789abcdef0123456789abcdef0123456789abcdef" \
-H "Content-Type: application/json" \
-d '{
"evaluations": [
{
"key": "new-checkout",
"defaultValue": false
}
],
"context": {
"user": {
"id": "user_123"
},
"account": {
"plan": "pro"
}
}
}'Returns
evaluationobjectrequired
projectIdstringrequired
Project bound to the runtime key.
Length: 1+
environmentobjectrequired
Environment bound to the runtime key.
resultsobject[]required
Example response · 200
json
{
"evaluation": {
"projectId": "project_example",
"environment": {
"id": "env_example",
"key": "production",
"name": "Production"
},
"results": [
{
"key": "new-checkout",
"type": "boolean",
"value": true,
"reason": "targeting_match"
}
]
}
}Responses
200Typed evaluation results for the requested flags.
400Validation failed.
401Authentication failed.
403The key is not allowed to access this resource.
429Rate limit exceeded.
500Unexpected server error.