{
"code": "bad_request",
"message": "Invalid request body. The metric 'conv.duration' is not supported for the selected interval type 'custom'.",
"status": 400
}
I am trying to build a custom interval report using the Analytics Conversations Aggregates endpoint. I need to calculate conversation duration and handle time for specific, non-standard intervals that do not align with the pre-built hourly or daily buckets. The documentation states that custom intervals are supported, but I keep hitting a 400 error when defining the metrics.
Here is the JSON payload I am sending to POST /api/v2/analytics/conversations/aggregates:
{
"dateFrom": "2023-10-01T00:00:00Z",
"dateTo": "2023-10-02T00:00:00Z",
"intervalType": "custom",
"intervals": [
{
"start": "2023-10-01T08:00:00Z",
"end": "2023-10-01T12:00:00Z"
},
{
"start": "2023-10-01T13:00:00Z",
"end": "2023-10-01T17:00:00Z"
}
],
"metrics": [
{
"name": "conv.duration",
"type": "sum"
}
],
"groupBy": ["conv.channel"]
}
I have verified the OAuth token has the analytics:reports:read scope. The time range is valid. The interval definitions are within the date range. I have tried changing conv.duration to conv.handledDuration and even conv.wrapUpDuration, but the error persists or changes slightly to indicate the metric is unsupported for custom intervals.
My goal is to get aggregated data for these specific shift blocks. I cannot use the standard hour or day intervals because they split my data across boundaries I do not care about. I need the totals for these exact windows.
Is there a specific syntax for the metrics array when using custom intervals? Or is this endpoint fundamentally restricted from returning duration metrics for non-standard time buckets?
How do I correctly structure the metrics array for custom intervals in the Analytics Conversations Aggregates API to avoid the 400 Bad Request error?