Analytics Conversations Aggregates query returning empty results for custom intervals

What is the standard approach to build a custom interval report using the Analytics Conversations Aggregates query? i’m trying to fetch data for a specific time range in my python fastapi service but the response is always empty.

the docs say: “The from and to fields must be specified in the request body.” i’m sending this payload via requests.post:

{
 "from": "2023-10-01T00:00:00.000Z",
 "to": "2023-10-02T00:00:00.000Z",
 "groupBy": "conversationId",
 "interval": "PT1H",
 "filters": {
 "and": [
 {
 "field": "direction",
 "op": "equals",
 "value": "inbound"
 }
 ]
 }
}

the endpoint is /api/v2/analytics/conversations/aggregate. i get a 200 ok but the data array is empty. the token has the analytics:read scope.

i’ve checked the timezone settings in the org. everything looks fine. is there something wrong with the interval format? the docs mention ISO 8601 durations. PT1H should be correct.

also, the groupBy field. the docs say: “Valid values are: conversationId, queueId, skillId.” i’m using conversationId.

any ideas why it’s not returning anything? the date range is definitely in the past. i’m running this on python 3.11 with requests 2.31.0.

The best way to fix this is…

“i’m trying to fetch data for a specific time range in my python fastapi service but the response is always empty.”

hey, i’ve hit this wall before. the issue isn’t your dates, it’s likely the groupBy field. if you don’t specify what you’re aggregating by, the API returns nothing because it doesn’t know how to bucket the data.

in my Ruby middleware, i always explicitely set groupBy to something like queue/id or user/id. also, check your timezone. the API expects UTC. if you’re in India (Asia/Kolkata), make sure you’re converting your local from/to timestamps to UTC before sending.

here’s a working JSON payload structure i use with Faraday:

{
 "from": "2023-10-01T00:00:00.000Z",
 "to": "2023-10-02T00:00:00.000Z",
 "groupBy": ["queue/id"],
 "metrics": ["wrapupTime", "holdTime"]
}

if groupBy is missing, add it. if it’s still empty, try widening the date range to see if there’s any data at all. sometimes the queue just had no calls that day.