Skip to main content

Update Experiment

Endpoint

/i/ab-testing/update-experiment

Enterprise Only
This API is available exclusively in Countly Enterprise.

Overview

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

Authentication

Authentication Methods:

  • API Key (parameter): api_key=YOUR_API_KEY
  • Auth Token (parameter): auth_token=YOUR_AUTH_TOKEN
  • Auth Token (header): countly-token: YOUR_AUTH_TOKEN

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)

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/Processing

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

Database Collections

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

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:

{}

Ⓔ Enterprise

This feature is part of Countly Enterprise.

Get Access:

Already a Customer? Use support portal if you have any questions


Last Updated

2026-02-16