Skip to main content

Get Specific Experiments

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

/o/ab-testing/experiment

Overview

Retrieve multiple experiment definitions by their ObjectIds.

Authentication

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

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

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"
}
]

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

  • 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.

Limitations

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

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.