Introduction
Overview of the Variant API
Variant assignment and retrieval is designed to as as straightforward as possible. Get get/set variants, you must specify the experiments you’d like assignments for any all available subject types.
Subject IDs
If an experiment is provided, but the subject for that experiment is missing or invalid, a variant will not be assigned or retrieved. The exception to this is for experiments in the “winner declared” status, where the winning variant will always be returned.
Examples
Get assignments for given subject
In this example, we don’t want to create any new variant assignments, only get existing ones (or variants for “winning declared” experiments).
This example says that the subject is currently assigned to the control
variant in the hero-nov-2024
experiment.
Sets assignments for given subject
In this example, we want to create any new assignments that don’t already exist:
This example says that the subject was previously assigned to the control
variant in the hero-nov-2024
experiment and, as a result of this request, was assigned the treatment-a
variant in the my-new-experiment
experiment.