I’m trying to pull conversation details using GET /api/v2/analytics/conversations/details/query. The docs mention pageSize but I’m not seeing a page parameter in the query object. Do I need to use cursor-based pagination with nextPageToken or is there a way to do simple page number iteration? My current payload looks like this:
{
"pageSize": 25,
"groupBy": ["conversationId"],
"timeRange": {
"from": "2023-01-01T00:00:00.000Z"
}
}
Are you hitting the API directly or using the PureCloud SDK?
If you’re using the SDK, you’ll notice the getAnalyticsConversationsDetailsQuery method doesn’t support a page parameter. The Genesys Cloud analytics endpoints rely heavily on cursor-based pagination to handle large result sets efficiently. You need to use the nextPageToken returned in the response.
Here is how the loop typically looks in the Node.js SDK:
const AnalyticsApi = PlatformClient.AnalyticsApi;
const analyticsApi = new AnalyticsApi();
async function fetchConversations(queryBody) {
let nextPageToken = null;
let allResults = [];
do {
const options = {
queryBody: {
...queryBody,
pageSize: 25,
nextPageToken: nextPageToken
}
};
try {
const response = await analyticsApi.getAnalyticsConversationsDetailsQuery(options);
allResults = allResults.concat(response.body.entities);
nextPageToken = response.body.nextPageToken;
} catch (error) {
console.error("Error fetching conversation details:", error);
break;
}
} while (nextPageToken);
return allResults;
}
If you are constructing the curl request manually, the JSON payload needs the nextPageToken field included in the body for subsequent calls. The first call omits it or sets it to null.
curl -X POST "https://api.mypurecloud.com/api/v2/analytics/conversations/details/query" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"groupBy": ["conversationId"],
"pageSize": 25,
"nextPageToken": "YOUR_TOKEN_FROM_PREVIOUS_RESPONSE"
}'
The nextPageToken is opaque. Don’t try to parse it. Just pass it back verbatim. Also keep an eye on the timeRan field in your query. If the window is too wide, the API might throttle you or return partial results.