Skip to main content

Stop 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/stop-experiment

Overview

Stop a running experiment and finalize results. Transitions the experiment to completed status.

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 stop

Examples

Example 1: Stop a Running Experiment

Request:

curl "https://your-server.com/i/ab-testing/stop-experiment" \
-d "api_key=YOUR_API_KEY" \
-d "app_id=YOUR_APP_ID" \
-d "experiment_id=5f9c8a3b4d1e2a001f3b4567"

Response

Success Response

{
"result": "Success"
}

Response Fields

FieldTypeDescription
resultStringResult message

Error Responses

  • HTTP 500 - Failed to stop:
{
"result": "Failed to stop experiment"
}
  • HTTP 400 - Not running yet:
{
"result": "The experiment is not running yet."
}
  • HTTP 400 - Already completed:
{
"result": "The experiment is already complete."
}

Behavior

  • Recalculates results before stopping the experiment.
  • Sets status to completed and stores completed_at timestamp.
  • Stores final results in the experiment document.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly_out.ab_testing_experiments{appId}Primary:Updates status, timestamps, and results.