Analytics Aggregates POST returning 400 on interval grouping

Trying to spin up a custom interval report against the /api/v2/analytics/conversations/aggregates endpoint. the goal is just to grab conversation counts grouped by 15-minute buckets over the last 48 hours. sending a POST with this payload:

{
 "queryType": "conversation",
 "interval": "PT15M",
 "dateFrom": "2023-10-25T12:00:00Z",
 "dateTo": "2023-10-27T12:00:00Z",
 "groupings": [{"type": "interval"}],
 "aggregations": [{"type": "count"}],
 "selectionCriteria": {"selectors": [{"type": "conversation", "predicate": "mediaType==voice"}]}
}

getting a 400 back every time. the response body claims Invalid interval format even though PT15M matches the spec. it’s weird because the swagger docs show exactly that format. tried swapping to PT1H just to test, same error. also noticed if i drop the selectionCriteria entirely it actually works, but then i’m pulling in every single interaction type which bloats the lambda memory way too fast.

anyone else hit this when filtering for just voice conversations? the predicate field in the docs is pretty vague on what the actual filter string should look like. i’ve been guessing at mediaType==voice but that might be breaking the parser. the interval error feels like a red herring since it only triggers when the selector is attached. just need the exact syntax for the selector predicate that plays nice with interval grouping. the docs are missing the actual examples again.

{
 "interval": "PT15M",
 "groupings": [{"type": "interval"}]
}

make sure those dateFrom and dateTo fields are ISO 8601 with the Z suffix. the api is strict about that. also check if your org has the analytics tier enabled for custom intervals. sometimes it defaults to hourly if the license isn’t right.

the payload looks mostly fine but check the aggregations array. if it’s cut off or empty, the api throws a 400.

also, PT15M is valid but the analytics engine can be picky about the grouping type. try switching groupings to:

"groupings": [{"type": "interval", "resolution": "PT15M"}]

sometimes the endpoint expects the resolution inside the grouping object rather than as a top-level field. if that doesn’t fix it, verify the user making the request has the analytics:view permission. missing perms often return generic 400s instead of 403s in older api versions.

thanks for the catch on the resolution field. adding that to the grouping object fixed the 400 error. weird that the docs don’t show it as required. also made sure the aggregations array had a valid type. working now.

Cause: the top-level interval field is ignored when groupings are present.
Solution: remove it and pass resolution inside the grouping object like this:

"groupings": [{"type": "interval", "resolution": "PT15M"}]