Skip to main content

Get Cohort Processing State

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

Overview

Retrieves the current processing state and status of a cohort. Shows whether cohort is actively recalculating, completed, or has errors. Useful for monitoring long-running cohort calculations.

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
cohortStringNoOptional; not used by current handler branch

Examples

Example 1: Check cohort calculation state

Request:

curl -X GET "https://your-server.com/o?method=cohortstate" \
-d "api_key=YOUR_API_KEY" \
-d "app_id=YOUR_APP_ID"

Response

Success Response

{
"hashes": {
"a4f...": {
"data": {},
"cid": ["cohort123"]
}
},
"cohorts": {
"cohort123": {
"_id": "cohort123",
"name": "High Value Users"
}
},
"ts": 1739630000
}

Response Fields

FieldTypeDescription
hashesObjectStep/signature map used for cohort membership evaluation.
cohortsObjectCohort definitions map keyed by cohort ID.
tsNumberCached snapshot timestamp (unix seconds).

Error Responses

No explicit returnMessage(...) path in this branch.

Behavior

  • Validates read permission for cohorts feature.
  • Returns the current cached cohort configuration from cohorts.getCurrentCohortConfig(...).
  • Output contains hash maps used by cohort processors plus cache timestamp metadata.

Notes

  • This endpoint returns configuration/cache state, not a single cohort progress percentage.

Limitations

  • Does not show per-cohort progress percentage.
  • Returns snapshot-style config/cache state.

Use Cases

  1. Progress monitoring: Check if cohort is done recalculating
  2. Error checking: Identify why cohort calculation failed
  3. Scheduling: Determine when to fetch updated cohort data
  4. UI status: Show cohort state (loading/ready) in interface
  5. Health check: Verify cohort is in healthy state
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.cohortsCollection:Source of state information

Database Collections

  • countly.cohorts - Stores cohort processing state and status