Skip to main content
POST
Register a Retention Query

Authorizations

Authorization
string
header
required

Authentication is done via Basic Auth. This requires a base64-encoded string of your credentials in the format username:password.

  • Username: Use your MoEngage workspace ID (also known as the App ID). You can find it in the MoEngage dashboard at Settings > Account > APIs > Workspace ID (earlier app id).
  • Password: Use your Data API Key, which you can find in the MoEngage dashboard at Settings > Account > APIs.

For more information, see Authentication.

Body

application/json

Request body for registering a Retention analysis query.

type
enum<string>
required

The analysis type. Must be retention for this endpoint.

Available options:
retention
events
object[]
required

Exactly two events: the first event that places a user into a cohort, and the return event measured in later periods.

Required array length: 2 elements
timerange
object
required

The time window the analysis runs over.

retention_type
enum<string>
required

How return events are counted — every (return in every period), first (first return only), or last (last return only).

Available options:
every,
first,
last
version
string

Payload schema version.

Example:

"2.0"

segmentation
object[]

Segments to scope the analysis (up to 5). Segmentation and comparison_timerange are mutually exclusive — do not send 2 or more segments together with a time comparison.

Maximum array length: 5
granularity
enum<string>

Cohort period — h (hourly, window up to 24 hours), d (daily, up to 90 days), or w (weekly, up to 180 days).

Available options:
h,
d,
w
Example:

"d"

chart_type
string

Visual representation of the result, such as line.

Example:

"line"

split_by
object[]

Attributes to break the cohorts down by. Include up to 10.

Maximum array length: 10
comparison_timerange
object

A second time range to compare against. Mutually exclusive with sending 2 or more segments. Pass an empty object for no comparison.

Response

Query registered. Poll status and fetch results with data.request_id.

Acknowledgement that a query was registered. Use data.request_id to poll status and fetch results.

response_id
string

A unique identifier for the response, useful for correlating logs and support requests.

Example:

"fc803857-632e-4bf0-8df1-fbc2bdeedb66"

type
string

The analysis type echoed back for the registered query.

data
object