Analytics Aggregates API: 400 Bad Request on interval report query

Hey everyone,

I’m trying to build a custom interval report using the Analytics Conversations Aggregates endpoint. The goal is to pull wrap-up time data in 15-minute buckets for our WFM adherence dashboard. I’ve been staring at the docs for a bit but the query keeps failing.

Here is the JSON body I’m sending to POST /api/v2/analytics/conversations/aggregates:

{
 "dateFrom": "2023-10-01T00:00:00.000Z",
 "dateTo": "2023-10-01T23:59:59.000Z",
 "groupings": [
 {
 "type": "time",
 "interval": "PT15M"
 }
 ],
 "viewId": "conv-all",
 "select": [
 {
 "type": "wrapupTime"
 }
 ]
}

I’m getting a 400 Bad Request back. The error message just says “Invalid query parameters” without much detail. I’ve checked the dateFrom and dateTo formats and they look correct. The viewId is definitely valid since I pulled it from the views endpoint.

  • Endpoint: /api/v2/analytics/conversations/aggregates
  • Method: POST
  • Error: 400 Bad Request
  • Payload: See above

I’ve tried removing the select array to see if that’s the issue, but it still fails. I’ve also tried using wrapUpTime with capital letters. Same result. Is the interval format wrong? Or is there a specific syntax for the select field I’m missing? Any pointers would be great.

You’re missing the interval field. That’s a required parameter for aggregate queries, and without it the service doesn’t know how to bucket your data. Since you want 15-minute chunks, you need to explicitly set that in the payload.

Also, watch out for the granularity field if you’re slicing by time of day, but for standard date ranges interval is usually enough. Here’s how the body should look:

{
 "dateFrom": "2023-10-01T00:00:00.000Z",
 "dateTo": "2023-10-01T01:00:00.000Z",
 "interval": "PT15M",
 "groupings": [
 {
 "type": "date",
 "unit": "HOUR"
 }
 ],
 "metrics": [
 "wrapUpTime"
 ]
}

Make sure your dateTo isn’t too far in the future or you’ll hit the max span limit. Keep the window tight while you’re testing.