Discrepancy in conversation counts between /api/v2/conversations and /api/v2/analytics/conversations

Does anyone know the precise data retention and aggregation differences between the real-time conversations API and the analytics endpoint?

I am building a Grafana dashboard for queue metrics. I need to display active conversations alongside historical trends. I noticed a significant count mismatch when querying the same time window.

The real-time endpoint returns current state. The analytics endpoint returns aggregated historical data. But the gap is larger than expected for completed conversations.

Here is the Python snippet using the genesyscloud SDK:

from genesyscloud import conversations_api
from genesyscloud import analytics_api

# Real-time check
conv_api = conversations_api.ConversationsApi(api_client)
conversations, resp, err = conv_api.get_conversations(
 expand=['routing'],
 pageSize=100
)

# Analytics check
analytics_api_inst = analytics_api.AnalyticsApi(api_client)
analytics_data, resp, err = analytics_api_inst.post_analytics_conversations_data(
 body={
 "interval": "2023-10-01T00:00:00Z/2023-10-01T01:00:00Z",
 "metrics": ["conversation.count"],
 "groupBys": []
 }
)

The analytics call returns 400 Bad Request if I omit groupBy. If I add groupBy=["routing.queue.name"], the sum of counts differs from the real-time snapshot taken at the end of the interval.

Environment details:

  • Genesys Cloud Region: us-east-1
  • SDK Version: 2.0.0
  • Python Version: 3.9
  • Timezone: Australia/Sydney

Key observations:

  • Real-time API includes conversations in ‘queued’ and ‘connected’ states.
  • Analytics API seems to exclude conversations that ended before the interval started.
  • Analytics API aggregates by minute by default. I need second-level granularity.

Is there a way to get exact conversation IDs from the analytics API? Or should I stick to the real-time API and poll every 5 seconds? The real-time API has rate limits. The analytics API has a delay.

I need a reliable source for both active and recent historical data. The documentation is vague on the overlap. Any code examples for bridging this gap would be helpful.