Skip to content
Start here

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:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Flagship ReadFlagship WriteFlagship Evaluate
ParametersExpand Collapse
appID: string

App identifier.

params: EvaluateGetParams { account_id, flagKey, targetingKey }
account_id: string

Path param: Cloudflare account ID.

flagKey: string

Query param: The flag key to evaluate.

targetingKey?: string

Query param: Context targeting key (per OpenFeature spec); used for percentage rollout bucketing.

ReturnsExpand Collapse
EvaluateGetResponse { flagKey, reason, variant, value }
flagKey: string
reason: "TARGETING_MATCH" | "DEFAULT" | "DISABLED" | "SPLIT"
One of the following:
"TARGETING_MATCH"
"DEFAULT"
"DISABLED"
"SPLIT"
variant: string
value?: string | null | number | boolean | 2 more
One of the following:
string | null
number
boolean
Record<string, unknown>
Array<unknown>

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"
}