Query analytics
Query analytics
Run an analytics query with selected measures, dimensions, filters, and time windows.
POST
Query analytics
Required access
| Authentication | Scope | Dataset grant |
|---|---|---|
| API client v2 | analytics.query | The dataset used in the request body, such as tickets, messages, outbound_messages, marketing_attribution, csat, or workforce_activity. |
Body
Dataset to query. For example,
tickets, messages, outbound_messages, marketing_attribution, csat, or workforce_activity.Measures to calculate. For example,
["ticket_count", "open_ticket_count"] for the tickets dataset or ["message_count", "customer_message_count"] for the messages dataset.Optional dimensions to group results. For example,
["channel_kind"], ["priority"], or ["day_of_week", "hour_of_day"].Optional filter object. For example,
{ "channel_ids": ["<channel_id>"], "statuses": ["open"] }. For channel, agent, pilot, team, or workspace IDs, see Resource IDs.Optional time window. Include this for trend queries or date-bounded summaries.
ISO start timestamp. For example,
2026-05-01T00:00:00.000Z.ISO end timestamp. For example,
2026-05-29T23:59:59.999Z.Timezone used to interpret the time window. For example,
Asia/Kolkata or UTC.Time grain for grouped trend results. Use
day, week, or month.Timestamp field used for the query window. For example,
created_at, closed_at, message_created_at, sent_at, or order_created_at.Optional business-hours configuration for business-hours duration measures.
Business-hours timezone. For example,
Asia/Kolkata.Local business day start time. For example,
09:00.Local business day end time. For example,
18:00.Working days as weekday numbers. For example,
[1, 2, 3, 4, 5] for Monday through Friday.Response shape. Use
summary for aggregate totals or rows for grouped rows.Optional sort instructions. For example,
[{ "field": "ticket_count", "direction": "desc" }].Field to sort by, usually a requested measure or dimension.
Sort direction. Use
asc or desc.Maximum number of rows to return. For example,
100.Cursor from the previous response when paginating through row results.
Notes
- This endpoint uses API client v2 credentials. See API client v2.