Anyone know why the /api/v2/analytics/queues/summary endpoint returns a 503 Service Unavailable when requesting data spanning more than 30 days? We are building a reporting dashboard for a multi-org client using the Node SDK v4.2.1. The request works for smaller date ranges but fails consistently for longer periods, despite valid OAuth tokens with analytics:report:read scope. Here is the request payload structure:
method: GET
headers:
Authorization: Bearer <token>
Content-Type: application/json
params:
dateFrom: "2023-01-01T00:00:00.000Z"
dateTo: "2023-06-01T00:00:00.000Z"
groupings:
- time
- queue
This happens because the backend processing timeout for large historical datasets. The analytics service has a hard limit on how long a single query can run, and aggregating 30+ days of queue summary data often exceeds that threshold. It is not an authentication issue, but rather a resource constraint on the server side during the aggregation phase.
For load testing or dashboard exports, splitting the date range is the standard workaround. Instead of one large request, use a loop to fetch data in smaller chunks, like 7-day intervals. This keeps each API call under the timeout limit and avoids the 503 error. You can then aggregate the results locally in your Node application before displaying them.
Here is a simple approach using the Node SDK to chunk the request. It reduces the load on the API gateway and ensures successful responses.
const start = new Date('2023-01-01');
const end = new Date('2023-01-31');
const chunkSize = 7 * 24 * 60 * 60 * 1000; // 7 days in ms
for (let rangeStart = start; rangeStart < end; rangeStart.setUTCSeconds(rangeStart.getUTCSeconds() + chunkSize)) {
let rangeEnd = new Date(rangeStart);
rangeEnd.setUTCSeconds(rangeEnd.getUTCSeconds() + chunkSize);
// fetch /api/v2/analytics/queues/summary with rangeStart and rangeEnd
}
Have you tried implementing a segmented retrieval strategy within your Node SDK implementation to bypass the backend aggregation limits?
const moment = require('moment');
function fetchHistoricalData(startDate, endDate) {
const start = moment(startDate);
const end = moment(endDate);
const results = [];
// Iterate in 7-day increments to stay within processing limits
while (start.isBefore(end)) {
const chunkEnd = start.clone().add(7, 'days');
if (chunkEnd.isAfter(end)) chunkEnd.endOf('day'); // Align with business day logic
// Execute API call for this specific window
const data = await analyticsAPI.getQueuesSummary({
start_time: start.format(),
end_time: chunkEnd.format()
});
results.push(data);
start.add(7, 'days');
}
return results;
}
This approach ensures that each individual request remains within the acceptable processing window, preventing the 503 errors observed with larger date spans.