We are trying to build a Terraform module that pulls conversation metrics grouped by both queue ID and media type. The goal is to feed this data into our internal reporting dashboard without relying on the UI export feature.
The endpoint we are hitting is POST /api/v2/analytics/conversations/details/query. We have a working query that groups by queue, but when we add media_type to the group_by array, the API returns a 400 Bad Request.
Here is the JSON payload we are sending:
{
"dateRange": {
"startDate": "2023-10-01T00:00:00Z",
"endDate": "2023-10-02T00:00:00Z"
},
"group_by": [
"queue",
"media_type"
],
"aggregations": [
{
"name": "handle_time",
"type": "AVG"
}
]
}
The error message says that the combination of group_by fields is invalid or unsupported for this specific aggregation type. We have tried changing the aggregation to COUNT and SUM, but the same 400 error persists.
Is there a specific restriction on grouping by media_type alongside queue in this endpoint? Or is there a different query structure required for multi-dimensional grouping? We need this to work for our automated reporting pipeline.