Skip to main content

Update Experiment

PATCH/v2/project/{project_key}/experiment/{test_id}

Update an experiment's name, URL, variants, configuration, custom code, or targeting. Only fields you include are changed; all other fields remain unchanged.

Path parameters

ParameterDescription
project_keyYour project's API key
test_idThe numeric experiment ID

Updatable fields

FieldTypeDescription
test_namestringNew display name for the experiment
urlstringChange the test page URL
variantsarrayReplace treatment variant definitions using the same shape as Create Experiment
controlobjectUpdate Control nickname/custom JS/custom CSS helper fields
control_attrobject/stringRaw Control attributes (name, js, css) if you are not using control
custom_jsstringExperiment-wide JavaScript applied to all assigned visitors, including Control
custom_cssstringExperiment-wide CSS applied to all assigned visitors, including Control
configurationobjectUpdate traffic, statistics, automation, or trigger settings
targetingobjectUpdate experiment-level targeting rules
tagsarrayExperiment tags for organization

Partial updates are shallow at the top level: omit a top-level field to leave it unchanged. When you send arrays such as variants, tags, or grouped targeting rules, the provided array becomes the new value for that field.

Variants and Control

Use the same variant rules as Create Experiment:

  • Do not include Control in variants.
  • Treatment names must be exact fixed strings: Variant 1, Variant 2, and so on, aligned with array position.
  • Use nickname for human-friendly labels.
  • Use variants[].customJS / variants[].customCSS for variant-specific code.
  • Use top-level custom_js / custom_css for experiment-wide code.
  • Use control or control_attr for Control-specific nickname/code.
{
"variants": [
{
"name": "Variant 1",
"nickname": "Red CTA Button",
"customCSS": ".cta-button { background-color: #FF5733 !important; color: #fff !important; }",
"customJS": "",
"data": []
}
],
"control": {
"nickname": "Original CTA",
"customJS": "",
"customCSS": ""
}
}

Configuration fields

FieldTypeDescription
traffic_allocationintegerPercentage of visitors included in the test. 0100.
confidence_intervalintegerStatistical confidence threshold. Typically 95.
start_test_datestringAuto-start date in ISO 8601 format.
end_test_datestringAuto-end date in ISO 8601 format.
is_mabinteger1 enables Multi-Armed Bandit mode.
is_autopilotinteger1 enables autopilot traffic allocation.
distributionobject/stringVariant traffic distribution settings.
bayesianinteger1 for Bayesian statistics, 0 for frequentist.
dom_change_pathstringDOM change execution mode.
trigger_variant_changestringWhen variant code should execute on dynamic/SPAs.
completion_visitorintegerStop when this many unique visitors have entered.
completion_conversionintegerStop when this many conversions have been tracked.
completion_stats_significant_flaginteger1 = stop when statistical significance is reached.
completion_after_periodintegerStop after this many days.
integrationarrayConnected integrations to receive experiment data.

Targeting fields

Use the same public targeting keys as Create Experiment. Top-level targeting applies to the whole experiment; variants[].targeting applies only to personalization variants.

Common keys include referral_rule, allowed_country, allowed_region, allowed_city, device_rule, browser_rule, os_rule, user_rule, browser_language_rule, segment_rule, event_rule, parameter_rule, ga4_rule, cookie_rule, schedule_rule, and experiment-only url_rule.

cookie_rule and schedule_rule are browser-runtime rules. Server-side SDK experiments cannot enforce them.

Example: reduce traffic allocation

curl -X PATCH "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/experiment/1234" \
-H "Authorization: Bearer YOUR_GENERATED_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"configuration": {
"traffic_allocation": 50
}
}'

Example: target desktop visitors only

curl -X PATCH "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/experiment/1234" \
-H "Authorization: Bearer YOUR_GENERATED_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"targeting": {
"device_rule": ["desktop"]
}
}'

Example: update targeting with parameters

curl -X PATCH "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/experiment/1234" \
-H "Authorization: Bearer YOUR_GENERATED_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"targeting": {
"allowed_country": [
{ "name": "United States", "code": "US", "rule": "whitelist" }
],
"parameter_rule": [
[
{ "criteria": "utm_campaign", "operator": "==", "value": "spring-sale" }
]
]
}
}'

Example: update a variant

curl -X PATCH "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/experiment/1234" \
-H "Authorization: Bearer YOUR_GENERATED_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"variants": [
{
"name": "Variant 1",
"nickname": "Short headline",
"customJS": "document.querySelector(\"h1\").textContent = \"Start testing faster\";",
"customCSS": "",
"data": []
}
]
}'

Success response

{
"success": true,
"test_id": 1234
}

Error responses

StatusMeaning
400Invalid field values or malformed request body
401Invalid or missing API key
404Experiment not found or belongs to a different project
Updating live experiments

Changing variants, targeting, or traffic allocation on a live experiment can affect assignment and reporting. For major content changes, prefer updating drafts or creating a new experiment.

Next step

To start, pause, or end the experiment, use Update Experiment Status.