Cursor pagination vs page-based for /api/v2/analytics/conversations/details/query

Trying to pull full history from the analytics details endpoint and getting stuck on the pagination logic. The docs mention page and size params, but the response also includes a cursor field. Does this endpoint actually support cursor-based pagination, or am I supposed to keep incrementing the page number until I hit 404?

You don’t need to increment the page number manually. The endpoint returns a nextPage URL in the response header or body. If you ignore that and just bump the page integer, you’ll likely miss data or hit a 404 prematurely. The cursor is the reliable way to go.

Here is how I handle it in Python using the SDK. It’s cleaner than parsing headers manually.

from genesyscloud import analytics_api

api_instance = analytics_api.AnalyticsApi(platform_client)

# Initial query
body = analytics_api.QueryConversationDetailsRequest(
 view='full',
 date_from='2023-01-01T00:00:00Z',
 date_to='2023-01-02T00:00:00Z',
 page_size=250
)

response = api_instance.post_analytics_conversations_details_query(body=body)

all_details = response.entity.details

while response.next_page is not None:
 # The SDK handles the cursor internally when you pass the response
 # Or you can extract the nextPage URL and request it directly
 response = api_instance.post_analytics_conversations_details_query(
 body=body, 
 page_token=response.next_page 
 )
 all_details.extend(response.entity.details)

The key is checking response.next_page. If it’s null, you’re done. If it has a value, pass it back in the request. This avoids the headache of calculating offsets.

One thing to watch for. If you are pulling a massive date range, the API might still timeout or return partial data if the query takes too long. I usually break the date range into chunks of 24 hours. It’s more API calls, but it’s safer for adherence tracking. I’ve seen the analytics queue back up during peak hours too. Just be patient with the rate limits.

Also, make sure your token has analytics:conversation:view scope. Without it, you’ll get a 403 before you even worry about pagination. It’s easy to miss that when setting up service accounts for reporting scripts.