Skip to main content

Quickstart: Create and Launch an Experiment

This guide walks you through the full experiment lifecycle using the Mida API — from creation to reading results. Copy-paste the curl commands and replace the placeholder values.

You'll need:

  • Your Project Key — from Dashboard → Settings → API
  • Your API Key — from Dashboard → Settings → API Keys
  • Your regionus or eu

Step 1 — Create the experiment

Create an experiment in status 9 (draft). The experiment is saved but not yet running.

curl --request POST \
--url "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/create-experiment" \
--header "Authorization: Bearer YOUR_GENERATED_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"test_name": "Homepage CTA Button Color Test",
"url": "https://example.com/",
"variants": [
{
"name": "Control",
"data": []
},
{
"name": "Red CTA Button",
"customCSS": ".cta-button { background-color: #FF5733 !important; color: #fff !important; }",
"customJS": "",
"data": []
}
],
"primary_goal": {
"goal_name": "CTA Button Click",
"goal_type": "clickOnElement",
"goal_value": ".cta-button"
},
"configuration": {
"traffic_allocation": 100,
"confidence_interval": 95
}
}'

Response:

{
"success": true,
"status": 9,
"test_id": 28222,
"company_id": 1001,
"goal_profile_id": 8936,
"secondary_goals_count": 0,
"warnings": []
}

Save the test_id — you'll use it in every subsequent step.

Variants explained
  • The first variant is always the Control (the original, unmodified page). Its data array must be empty.
  • Add one object per variant you want to test. Use customCSS and/or customJS to inject changes.
  • data: [] is required on every variant (even if empty). It holds visual editor DOM changes.

Step 2 — Launch the experiment

Set status to 1 (live) to begin splitting traffic between variants.

curl --request PATCH \
--url "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/experiment/28222/status" \
--header "Authorization: Bearer YOUR_GENERATED_API_KEY" \
--header "Content-Type: application/json" \
--data '{"status": 1}'

Response:

{
"success": true,
"test_id": 28222,
"status": 1
}

The experiment is now live. Visitors to the test URL will be split between Control and your variant.


Step 3 — Check results

After visitors have arrived and conversions have been tracked, retrieve per-variant results:

curl "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/experiment/28222/result" \
-H "Authorization: Bearer YOUR_GENERATED_API_KEY"

Response:

{
"success": true,
"test_id": 28222,
"test_name": "Homepage CTA Button Color Test",
"status": 1,
"days_running": 7,
"total_visitors": 2980,
"total_conversions": 268,
"variants": [
{
"variant_id": "0",
"name": "Control",
"visitors": 1500,
"conversions": 120,
"conversion_rate": 8.0,
"is_control": true
},
{
"variant_id": "1",
"name": "Red CTA Button",
"visitors": 1480,
"conversions": 148,
"conversion_rate": 10.0,
"improvement": 25.0,
"is_control": false
}
]
}

The improvement field shows relative lift vs the control. Here, the Red CTA Button variant converts 25% better than Control.


Step 4 — Deactivate the experiment

When you have a winner, deactivate the experiment with status 0:

curl --request PATCH \
--url "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/experiment/28222/status" \
--header "Authorization: Bearer YOUR_GENERATED_API_KEY" \
--header "Content-Type: application/json" \
--data '{"status": 0}'
Reactivating

Setting status 0 stops data collection but preserves all results. You can restart the experiment at any time by setting status back to 1.


Common patterns

Filter results by date range

curl "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/experiment/28222/result?start_date=2024-01-15&end_date=2024-02-15" \
-H "Authorization: Bearer YOUR_GENERATED_API_KEY"

Create experiment with a pre-existing goal

If you've already created a goal and have its key, reference it directly:

--data '{
"test_name": "Pricing Page Headline Test",
"url": "https://example.com/pricing",
"variants": [
{ "name": "Control", "data": [] },
{ "name": "Variant 1", "customCSS": "h1 { font-size: 2.5rem; }", "data": [] }
],
"primary_goal_key": "cta_button_click"
}'

Create experiment and launch immediately

Pass "status": 1 in the create request to skip the draft step:

--data '{
"test_name": "Homepage Hero Test",
"status": 1,
"url": "https://example.com/",
"variants": [...]
}'

Prevent duplicate experiments (idempotency)

Pass a unique idempotency_key to safely retry without creating duplicates. Same key returns the original response for 24 hours:

--data '{
...
"idempotency_key": "deploy-2026-04-01-homepage-cta"
}'

Status codes reference

CodeMeaning
9Draft — saved, not running
1Live — actively running
0Inactive — stopped, data preserved, can be restarted

Goal types reference

When setting a primary_goal inline, use one of these goal_type values:

goal_typeWhat it tracksgoal_value example
clickOnElementClick on a CSS selector.buy-btn
clickOnTextClick on an element with matching textAdd to cart
formSubmitForm submissionform#signup
pageviewURL partial match/thank-you
pageviewExactExact URL matchhttps://example.com/thank-you
pageviewWildcardURL with * wildcards/products/*/confirm
pageviewRegexRegex URL pattern^/checkout/.+/success$
scriptCustom JS event triggerpurchase_complete

What's next