Discrepancy between /api/v2/conversations and /api/v2/analytics/conversations for Android SDK session duration

My current config is completely failing…

I am attempting to reconcile session duration metrics for Genesys Cloud Web Messaging conversations initiated via my custom Kotlin Android SDK implementation. The application operates in the America/Chicago timezone, and I am methodically debugging a discrepancy between real-time state and historical analytics.

When I query the Conversations API directly using GET /api/v2/conversations/{conversationId} within a Kotlin coroutine scope, the response payload includes a state field and createdTimestamp. However, the lastActivityTimestamp often appears null or stale if the conversation is still active in the WebSocket session. Conversely, when I query the Analytics API using GET /api/v2/analytics/conversations/summary?query=conversationId:{id}, the returned JSON payload provides a duration field in milliseconds that seems more accurate for completed sessions.

The issue arises during active sessions. The Analytics endpoint returns a 404 Not Found or an empty result set if the conversation has not yet been fully closed and processed by the analytics pipeline. Meanwhile, the Conversations API returns a 200 OK but lacks the precise duration metric I need to update the UI immediately.

Here is the Kotlin code snippet for the Conversations API call:

val response = httpClient.get("https://myinstance.mygenesyscloud.com/api/v2/conversations/$conversationId")
val json = response.bodyAsText()
// Parsing fails to extract duration

And the Analytics API call:

val analyticsResponse = httpClient.get("https://myinstance.mygenesyscloud.com/api/v2/analytics/conversations/summary?query=conversationId:$conversationId")
// Returns 404 or empty data for active sessions

I need to understand the exact architectural distinction between these two endpoints regarding data latency and availability. Is there a recommended approach to fetch real-time duration metrics for an active Web Messaging session in Android without relying on the delayed Analytics pipeline? I am looking for a code-level solution to handle this gap.

Thank you.

The quickest way to solve this is to stop relying on the raw duration field from the conversations endpoint. The GET /api/v2/conversations/{conversationId} returns the total elapsed time since creation, including any pending or disconnected states. For accurate analytics, you must query the analytics endpoint directly. Use GET /api/v2/analytics/conversations/summary with a specific groupBy: conversationId and filter by your specific date range. The analytics engine calculates talk and hold times based on actual media flow, ignoring idle gaps. Here is the correct Kotlin implementation using the Genesys Cloud SDK:

val analyticsClient = AnalyticsApi()
val request = GetConversationsSummaryRequest().apply {
 dateRange = DateRange(startDate = start, endDate = end)
 groupBy = listOf("conversationId")
 metrics = listOf("duration", "talk", "hold")
}
val response = analyticsClient.getConversationsSummary(request)

Note: Ensure your OAuth token includes analytics:read scope. The conversations API does not expose granular metric breakdowns.

As far as I remember, the documentation states that “analytics data is not available in real-time,” so you must wait for the processing window. Try this summary query instead:

{
 "groupBy": ["conversationId"],
 "filter": {
 "type": "conversation",
 "subType": "webchat",
 "dateRange": {
 "from": "2023-10-01T00:00:00.000Z",
 "to": "2023-10-02T00:00:00.000Z"
 }
 }
}

The docs actually state that the duration field in the Conversations API represents the total elapsed time since creation, which includes pending and disconnected states. This explains the discrepancy observed in the Android SDK implementation.

My config is not working… I am attempting to reconcile session duration metrics for Genesys Cloud Web Messaging conversations initiated via my custom Kotlin Android SDK implementation. The application operates in the America/Chicago timezone, and I am methodically debugging a discrepancy between real-time state and historical analytics.

The suggestion above to use the analytics endpoint is correct. In an Angular context, I utilize platformClient.AnalyticsApi.getConversationsSummary with a groupBy of conversationId. Ensure the dateRange uses UTC ISO 8601 format, as the Chicago timezone offset is handled server-side. For real-time session tracking within the app, I subscribe to WebSocket notifications via platformClient.NotificationsApi.addNotificationSubscription rather than polling. This avoids the latency inherent in the analytics pipeline. The code block below demonstrates the correct summary request structure.

const body = {
 groupBy: ['conversationId'],
 filter: {
 type: 'conversation',
 subType: 'webchat',
 dateRange: {
 from: new Date().toISOString(),
 to: new Date().toISOString()
 }
 }
};
platformClient.AnalyticsApi.getConversationsSummary(body);