API
Flag Evaluation API

Flag Evaluation API

This API allows you to evaluate feature flag variations for a user against one or more feature flags in your environment.

API Endpoint

POST {evaluation-server-url}/api/public/featureflag/evaluate

Authentication

This API requires authentication using your environment secret key. You can use either your server-side or client-side secret key. Include the secret key in the Authorization header of your request.

Note: To get the environment secret key, refer to FAQ documentation.

Example:

Authorization: your-environment-secret-key

Request

The request body should be a JSON object with the following structure:

Schema

Request Body

ParameterTypeRequiredDescription
userEndUserYesThe end user for whom to evaluate feature flags
filterFeatureFlagFilterNoOptional filter to limit which feature flags to evaluate

EndUser

PropertyTypeRequiredDescription
keyIdstringYesUnique identifier for the user in your environment
namestringNoDisplay name for the user
customizedPropertiesArray<CustomProperty>NoArray of custom properties for user targeting

CustomProperty

FieldTypeRequiredDescription
namestringYesProperty name
valuestringYesProperty value

FeatureFlagFilter

PropertyTypeDefaultDescription
tagFilterModestring"and"Determines how multiple tags are matched. Use "and" to return only flags that have ALL specified tags, or "or" to return flags that have ANY of the specified tags
tagsstring[][]Array of tags to filter feature flags
keysstring[][]Array of specific feature flag keys to evaluate
timestampnumber0Unix timestamp in milliseconds. When provided, only returns flags modified after this timestamp. Useful for polling scenarios.

Example

{
  "user": {
    "keyId": "user-123",
    "name": "John Doe",
    "customizedProperties": [
      {
        "name": "country",
        "value": "US"
      },
      {
        "name": "plan",
        "value": "premium"
      }
    ]
  },
  "filter": {
    "tagFilterMode": "and",
    "tags": ["frontend", "mobile"],
    "keys": []
  }
}

Response

The API returns an array of evaluation results, one for each matching feature flag.

Schema

Response Body

PropertyTypeDescription
keystringThe feature flag key
variationEvalResultVariationThe evaluated variation for the user

EvalResultVariation

PropertyTypeDescription
idstringThe variation ID
typestringThe variation type (e.g., "string", "boolean", "number", "json")
valuestringThe variation value
matchReasonstringExplanation of why this variation was selected. Possible values:
"flag disabled" - The flag is disabled
"targeted" - The user is targeted individually
"{rule name}" - The user matched a specific rule (returns the rule name)
"default" - The user matched the default rule
sendToExperimentbooleanIndicates whether this variation should be included in experiment analysis. Needed when tracking insights.

Example

[
  {
    "key": "new-dashboard-design",
    "variation": {
      "id": "08aceef3-5513-4b38-80ad-4b27bebe8871",
      "type": "boolean",
      "value": "true",
      "matchReason": "premium user rule",
      "sendToExperiment": true
    }
  },
  {
    "key": "theme-color",
    "variation": {
      "id": "c5364cfd-292a-4e06-8e8e-b0ae7387f791",
      "type": "string",
      "value": "dark",
      "matchReason": "default",
      "sendToExperiment": false
    }
  },
  {
    "key": "max-file-upload-size",
    "variation": {
      "id": "34683e86-b436-4694-b335-29628c0896e3",
      "type": "number",
      "value": "104857600",
      "matchReason": "premium user rule",
      "sendToExperiment": true
    }
  }
]

Error Responses

401 Unauthorized

Returned when the authentication secret key is invalid or missing.

400 Bad Request

Returned when the request validation fails.

Missing or invalid user:

{
  "message": "A valid user is required."
}

Invalid tag filter mode:

{
  "message": "Invalid tag filter mode: invalid. Valid values are 'and' or 'or'."
}

Evaluating a Single Feature Flag

To evaluate against a single feature flag, use the filter.keys parameter with an array containing just one feature flag key.

Request

{
  "user": {
    "keyId": "user-123",
    "name": "John Doe",
    "customizedProperties": [
      {
        "name": "country",
        "value": "US"
      }
    ]
  },
  "filter": {
    "keys": ["new-dashboard-design"]
  }
}

Response

Note: When evaluating a single feature flag, the response will still be an array, but it will contain only one element.

[
  {
    "key": "new-dashboard-design",
    "variation": {
      "id": "ac727073-8cc5-4ec5-9405-59737ea737bb",
      "type": "boolean",
      "value": "false",
      "matchReason": "flag disabled",
      "sendToExperiment": false
    }
  }
]

Notes

  • The matchReason field in the response provides transparency about why a particular variation was selected, which can be helpful for debugging targeting rules.
  • If no filter is provided, all feature flags in the environment will be evaluated.
  • If filter criteria result in no matching feature flags, the response will be an empty array [].