Hanzo
OpenapiExperiment

Registers a controlled experiment AND puts its assignment flag live, in that…

Registers a controlled experiment AND puts its assignment flag live, in that order, so the arms start bucketing subjects the moment this returns 201 — the…

POST /v1/experiment

Addresshttps://api.hanzo.ai/v1/experiment
MethodPOST
Operationpost_experiment
AuthAuthorization: Bearer $HANZO_API_KEY

Registers a controlled experiment AND puts its assignment flag live, in that order, so the arms start bucketing subjects the moment this returns 201 — the flag is created active at 100% rollout, with each variant weighted as declared. There is no separate start call; creating IS starting.

A variant carries an opaque payload this primitive never interprets: a feature config, an ad-creative id, a subject line, a model id.

Requires a validated principal, and refuses without one. The org and project are taken from that principal and the creator is stamped from the credential — none of the three is a body field, so an experiment cannot be filed against another tenant. An id already used in this project is a conflict, never a silent overwrite: re-creating would stomp the assignment flag of a run in progress.

It fails closed on the flag write. An experiment whose assignment flag does not exist would assign nobody, so if that write fails nothing is registered.

Request

11 fields, body application/json (required).

FieldInTypeRequiredDescription
exposureEventbodystringExposureEvent is the event that marks a subject as enrolled — the analysis denominator — defaulting to the SDK's $feature_flag_called marker.
flagKeybodystringFlagKey names the assignment flag this experiment writes, defaulting to exp_<id>.
idbodystringyesID is the experiment's slug, claimed once per project.
metricEventbodystringyesMetricEvent is the event that counts as a conversion — the analysis numerator.
namebodystringName is free text for a reader; the id is what addresses the experiment.
subjectKindbodystringSubjectKind is the unit assigned and measured: user (the default), org, session or audience.
variantsbodyArm[]yesArms are the arms, at least two.
variants[].controlbodybooleantrue on the baseline arm every other arm is compared to
variants[].keybodystringthe arm's slug, unique within the experiment
variants[].payloadbodyanyopaque JSON the arm carries, which the consumer interprets
variants[].weightbodynumberits share of the rollout; the arms sum to 100

Response

StatusBodyMeaning
201Trialcreated

201 body — 18 fields.

FieldInTypeAlwaysDescription
createdAtbodystringwhen it started assigning
createdBybodystringthe credential that registered it
decidedAtbodystringwhen the promotion took effect
decidedBybodystringthe credential that promoted the winner
exposureEventbodystringthe event that enrols a subject — the analysis denominator
flagKeybodystringthe assignment flag this experiment drives
idbodystringthe experiment's slug, unique within the project
metricEventbodystringthe event that counts as a conversion — the numerator
namebodystringfree text for a reader
projectbodystringthe sub-scope within the org, stamped from the principal
statusbodystringrunning while it assigns and measures, decided once a winner is promoted
subjectKindbodystringthe unit assigned and measured: user, org, session or audience
variantsbodyArm[]the arms, weighted, one of them the control
variants[].controlbodybooleantrue on the baseline arm every other arm is compared to
variants[].keybodystringthe arm's slug, unique within the experiment
variants[].payloadbodyanyopaque JSON the arm carries, which the consumer interprets
variants[].weightbodynumberits share of the rollout; the arms sum to 100
winnerbodystringthe arm promoted to the whole rollout

Failure carries the platform error shape — see Errors.

Examples

hanzo experiments create \
  --id <id> \
  --metric-event <metricEvent> \
  --variants '[{"control":false,"key":"<key>","payload":"<payload>","weight":0}]'

Experiment API · All Hanzo APIs · Interactive reference

How is this guide?

On this page