Create an A/B experiment
Create an A/B experiment on this agent.
Create an A/B experiment on this agent.
The agent in the path is the control; variant_agent_id names the
challenger. Both must already exist in your organisation, and they must
be different agents — sending the same id for both is a 400.
The experiment is created at status draft and routes no traffic until
you activate it with PATCH ... {"status": "active"}. Only one experiment
per control agent may be ACTIVE at a time; the second activation is a 409.
variant_traffic_pct defaults to 50, i.e. an even split once active.
Create never conflicts. A new experiment is always a draft and no
active-count check applies, so 409 is not a possible outcome here — it only
appears on PATCH and DELETE.
Rate limit: 1000 requests per minute per organization (bucket default). Exceeding it returns 429 with Retry-After; the X-RateLimit-* response headers report your remaining allowance on every call.
v2/agents/{agent_id}/versionsAuthorization
AuthorizationRequiredBearer <token>
Your Graine API key. Create one in the dashboard under Developers, or via POST /v2/api-keys. Send it as Authorization: Bearer <key>.
In: header
Request Body
application/jsonRequiredvariant_agent_idRequiredVariant Agent Id
The challenger agent. Must already exist in this organisation and must differ from the control agent.
1version_nameRequiredVersion Name
Experiment name, 1-100 characters.
1Maximum length: 100main_agent_idMain Agent Id | null
Optional echo of the control agent in the path. If supplied it must match the path exactly.
descriptionDescription | null
Free-text notes, up to 500 characters.
500variable_testedVariable Tested | null
What is being tested, e.g. 'voice', 'script', 'cadence'.
200variant_traffic_pctVariant Traffic Pct
Percentage of calls routed to the variant once the experiment is ACTIVE. Defaults to an even 50/50 split.
50Minimum: 0Maximum: 100Path Parameters
agent_idRequiredAgent Id
The CONTROL agent. This becomes main_agent_id.
Query Parameters
organization_idOrganization Id
Optional. It must match the organisation the API key belongs to; any other value is rejected.
Response Body
201
The created experiment, at status 'draft'.
version_idRequiredVersion Id
Experiment identifier.
main_agent_idRequiredMain Agent Id
The CONTROL agent. Always equal to the agent_id in the path.
variant_agent_idRequiredVariant Agent Id
The CHALLENGER agent that receives the split traffic.
version_nameRequiredVersion Name
Experiment name.
descriptionDescription | null
Free-text notes about the experiment.
variable_testedVariable Tested | null
What is being tested, e.g. 'voice', 'script', 'cadence'.
variant_traffic_pctRequiredVariant Traffic Pct
Percentage of calls routed to the variant (0-100). The remainder goes to the control agent. 0 pauses the variant in place; 100 promotes it.
statusRequiredStatus
draft | active | paused | concluded
winnerWinner | null
control | variant. Only ever set on a concluded experiment.
start_dateStart Date | null
ISO-8601 UTC. Informational; it does not gate routing.
end_dateEnd Date | null
ISO-8601 UTC. Informational; it does not gate routing.
created_byCreated By | null
Identifier of whoever created the experiment.
created_atCreated At | null
ISO-8601 UTC.
updated_atUpdated At | null
ISO-8601 UTC.
400
1000 — malformed or contradictory input: an unknown status token, an empty patch body, an explicit null, or a variant agent that does not exist in this organisation.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
401
1100 — missing, unknown or inactive API key. 1101 — a browser session token was presented.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
403
1102 — the key is valid but lacks the scope this endpoint requires, or names another organisation. GET /v2/scopes reports which scopes the key holds.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
404
1200 — no such agent, or no such version for that agent, in this organisation. Cross-tenant reads answer 404, never 403, so ids cannot be probed.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
422
1001 — the body or query failed validation; the message names the first offending field.
errorRequiredinteger
Stable integer code from the error table. Branch on this, not on the message.
messageRequiredstring
One human-readable sentence. Wording may change; the code will not.
429
1300 — per-organisation rate limit exceeded. Carries Retry-After.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
503
1501 — the agent service is unreachable or returned a 5xx.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
504
1502 — the agent service did not respond in time.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
The created experiment, at status 'draft'.

