Trying to build a reliable trace aggregation loop for Data Actions using the /api/v2/analytics/conversations/details/query endpoint. The goal is to capture every conversation event to correlate with our OpenTelemetry spans.
Using cursor-based pagination feels risky because the docs warn about data consistency if new records arrive during the fetch. Here’s the current fetch logic:
import requests
def fetch_all_conversations(auth_token, start_time, end_time):
url = "https://myinstance.mypurecloud.com/api/v2/analytics/conversations/details/query"
headers = {"Authorization": f"Bearer {auth_token}", "Content-Type": "application/json"}
body = {
"dateFrom": start_time,
"dateTo": end_time,
"groupBy": ["conversationId"],
"view": "conversation"
}
while True:
res = requests.post(url, json=body, headers=headers)
data = res.json()
if not data.get('data'):
break
for record in data['data']:
process_for_otel(record)
if data.get('pagination', {}).get('nextPageToken'):
body['pageToken'] = data['pagination']['nextPageToken']
else:
break
fetch_all_conversations(token, "2023-10-01T00:00:00Z", "2023-10-01T23:59:59Z")
The issue is the nextPageToken behavior. If I have high volume, does the cursor move forward as new data lands, or is it a snapshot? I’m seeing duplicate conversationIds in the output when running this over a 24-hour window.
Is there a way to enforce a strict snapshot or should I switch to page-based pagination for analytics queries? The SDK doesn’t seem to expose a pageSize override that works consistently with cursors here.