413 Entity Too Large on GET /api/v2/analytics/conversations/summary for 90-day window

Could someone explain the best way to handle the 413 error when querying 90 days of conversation summary data? I am using the Python SDK and hitting the limit on the query size. My current approach is to send a single request with a large date range. Here is the payload structure causing the issue:

{
 "groupBy": ["conversation.mediaType"],
 "interval": "P1D",
 "dateFrom": "2023-01-01T00:00:00.000Z",
 "dateTo": "2023-03-31T23:59:59.999Z",
 "select": ["conversation.mediaType"]
}

Should I split this into multiple requests with smaller intervals? If so, how should I aggregate the results in Python?

you need to break that 90-day window into smaller chunks. the analytics api has strict payload limits and a single large query will always trigger a 413. as the docs state, “detail queries utilize token-based pagination,” but for summary data with large date ranges, you must implement manual date slicing. here is a java approach using PureCloudPlatformClientV2 to split the range into 30-day intervals:

List<SummaryResponse> results = new ArrayList<>();
LocalDate start = LocalDate.parse("2023-01-01");
LocalDate end = LocalDate.parse("2023-03-31");

while (start.isBefore(end)) {
 LocalDate chunkEnd = start.plusDays(29); // 30 days total
 if (chunkEnd.isAfter(end)) chunkEnd = end;
 
 QuerySummaryRequest req = new QuerySummaryRequest()
 .dateFrom(start.atStartOfDay().atZone(ZoneOffset.UTC).toString())
 .dateTo(chunkEnd.atTime(LocalTime.MAX).atZone(ZoneOffset.UTC).toString())
 .groupBy(Arrays.asList("conversation.mediaType"))
 .interval("P1D");
 
 results.add(platformClient.analyticsApi.postAnalyticsConversationsSummary(req, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null));
 start = chunkEnd.plusDays(1);
}

this avoids the entity too large error completely.

If I remember correctly, splitting the date range is the only reliable fix. In my ServiceNow integrations, I chunk requests to 30 days max. The payload below works consistently with the Python SDK.

{
 "groupBy": ["conversation.mediaType"],
 "interval": "P1D",
 "dateFrom": "2023-01-01T00:00:00.000Z",
 "dateTo": "2023-01-30T23:59:59.999Z"
}

This is a standard constraint issue that the documentation explicitly mentions but often gets ignored in initial implementation. The suggestion above is correct regarding manual slicing, but in .NET, we should handle this asynchronously to avoid blocking threads. The docs state “queries must be bounded by time,” and exceeding that triggers the 413.

Here is a C# approach using GetAsync with chunked dates:

  • Split the 90-day range into 30-day segments.
  • Use HttpClient or the SDK AnalyticsApi for each segment.
  • Aggregate results in memory.
var tasks = dateRanges.Select(async range => 
{
 var body = new ConversationSummaryQuery 
 { 
 DateFrom = range.Start, 
 DateTo = range.End,
 Interval = "P1D" 
 };
 return await platformClient.Analytics.GetConversationSummaryAsync(body);
});
var results = await Task.WhenAll(tasks);

This prevents the payload size error. I run this in an Azure Function to keep the execution time low.

You might want to check at how you are aggregating those chunks. splitting the date range is the obvious fix for the 413, but if you are just looping through 30-day blocks in a naive for-loop, you are going to hit rate limits on the analytics api faster than you think. the suggestion above about chunking is correct, but it lacks the concurrency control needed for production workloads.

in my node.js serverless setups, i wrap these calls in a step function or a controlled promise pool to handle retries and backoff. if you are using the purecloudplatformclientv2 sdk, ensure you are setting the correct oauth scopes (analytics:query:read) before firing off the requests. also, be careful with the interval parameter. using P1D over a 90-day window creates 90 data points per media type. if you group by multiple attributes, the response payload can still be massive even with date slicing.

here is a quick node.js snippet using the sdk to handle the chunking with a simple concurrency limit to avoid throttling:

const { platformClient } = require('genesyscloud');
const PQueue = require('p-queue');

async function fetchAnalyticsChunks(startDate, endDate, queue) {
 const currentStart = new Date(startDate);
 const end = new Date(endDate);
 
 while (currentStart < end) {
 const chunkEnd = new Date(currentStart);
 chunkEnd.setDate(chunkEnd.getDate() + 30); // 30-day chunks
 if (chunkEnd > end) chunkEnd.setTime(end.getTime());

 const query = {
 dateFrom: currentStart.toISOString(),
 dateTo: chunkEnd.toISOString(),
 groupBy: ['conversation.mediaType'],
 interval: 'P1D',
 select: ['conversation.count']
 };

 await queue.add(async () => {
 const response = await platformClient.AnalyticsApi.postAnalyticsConversationsSummary(query);
 return response.body;
 });

 currentStart.setTime(chunkEnd.getTime());
 }
}

// Usage with concurrency limit of 5
const queue = new PQueue({ concurrency: 5 });
fetchAnalyticsChunks('2023-01-01', '2023-03-31', queue);

this approach prevents the 413 by keeping payloads small and respects api limits by controlling parallel execution. don’t forget to implement exponential backoff in your error handling logic.