Analytics API aggregation query failing on queue/media type grouping

I’m trying to pull historical metrics from the Analytics API, specifically grouping by queue and media type. The endpoint is GET /api/v2/analytics/conversations/details/query.

Here’s the payload I’m sending:

{
 "dateRange": {
 "startDate": "2023-10-01T00:00:00.000Z",
 "endDate": "2023-10-02T00:00:00.000Z"
 },
 "groupings": [
 {
 "groupBy": "queue",
 "subGroupBy": "mediaType"
 }
 ],
 "metrics": [
 "totalHandled",
 "totalAbandoned"
 ]
}

The request comes back with a 400 Bad Request. The error message is vague: Invalid grouping configuration. I’ve checked the Swagger docs, and queue and mediaType are listed as valid group-by values for conversation details.

I’ve tried swapping the order of the groupings, but it makes no difference. I’ve also tried using the filter parameter to isolate a single queue, but the same error persists.

Is there a known limitation on nested groupings in the v2 analytics API? Or am I missing a required field in the grouping object? I’m using the Python SDK, but the raw HTTP call fails too, so I don’t think it’s an SDK issue.

You’re hitting the standard date range limit. The details endpoint caps queries at 24 hours, so your October 1st to 2nd range is too wide for a single request. You’ll need to split the dateRange into smaller chunks or switch to the summary endpoint if you just need aggregates.

Here is how the payload should look for a valid 24-hour window. Make sure the metrics array is complete and the groupings match the API schema exactly.

{
 "dateRange": {
 "startDate": "2023-10-01T00:00:00.000Z",
 "endDate": "2023-10-01T23:59:59.999Z"
 },
 "groupings": [
 {
 "groupBy": "queue",
 "subGroupBy": "mediaType"
 }
 ],
 "metrics": [
 "totalHandled",
 "totalAbandoned"
 ]
}