I am trying to build a custom reporting widget for our agent desktop using the Embeddable Client App SDK. The goal is to fetch interval data for conversation duration over the last hour. I am using the POST /api/v2/analytics/conversations/aggregates endpoint.
Here is the JSON payload I am sending:
{
"interval": "PT1H",
"dateFrom": "2023-10-27T10:00:00.000Z",
"dateTo": "2023-10-27T11:00:00.000Z",
"groupings": [
{
"id": "mediaType",
"type": "string"
}
],
"select": [
{
"id": "duration",
"type": "sum"
}
],
"where": {
"id": "mediaType",
"type": "string",
"value": "voice"
}
}
The response is a 400 Bad Request with this body:
{
"code": "bad_request",
"message": "Invalid query",
"status": 400
}
I have checked the documentation and the field names look correct. The interval is ISO 8601 duration format. The dateFrom and dateTo are ISO 8601 timestamps. I am using the same OAuth token that works for other endpoints like /api/v2/users/me.
Is there something wrong with the where clause structure? Or maybe the select array format? I have tried removing the where clause but it still fails. The error message is not helpful. I don’t know what part of the query is invalid.
Any ideas?