Analytics API aggregation query returning 400 when grouping by queue and media type

Trying to build a report that groups interaction data by both queue and media type. I’m using the POST endpoint /api/v2/analytics/conversations/details/query because GET doesn’t support the complex aggregation I need.

Here is the JSON payload I’m sending in the request body:

{
 "dateFrom": "2023-10-01T00:00:00.000Z",
 "dateTo": "2023-10-02T00:00:00.000Z",
 "groupBy": ["queue.id", "mediaType"],
 "aggregations": [
 {
 "type": "count",
 "name": "totalInteractions"
 }
 ],
 "filter": {
 "type": "AND",
 "filters": [
 {
 "type": "EQUALS",
 "field": "mediaType",
 "values": ["voice", "chat"]
 }
 ]
 }
}

The API returns a 400 Bad Request. The error message in the response body is vague: Invalid aggregation query. I’ve checked the field names against the schema docs. queue.id and mediaType seem correct for the groupBy array.

I tried removing mediaType from the groupBy list. When I only group by queue.id, the query works fine. Adding mediaType breaks it. Is there a restriction on mixing entity IDs with simple string fields in the aggregation? Or am I missing a required parameter for multi-dimensional grouping?

{
“groupBy”: [“queue.id”],
“aggregations”: [
{
“type”: “count”,
“metric”: “interactions”
}
],
“filters”: [
{
“type”: “eq”,
“field”: “mediaType”,
“value”: “voice”
}
]
}


You can't group by `mediaType` and `queue.id` simultaneously in that endpoint. The API doesn't support multi-dimension aggregation like that. Filter for one media type instead, then run separate queries for voice, chat, etc.

Grouping by queue.id and mediaType directly in the groupBy array usually fails because the API expects specific metric paths, not just raw field names. The suggestion to filter and run separate queries works, but it’s inefficient if you need a unified view.

Try using the metrics array with explicit paths instead. You can aggregate across media types by defining the metric properly. Here is a working payload structure:

{
 "dateFrom": "2023-10-01T00:00:00.000Z",
 "dateTo": "2023-10-02T00:00:00.000Z",
 "groupBy": ["queue.id"],
 "metrics": [
 {
 "id": "interactions",
 "filter": {
 "type": "eq",
 "field": "mediaType",
 "value": "voice"
 }
 },
 {
 "id": "interactions_chat",
 "filter": {
 "type": "eq",
 "field": "mediaType",
 "value": "webchat"
 }
 }
 ],
 "aggregations": [
 {
 "type": "count",
 "metric": "interactions"
 }
 ]
}

This approach keeps you in a single API call. You’ll get rows per queue, with separate columns for voice and chat counts. It’s cleaner for WFM reporting. The key is defining the metric filters explicitly rather than trying to group by the dimension itself.