JS SDK pagination for multi-division queues not working

Trying to fetch all queues across multiple divisions using the Genesys Cloud JS SDK. The getQueuesQueues method only returns results for the current division context, and passing divisionId as null or * throws a 400 error.

  • SDK version: 11.18.0
  • Auth: Client Credentials
  • Tried setting divisionId to empty string
  • Tried iterating through divisions manually but getQueuesQueues seems to ignore it

Here is the code block I am running.

const queuesApi = platformClient.queues;
const allQueues = [];

try {
 const response = await queuesApi.getQueuesQueues({
 divisionId: null, // Also tried '*' and ''
 pageSize: 1000,
 pageNumber: 1
 });
 allQueues.push(...response.entities);
} catch (err) {
 console.error(err);
}

The error response is {"errorCode":"bad-request","message":"Division ID is required"}. Is there a specific flag to ignore division filtering or do I have to loop through every division ID first?

Are you passing the division ID as a string literal or letting the SDK handle the serialization? The getQueuesQueues method expects a specific structure for the divisionId parameter when you’re dealing with multiple divisions. Passing null or * won’t work because the API endpoint requires an explicit division ID or a valid wildcard pattern that the SDK knows how to encode.

You’re likely hitting a 400 error because the client credentials grant might not have access to all divisions, or the SDK is serializing the parameter incorrectly. Here’s how I handle this in my custom agent desktop apps using the Embeddable Client App SDK. First, fetch all available divisions, then iterate through them to collect queues. This avoids the wildcard issue entirely.

const { PlatformClient } = require('@genesyscloud/genesyscloud');

async function getAllQueues(platformClient) {
 const divisions = await platformClient.OrganizationsApi.getOrganizationsDivisions();
 const allQueues = [];

 for (const division of divisions.entities) {
 try {
 const queues = await platformClient.QueueApi.getQueuesQueues({
 divisionId: division.id
 });
 allQueues.push(...queues.entities);
 } catch (error) {
 console.error(`Failed to fetch queues for division ${division.id}:`, error);
 }
 }

 return allQueues;
}

This approach is safer because it respects division permissions and avoids hitting rate limits with a single massive request. Also, make sure your client credentials have the queue:read scope for all divisions you’re targeting. If you’re still getting 400 errors, check the response headers for the exact reason. Sometimes it’s a simple typo in the division ID.