Flags API reference

Flags API · Evaluate

post/v1/workspaces/{workspace_id}/configs/{config_id}/environments/{environment_id}/evaluateAuth

Test an evaluation

Evaluates a sample user against the published config of this environment (the current revision, or `revision`) with the same engine the SDKs run, and returns the evaluation details per key: value, reason, the rule and percentage option that decided, and soft-miss warnings. Each setting's own value is the default. Nothing is stored and the user is never logged. Limited to 30 calls a minute per credential; the evaluation has a 250 ms budget (422 `EVALUATION_BUDGET_EXCEEDED`, ask for fewer keys).

Path parameters

config_id*string · uuid

Id of the config.

environment_id*string · uuid

Id of an environment of the same project.

workspace_id*string · uuid

Id of the workspace.

Request body

userobject

The user to evaluate for, in the SDK's shape: `identifier`, `email`, `country` and `custom: {…}`; flat attributes are accepted too (`custom` wins when both name one). Attribute names are yours and kept as sent. `null` or omitted: no user (rules that need one are soft misses with `missing_user`). Attribute values are text, numbers, booleans or arrays of text; anything else is a soft miss (`invalid_attribute`), as in the SDKs. Dates: send unix seconds, `{"$date": "<ISO 8601>"}`, or a plain ISO 8601 string for an attribute that a `before`/`after` condition of this config uses (converted to unix seconds; a console convenience, SDKs take a `Date` or unix seconds; each converted attribute adds an `iso_date_converted` warning to the rows it affects). Never stored or logged.

Example: {"identifier":"user-2","email":"ada@acme.com","custom":{"app_version":"2.1.0"}}

keysarray

Setting keys to evaluate (at most 200). Omitted: every setting. An unknown key returns a `FLAG_NOT_FOUND` row.

Example: ["new_checkout","banner_text"]

revisioninteger

Evaluate this published revision instead of the current one (404 `REVISION_NOT_FOUND` once pruned).

Example: 41

Response · 200 The evaluation details.

revision*integer

The config revision evaluated.

Example: 42

data*array

One row per evaluated key: the requested keys in request order, or every setting in config order.

Example

Request

POST https://api.flags.productcraft.co/v1/workspaces/{workspace_id}/configs/{config_id}/environments/{environment_id}/evaluate
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "user": {
    "identifier": "user-2",
    "email": "ada@acme.com",
    "custom": {
      "app_version": "2.1.0"
    }
  },
  "keys": [
    "new_checkout",
    "banner_text"
  ],
  "revision": 41
}

Response

{
  "revision": 42,
  "data": [
    {
      "key": "new_checkout",
      "value": true,
      "variant": "rule:1/pct:0",
      "reason": "SPLIT",
      "error_code": null,
      "error_message": null,
      "rule_index": 1,
      "percentage_index": 0,
      "is_default_value": false,
      "warnings": [
        {
          "code": "missing_attribute",
          "message": "The user has no attribute \"app_version\".",
          "key": "new_checkout",
          "rule_index": 1,
          "attribute": "app_version"
        }
      ]
    }
  ]
}