Create decide

Promotes one variant to the whole rollout and records who decided.

POST /v1/experiment/{id}/decide

Addresshttps://api.hanzo.ai/v1/experiment/{id}/decide
MethodPOST
Operationpost_experiment_by_id_decide
AuthAuthorization: Bearer $HANZO_API_KEY

Promotes one variant to the whole rollout and records who decided.

It rewrites the assignment flag so the named winner serves 100% of the rollout and every other arm 0%, preserving the flag's targeting groups and payloads, then stamps the experiment decided with the winner, the deciding credential and the time. This is a production behaviour change that takes effect immediately for every subject the flag evaluates.

It requires an ORG ADMIN of the caller's own org — a stricter gate than the rest of this surface, matching the flags write plane, because promoting is a flag write. The admin check runs AFTER the experiment is found, so a caller from another tenant is answered not-found rather than forbidden and learns nothing about what exists.

An experiment whose assignment flag has gone missing is a conflict rather than a silent no-op — there is nothing to promote.

Deciding is NOT terminal. A second call re-promotes a different variant and re-stamps the row; the status stays decided and the previous winner is overwritten with no record that it was ever chosen. Nothing here reverts the flag to its original weights either, so an experiment cannot be un-decided through this route — restoring a split means writing the flag definition back through the flags plane.

Request

2 fields, body application/json (required).

FieldInTypeRequiredDescription
idpathstringyes
winnerbodystringyesWinner is the variant to promote.

Response

StatusBodyMeaning
200experiment.Trialok
defaultproblem-detailsrefused

200 body — 18 fields.

FieldInTypeAlwaysDescription
createdAtbodystring—when it started assigning
createdBybodystring—the credential that registered it
decidedAtbodystring—when the promotion took effect
decidedBybodystring—the credential that promoted the winner
exposureEventbodystring—the event that enrols a subject — the analysis denominator
flagKeybodystring—the assignment flag this experiment drives
idbodystring—the experiment's slug, unique within the project
metricEventbodystring—the event that counts as a conversion — the numerator
namebodystring—free text for a reader
projectbodystring—the sub-scope within the org, stamped from the principal
statusbodystring—running while it assigns and measures, decided once a winner is promoted
subjectKindbodystring—the unit assigned and measured: user, org, session or audience
variantsbodyexperiment.Arm[]—the arms, weighted, one of them the control
variants[].controlbodyboolean—true on the baseline arm every other arm is compared to
variants[].keybodystring—the arm's slug, unique within the experiment
variants[].payloadbodyany—opaque JSON the arm carries, which the consumer interprets
variants[].weightbodynumber (double)—its share of the rollout; the arms sum to 100
winnerbodystring—the arm promoted to the whole rollout

Failure carries the platform error shape — see Errors.

Examples

hanzo experiment decide <id> --winner <winner>
import { Configuration, ExperimentApi } from 'hanzoai';

const api = new ExperimentApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postExperimentByIdDecide({ id: 'id', winner: "<winner>" });
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import ExperimentApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = ExperimentApi(client).post_experiment_by_id_decide(id='id', winner="<winner>")
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.ExperimentAPI.PostExperimentByIdDecide(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, experiment_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = experiment_api::post_experiment_by_id_decide(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.ExperimentApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new ExperimentApi(client).postExperimentByIdDecide();
curl -X POST https://api.hanzo.ai/v1/experiment/<id>/decide \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "winner": "<winner>"
     }'

MCP reaches experiment through the experiment tool, which names its 7 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_experiments"
         }
       }
     }'

Experiment API · All Hanzo APIs · Interactive reference

Was this page useful?