Null wrapUpCode in Analytics Detail Query: Query Error or Known Limitation?

Is it possible to retrieve non-null wrapUpCode values in the /api/v2/analytics/conversations/details/query endpoint, or is this a known data schema limitation for specific media types?

  • I am executing a POST request to /api/v2/analytics/conversations/details/query to extract conversation metrics for our Web Messaging and Voice queues. The goal is to correlate wrapUpCode with agent performance metrics using the groupBy array.
  • My request body includes groupBy: ["mediaType", "wrapUpCode"] and filters for mediaType in ["voice", "webchat"]. Despite valid conversations existing in the UI with explicit wrap-up codes assigned, the API response consistently returns null for the wrapUpCode field in the detail records.
  • Here is a simplified version of my payload structure:
{
"dateFrom": "2023-10-01T00:00:00.000Z",
"dateTo": "2023-10-01T23:59:59.000Z",
"groupBy": ["mediaType", "wrapUpCode"],
"filters": {
"mediaType": {
"path": "mediaType",
"type": "string",
"op": "in",
"value": ["voice", "webchat"]
}
}
}
  • I have verified that the view:analytics scope is present in my OAuth token and that the wrapUpCode field is not explicitly excluded in any field selection logic (since I am using default detail fields).
  • In my recent experience with Analytics Aggregates queries, omitting specific type fields or misconfiguring groupBy can lead to empty results, but here I am getting records, just with null values for the specific field.
  • I suspect this might be related to how the analytics service processes wrapUpCode for webchat media types compared to voice, or perhaps the field is only available in a different endpoint like /api/v2/quality/evaluations.
  • Has anyone successfully queried wrapUpCode via the Analytics Details API? If so, what is the correct structure to ensure the field populates correctly?

Have you tried setting wrapUpCode in the metrics array instead of relying on default fields, as detailed in this doc? For Voice media, the wrap-up code is strictly tied to the agent’s interaction end event, so omitting it from the explicit metric list often results in null values during the aggregation phase.

This is typically caused by the data export timing. in my glue jobs, i see wrapupCode is null until the conversation is fully closed and exported. use this filter to avoid stale nulls.

df = spark.sql("SELECT * FROM gc_conversations WHERE wrapupCode IS NOT NULL")

check your s3 staging latency.

It depends, but generally… the issue lies in how the detail query aggregates conversation segments. The suggestion above about explicit metrics is correct, but insufficient for Web Messaging.

In Voice, the wrapUpCode exists at the conversation level. In Web, it is often tied to specific agent interactions. If your query filters by conversation.id without expanding interactions, the root node may lack the code.

Use this payload structure for accurate retrieval:

{
 "interval": "2023-10-01T00:00:00Z/2023-10-02T00:00:00Z",
 "view": "conversation",
 "groupBy": ["wrapUpCode"],
 "metrics": ["wrapUpCode", "durationSystem"],
 "filter": [
 { "type": "string", "path": "mediaType", "op": "in", "value": ["voice", "webchat"] }
 ]
}

If you still see nulls, check the state filter. Ensure state:closed is applied. Open conversations return null by design. In my Azure Function consumers, I validate the segmentId mapping. If the segment is missing, the code is null.

Requirement Status
Metric in array Required
State filter Recommended
Segment expansion Optional

The way I solve this is by ensuring the query payload explicitly requests interaction-level metrics, not just conversation aggregates. The issue is that Web Messaging wrap-up codes are attached to the specific agent interaction, not the root conversation object. If you only query the top level, you get nulls.

Error: “wrapUpCode is null for mediaType ‘webchat’ despite successful completion”

Here is the working SvelteKit server route logic. You must include interactions in your groupBy or ensure metrics includes the interaction-specific wrap-up field.

const body = {
 dateFrom: "2023-10-01T00:00:00.000Z",
 dateTo: "2023-10-01T23:59:59.999Z",
 queryType: "conversation",
 metrics: ["wrapUpCode", "agentWrapUpTime"],
 groupBy: ["wrapUpCode", "interaction.agentId"] // Critical for web
};

const response = await fetch("/api/v2/analytics/conversations/details/query", {
 method: "POST",
 headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
 body: JSON.stringify(body)
});
  1. Verify media type in your filter.
  2. Expand interactions if using voice.
  3. Check SvelteKit proxy latency.