Analytics API: Filtering by Wrap-up Code AND Call Duration (Metric Filter)

I’m a supervisor, not a developer, but I’ve been trying to use the Developer Center API Explorer to pull some reports that the standard UI can’t handle.

I need to use POST /api/v2/analytics/conversations/details/query to find all calls from yesterday that had the wrap-up code ‘Complaint’ AND where the agent’s talk time (tTalk) was greater than 5 minutes (300000 ms).

I figured out how to filter the segmentFilters by the wrap-up code dimension, but I keep getting a 400 Bad Request when I try to add the tTalk metric filter. The documentation on nesting dimension and metric filters is really confusing for a non-coder. Can someone provide a working JSON payload example for this?

I had to learn this the hard way during our predictive routing beta! The trick is understanding that dimensions (like wrap-up codes) and metrics (like tTalk) are evaluated differently in the query.

You cannot put a metric filter inside a segmentFilter block. You have to use the conversationFilters or evaluationFilters section depending on the scope, but actually, for metrics like tTalk, you use the metricFilters array at the top level of the segment block.

Here’s the snippet: inside your segment filter, add "metricFilters": [ {"metric": "tTalk", "range": { "gte": 300000 } } ]. Note that the time is in milliseconds!

I actually submitted a bug to the Python SDK repo about this because the models weren’t serializing metricFilters correctly.

's JSON structure is correct. Just be aware of where the tTalk occurs. If you put that metricFilter inside a segment filter that is strictly looking for the wrapUpCode dimension, it might fail. Why? Because the wrapUpCode is applied during the wrapup segment type, but tTalk is accumulated during the interact segment type.

To be safe, you should use two separate segmentFilters combined with an AND operator at the conversationFilters level: one filter for the interact segment checking tTalk > 300000, and another filter for the wrapup segment checking wrapUpCode == Complaint.