Skip to main content

Get Specific Experiments

Endpoint

/o/ab-testing/experiment

Enterprise Only
This API is available exclusively in Countly Enterprise.

Overview

Retrieve multiple experiment definitions by their ObjectIds.

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

  • Read (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 ID
experimentsString (JSON)YesJSON array of experiment IDs

Response

Success Response

[
{
"_id": "6991caa6024cb89cdc04eff5",
"name": "Pricing1",
"description": "TestPricing",
"target_users": {
"percentage": 100,
"condition": "{}"
},
"variants": [
{
"name": "Control group",
"parameters": [
{
"name": "Pricing1",
"value": "5000/month"
}
]
},
{
"name": "Variant A",
"parameters": [
{
"name": "Pricing1",
"value": "10000/month"
}
]
}
],
"status": "running"
}
]

Response Fields

FieldTypeDescription
[]ArrayExperiment documents matching the requested IDs
[].nameStringExperiment name
[].variantsArrayVariant definitions with parameter values
[].statusStringExperiment status

Error Responses

  • If parsing experiments fails, the handler continues with an empty ID list and returns [].
  • If no matching IDs are found, returns [].

Behavior/Processing

  • Parses experiments as JSON and converts each ID to an ObjectID.
  • Fetches experiment documents from countly_out.ab_testing_experiments{appId}.
  • Returns an empty array if none are found.

Database Collections

CollectionUsed forData touched by this endpoint
countly_out.ab_testing_experiments{appId}Endpoint data sourceStores endpoint-related records this endpoint reads or modifies.

Examples

Example 1: Read two experiments

Request:

curl "https://your-server.com/o/ab-testing/experiment?app_id=YOUR_APP_ID&experiments=[\"EXPERIMENT_ID_1\",\"EXPERIMENT_ID_2\"]&api_key=YOUR_API_KEY"

Response:

[
{
"_id": "6991caa6024cb89cdc04eff5",
"name": "Pricing1",
"status": "running"
}
]

Limitations

  • experiments must be valid JSON. Invalid JSON returns an empty result.
  • Batch experiment IDs to reduce network overhead.

Ⓔ 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