On this page

Experiment Evaluation API

The Experiment Evaluation APIs retrieve variant assignment data for users through remote evaluation using the evaluation API, or download local evaluation flags using the flags API.

Regions

Authorization

The evaluation APIs authenticate the request using your deployment key set in the Authorization header with the prefix Api-Key. For example, Authorization: Api-Key <deployment_key>.


Evaluation API

text
GET /v1/vardata

The Evaluation API lets you retrieve variant assignment data for users. When you call this API, Amplitude tracks an [Experiment] Assignment event.

Evaluation query parameters

Evaluation headers

Evaluation response

The response body is a JSON object keyed by the flag key. The value for each flag key is the variant assigned to the user. Each variant object contains the following fields:

Unexpected response fields.

The variant object for each flag may include additional response fields in the future. Your code must handle these additional fields gracefully.

For example:

json
{
  "my-experiment": {
    "key": "treatment",
    "payload": { "price": 99.99, "discount": "25%" },
    "expKey": "exp-1",
    "evaluationId": "224681772811_1760563672659_3681"
  }
  // ...
}

Empty results

If a user isn't in the target audience, the Evaluation API may return an empty object.

json
{}

Evaluation response status codes

Evaluation example

Set the fields in the table, then select Send to make the request in your browser, or copy the curl command to run the request yourself.

Evaluation example

GET · /v1/vardataEvaluation API
Request parameters
Server deployment key. Starts with server-.
Provide at least one of User ID or Device ID.
Comma-separated. Leave blank to fetch all flags in the deployment.
Optional JSON passed as user properties for targeting.
Not sent
cURLGET · /v1/vardata
curl --request GET \
--url 'https://api.lab.amplitude.com/v1/vardata' \
--header 'Authorization: Api-Key deployment_key'
$ awaiting send…

Flags API

text
GET /v1/flags

The Flags API lets you download flag configurations for local evaluations. Use the Flags API to bootstrap client-side local evaluation SDKs with initialFlags, or to run evaluation using external flag configuration storage such as edge environments.

The data model returned by this API differs from the management API format for flags and experiments. The Flags API format supports evaluation, so it's more verbose and less human-readable than the management API format.

Flags query parameters

Flags headers

Flags response

The Flags API returns a JSON array of objects, where each object represents a flag or experiment. For example, here's a basic response with a single flag.

json
[
  {
    "key": "example-flag",
    "metadata": {
      "deployed": true,
      "evaluationMode": "local",
      "flagType": "release",
      "flagVersion": 42
    },
    "segments": [
      {
        "metadata": {
          "segmentName": "All Other Users"
        },
        "variant": "off"
      }
    ],
    "variants": {
      "off": {
        "key": "off",
        "metadata": {
          "default": true
        }
      },
      "on": {
        "key": "on",
        "value": "on"
      }
    }
  }
]

Flags response status codes

Was this helpful?