Evaluate flag
client.flagship.apps.evaluate.get(stringappID, EvaluateGetParams { account_id, flagKey, targetingKey } params, RequestOptionsoptions?): EvaluateGetResponse { flagKey, reason, variant, value }
GET/accounts/{account_id}/flagship/apps/{app_id}/evaluate
Evaluates a flag against the provided context. Pass context attributes as query parameters; values are forwarded as strings. For low-latency in-Worker evaluation, prefer the Flagship binding over this endpoint.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
Evaluate flag
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const evaluate = await client.flagship.apps.evaluate.get('app_id', {
account_id: 'account_id',
flagKey: 'flagKey',
});
console.log(evaluate.flagKey);{
"flagKey": "flagKey",
"reason": "TARGETING_MATCH",
"variant": "variant",
"value": "string"
}Returns Examples
{
"flagKey": "flagKey",
"reason": "TARGETING_MATCH",
"variant": "variant",
"value": "string"
}