Skip to main content
Version: 24.05

Update Experiment

Enterprise

This endpoint is part of Countly Enterprise. To get access, contact sales or compare versions. Existing customers can reach the support portal with questions.

Endpoint​

/i/ab-testing/update-experiment

Overview​

Update experiment configuration while in draft status. Running or completed experiments cannot be updated.

Authentication​

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions​

  • Update (ab_testing feature)

Request Parameters​

ParameterTypeRequiredDescription
api_keyStringYes (or use auth_token)API key for authentication
auth_tokenStringYes (or use api_key)Auth token for authentication
app_idStringYesApplication identifier
experiment_idStringYesExperiment ObjectId to update
experimentString (JSON)YesUpdated experiment configuration (same structure as add-experiment)

Examples​

Example 1: Update Experiment Name and Description​

Request:

curl "https://your-server.com/i/ab-testing/update-experiment" \
-d "api_key=YOUR_API_KEY" \
-d "app_id=YOUR_APP_ID" \
-d "experiment_id=5f9c8a3b4d1e2a001f3b4567" \
-d 'experiment={"name":"Updated Button Test","description":"Updated description","variants":[{"name":"Control","parameters":[{"name":"button_color","value":"blue"}]},{"name":"Variant","parameters":[{"name":"button_color","value":"red"}]}],"target_users":{"percentage":"50","condition":"{}"},"goals":[{"steps":[{"type":"did","event":"click_button"}],"user_segmentation":"{}"}]}'

Response:

{}

Response​

Success Response​

{}

Response Fields​

This endpoint returns an empty JSON object on success.

Error Responses​

  • HTTP 400 - Incomplete request:
{
"result": "Incomplete request"
}
  • HTTP 400 - Invalid goals:
{
"result": "Invalid data: goals"
}
  • HTTP 400 - Invalid variant payload:
{
"result": "Invalid parameter in variant Control group"
}
  • HTTP 400 - Referenced remote-config parameter does not exist:
{
"result": "The parameter does not exists"
}
  • HTTP 400 - Can only update drafts:
{
"result": "Only experiment with draft status can be updated"
}
  • HTTP 400 - Generic update failure:
{
"result": "Failed to update experiment"
}

Behavior​

  • Validates experiment structure, variants, and goals.
  • Updates experiment document only when status is drafts.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly_out.ab_testing_experiments{appId}Primary:Updates experiment configuration for draft experiments.