The Amplitude Experiment Evaluation REST API lets you retrieve variant assignment data for users via remote evaluation. User information passes as query parameters on the request to allow for caching the response on the CDN. When you call this API, Amplitude tracks an [Experiment] Assignment
event.
Region | URL |
---|---|
Standard Server | https://api.lab.amplitude.com/v1/ |
EU Residency Server | https://api.lab.eu.amplitude.com/v1/ |
The REST API authenticates the request using your deployment key set in the Authorization header with the prefix Api-Key
. For example, Authorization: Api-Key <deployment_key>
Name |
Description |
---|---|
user_id |
The user's ID. |
device_id |
The user's device ID. |
flag_key |
A specific flag key to get the variant of. If empty/missing, Experiment evaluates all flags & experiments associated with the deployment key. |
context |
JSON string consisting of a full user context. Set user properties in the user_properties field (for example: {"user_properties":{"premium":true}} ). |
A successful request returns a 200
response and a map of flag key to variants. If flag_key
isn't provided, Experiment evaluates all flags associated with the deployment key in the authorization header.
The response body is a JSON object keyed by the flag key. The value for a given flag key is the variant assigned to the user. The variant contains its identification key
(a.k.a value) and an optional payload containing a JSON element.
1{2 "<flag_key>": {3 "key": "<variant_value>",4 "payload": <variant_payload>5 },6 // ...7}
If a user isn't in the target audience, the Evaluation API may return an empty object.
1{}
Use the example below to try the API from your browser or copy a curl.
If the request has invalid JSON in the context parameter, it returns a 400
status.
If the request doesn't include a valid API key, it returns a 401
response.
Set the fields in the table, and press send to send the request in browser, or copy the curl to send the request yourself.
1curl --request GET \2 --url '' \3 --header 'Authorization: Api-Key '
Thanks for your feedback!
November 21st, 2024
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2024 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.