Generally speaking, the group_by interval validation is strict about ISO 8601 duration formats and metric compatibility. The API rejects PT5M if the selected metrics don’t support that granularity or if the format isn’t exactly right.
First, check your metric list. Not all metrics support 5-minute intervals. For example, conversation/count works, but some detailed analytics metrics might only allow 15m, 30m, or 1h. If you’re using a metric that doesn’t support PT5M, the API will throw that exact error.
Second, ensure the interval string is strictly ISO 8601. PT5M is correct for 5 minutes, but sometimes SDKs or query builders mangle this. Try explicitly setting it in the JSON payload.
Here’s a working curl example with a compatible metric:
curl -X POST "https://api.mypurecloud.com/api/v2/analytics/conversations/aggregates/query" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"metrics": ["conversation/count"],
"groupBy": ["interval"],
"interval": "PT5M",
"dateFrom": "2023-10-01T00:00:00.000Z",
"dateTo": "2023-10-01T01:00:00.000Z"
}'
If you’re using the PureCloudPlatformClientV2 SDK, ensure you’re constructing the GroupBy object correctly. In TypeScript, it looks like this:
const groupBy = new platformClient.AnalyticsApi.GroupBy();
groupBy.interval = "PT5M";
Also, verify the dateFrom and dateTo range. If the range is smaller than the interval, the API might reject it. Ensure your time window is at least PT5M wide.
If you’re still hitting the error, try switching to PT15M to confirm the issue is specifically with the 5-minute interval. If PT15M works, then your metric choice is the culprit. Check the metric documentation for supported intervals. Some metrics, especially those involving agent performance, have stricter granularity requirements.
Finally, if you’re building this in Pulumi, ensure you’re not accidentally stringifying the object incorrectly. The payload must be a clean JSON object, not a stringified version of an object. Double-check your Pulumi resource definition for the analytics query.