Problem
The nightly export script keeps pulling duplicate conversation records after the first batch. We’re querying the details endpoint to feed the supervisor dashboard. The admin UI handles the view fine, but the backend job gets stuck in a loop. We need the raw data for the Pacific reporting window, but the pagination logic is fighting us.
Code
response = requests.post(
f"{base_url}/api/v2/analytics/conversations/details/query",
headers=auth_headers,
json=payload
)
data = response.json()
while data.get("nextPageToken"):
payload["pageToken"] = data["nextPageToken"]
response = requests.post(url, headers=auth_headers, json=payload)
data = response.json()
Error
Nothing crashes outright. The endpoint returns 200 every time. We just see overlapping conversationId values in the output CSV. The token keeps refreshing, but the dataset shifts back to the beginning of the queue. It looks like the API is ignoring the nextPageToken when we pass it back in pageToken. The docs mention cursor-based pagination, but the payload structure expects a pageToken field. We’ve tried swapping to cursor and offset, but both throw 400 Bad Request. The queue analytics team needs clean splits. We’re sitting on a pile of half-exported JSON files. The timestamp ranges are overlapping too.
Question
How do we actually chain the tokens without getting duplicate rows? Any working snippet for this endpoint would save us a rewrite. The token format just doesn’t match the response schema. Just need to know the exact key name for the next cursor.