Skip to main content

Get Cohort Member Data

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=cohortdata

Overview

Retrieves member data for one or more specified cohorts. Returns detailed user-level information for users in selected cohorts, including engagement metrics and demographics.

Authentication

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

Permissions

  • Required permission: Read on the cohorts feature

Request Parameters

ParameterTypeRequiredDescription
api_keyStringYes (or auth_token)API key for authentication
auth_tokenStringYes (or api_key)Auth token for authentication
app_idStringYesApplication identifier
cohortsJSON Array StringYesJSON array string of cohort IDs: ["cohort1","cohort2"]
iDisplayStartNumberNoPagination offset (default 0)
iDisplayLengthNumberNoNumber of records per page (default 50)

Examples

Example 1: Read members for specific cohorts

Request:

curl -X GET "https://your-server.com/o?method=cohortdata" \
-d "api_key=YOUR_API_KEY" \
-d "app_id=YOUR_APP_ID" \
-d 'cohorts=["cohort123","cohort456"]' \
-d "iDisplayLength=100"

Response

Success Response

[
{
"_id": "cohort123",
"data": {
"aaData": [{"uid": "user1", "name": "User One"}],
"iTotalRecords": 1050,
"iTotalDisplayRecords": 50
}
}
]

Response Fields

FieldTypeDescription
[]ArrayOne item per requested cohort ID.
_idStringCohort ID in each array item.
dataObjectCohort member data payload in each array item from fetch.getTimeObj('cohortdata', ...).

Error Responses

No explicit returnMessage(...) path in this branch. On lookup/parse issues, it returns an empty array.

Behavior

  • Validates read permission for cohorts feature.
  • Parses cohorts JSON array and loads matching cohort documents.
  • Normalizes period in special cases (yesterday, prevMonth, custom ranges).
  • Runs fetch.getTimeObj('cohortdata', ...) per cohort and returns mapped results.

Available Projections

  • uid - User ID
  • sessions - Total session count
  • events - Total event count
  • last_seen - Last activity timestamp
  • devices - Number of devices
  • location - Geographic location
  • revenue - Total revenue (if enabled)
  • created_at - Account creation date
  • demographics - Age, gender (if available)

Use Cases

  1. Member export: Export cohort members for external use
  2. Correlation analysis: Analyze engagement patterns across cohorts
  3. Audience sampling: Get sample of cohort members
  4. Data validation: Verify members in cohort
  5. Segmented reporting: Generate reports per-cohort
Implementation details

Configuration Impact

SettingDefaultAffectsUser-visible impact
cohorts.*Cohort feature defaultsCohort query/evaluation behavior used by this endpoint.Changes to cohort settings can affect result scope, calculation behavior, or filtering outcomes.
api.*Server API defaultsShared API execution controls (for example processing thresholds/limits).Changes to API-level controls can affect runtime behavior, limits, or response timing for this endpoint.

Database Collections

CollectionUsed forData touched by this endpoint
countly.cohortsEndpoint data sourceStores endpoint-related records this endpoint reads or modifies.
countly.cohortUsersEndpoint data sourceStores endpoint-related records this endpoint reads or modifies.
countly.app_users{app_id}Per-app user profilesStores user-level properties and profile fields affected by this endpoint.