Skip to main content
Version: 25.03

Cohorts - Read Cohort Results

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?method=cohort

Overview​

Returns the calculated results of a cohort. Depending on the cohort type and the generate parameter, results are read from the stored cache or calculated in a background task.

Authentication​

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

Permissions​

Requires cohorts Read permission.

Request Parameters​

ParameterTypeRequiredDescription
methodStringYesMust be cohort.
app_idStringYesApplication ID.
cohortStringYesCohort ID.
manualBoolean/StringNoWhen set, the application ID is appended to cohort to build the cohort ID.
generateBoolean/StringNoWhen set for a non-manual cohort, the results are calculated instead of read from the cache. Ignored when real-time cohorts are enabled.
save_reportBoolean/StringNoWith generate, keeps the calculation as a saved report.
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.

Examples​

Read cached results of a cohort​

/o?method=cohort&
app_id=6991c75b024cb89cdc04efd2&
api_key=YOUR_API_KEY&
cohort=65f0cbf8bca6b8e8fbf7f901

Calculate the results​

/o?method=cohort&
app_id=6991c75b024cb89cdc04efd2&
api_key=YOUR_API_KEY&
cohort=65f0cbf8bca6b8e8fbf7f901&
generate=true

Response​

Success Response​

The cohort's stored results are returned as the response body. When the results are being calculated in a background task, a task reference is returned instead:

{
"task_id": "65f1f7b2ad5b9b001f12ab34"
}

An empty array ([]) is returned if the server has no Drill database connection.

Error Responses​

  • 400
{
"result": "Missing request parameter: cohort"
}
  • 400
{
"result": "Requested cohort does not exist"
}
  • 406
{
"result": "Cannot get cohort results"
}

Behavior​

Behavior Modes​

ModeConditionResult
Cached readReal-time cohorts are enabled, generate is not set, or the cohort is manualReturns the stored results of the cohort.
Calculationgenerate is set, real-time cohorts are disabled, and the cohort is not manualCalculates the results in a background task. Returns the task_id of a task that is already running for the same request.