Opt Out from Experiments
Endpoint
/i?method=ab_opt_out
Ⓔ Enterprise Only
This API is available exclusively in Countly Enterprise.
Overview
Opt a user out of specific running experiments or all running experiments. When opting out of specific experiments, the API removes the user from experiments that contain any of the provided parameter keys.
Authentication
Authentication Methods:
- App Key (parameter):
app_key=YOUR_APP_KEY
Permissions
- No additional permissions required
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
app_key | String | Yes | Application key |
device_id | String | Yes | Device identifier for the user |
keys | String | No | JSON array of parameter keys to opt out from specific experiments |
Response
Success Response
{
"result": "Success"
}
Response Fields
| Field | Type | Description |
|---|---|---|
result | String | Result message |
Error Responses
- Missing user:
{
"result": "No uid"
}
Behavior/Processing
- Dispatches from
/ito the SDK ingestion handler whenmethod=ab_opt_out. - Requires the SDK request context to resolve an app user with
uid; otherwise returnsNo uid. - If
keysis a valid JSON array, fetches running experiments and finds experiments whose variants contain any parameter name fromkeys. - For matched experiments, removes matching
{experiment_id}entries fromapp_users{appId}.ab. Duplicate experiment IDs are de-duplicated before updates. - If
keysis missing, invalid JSON, or not an array, the endpoint opts the user out of all experiments by unsetting the wholeabfield. - Filtering only considers experiments with
status=running.
Database Collections
| Collection | Used for | Data touched by this endpoint |
|---|---|---|
countly.app_users{appId} | Primary: | Stores user experiment assignments. |
countly_out.ab_testing_experiments{appId} | Related: | Used to resolve experiments when filtering by keys. |
Examples
Example 1: Opt Out of All Experiments
Request:
curl "https://your-server.com/i?method=ab_opt_out" \
-d "app_key=YOUR_APP_KEY" \
-d "device_id=DEVICE_ID"
Example 2: Opt Out of Specific Parameter Keys
Request:
curl "https://your-server.com/i?method=ab_opt_out" \
-d "app_key=YOUR_APP_KEY" \
-d "device_id=DEVICE_ID" \
-d 'keys=["button_text","header_text"]'
Related Endpoints
Ⓔ Enterprise
This feature is part of Countly Enterprise.
Get Access:
Already a Customer? Use support portal if you have any questions
Last Updated
2026-04-18