Execute retention query
Execute a retention query: of the users who performed the start event, how many performed the return event N days, weeks or months later. Cohorts are measured forward from the start event: time selects the cohorts (every day, week or month it touches), and returns are counted after it ends. retentionCriteria.returnOn counts a return in window N only (exact, the default) or in window N or any later one (on_or_after). options.display picks the result: a time series or single number at one offset (retentionGroup), or every cohort at every offset (retention_curve, retention_grid). Values that cannot be measured yet are null with state: "pending", never zero.
Secret server key (prefixed gb_sk_) for server-to-server calls. Send it as Authorization: Bearer <key>. Never ship a secret key in a game client.
In: header
Path Parameters
Gamebeast project ID
Header Parameters
Gamebeast environment ID
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X POST "https://example.com/application/0/analytics/v1/queries/retention/execute" \ -H "environment_id: 0" \ -H "Content-Type: application/json" \ -d '{ "time": { "step": "second", "relative": { "step": "second", "value": 0 } }, "metrics": [ { "id": "string", "visible": true, "data": { "name": "string", "type": "event" } }, { "id": "string", "visible": true, "data": { "name": "string", "type": "event" } } ], "retentionCriteria": { "measurement": "retention_rate", "retentionWindow": "day" }, "options": { "display": "retention_curve" } }'{ "series": [ { "time": "string", "value": { "all_users": 0, "retained_users": 0, "retention_rate": 0, "state": "complete", "cohorts": { "counted": 0, "total": 0 }, "retention_rate_delta": 0 }, "breakdowns": { "property1": { "all_users": 0, "retained_users": 0, "retention_rate": 0, "state": "complete", "cohorts": { "counted": 0, "total": 0 }, "retention_rate_delta": 0 }, "property2": { "all_users": 0, "retained_users": 0, "retention_rate": 0, "state": "complete", "cohorts": { "counted": 0, "total": 0 }, "retention_rate_delta": 0 } }, "cached": true, "filled": true } ], "seriesAggregates": { "total": { "minimum": 0, "maximum": 0, "average": 0, "median": 0, "sum": 0 }, "breakdowns": { "property1": { "minimum": 0, "maximum": 0, "average": 0, "median": 0, "sum": 0 }, "property2": { "minimum": 0, "maximum": 0, "average": 0, "median": 0, "sum": 0 } } }, "retention": { "window": "day", "returnOn": "exact", "offsets": [ 0 ], "cohortsTotal": 0, "cohortsComplete": 0, "breakdownGroups": { "shown": 0, "total": 0 } }}