Genesys Cloud Analytics API 413 Error on 90-Day WEM Query

Running a Python script to pull WEM adherence metrics for the last 90 days. The POST to /api/v2/analytics/conversations/summary/queries fails with a 413 Entity Too Large error. The payload size hits the limit because I’m trying to get all agents in one go.

Here is the query body I’m sending:

{
 "queryType": "agent",
 "interval": "P1D",
 "dateFrom": "2023-10-01T00:00:00.000Z",
 "dateTo": "2023-12-30T23:59:59.999Z",
 "groupBy": "agentId",
 "metrics": ["adherence"]
}

The response comes back immediately with status 413. I’ve tried reducing the number of metrics but it still fails. The documentation mentions a size limit but doesn’t specify how to chunk the request.

How do I split this into smaller requests? Should I chunk by date range or by agent ID? I need to get the full 90 days for my reporting dashboard.

Are you paginating the user IDs or dumping the whole org in one shot? That’s usually the trigger for the 413. Try splitting the query by smaller user chunks or using the include parameter to limit fields. Here’s a quick Node.js pattern to batch the requests if you’re stuck with the full list.

const chunks = _.chunk(userIds, 50);
await Promise.all(chunks.map(chunk => postAnalyticsQuery({ userIds: chunk })));

Just loop through the chunks and aggregate locally.