Analytics API 413 Error on 90-day query - how to chunk the request?

Running into a wall with the Analytics API. I’m trying to pull interaction data for a 90-day window in one go, but the server keeps rejecting the payload.

Here is the JSON body I’m sending to POST /api/v2/analytics/interactions/summary/query:

{
 "dateFrom": "2023-10-01T00:00:00.000Z",
 "dateTo": "2023-12-30T23:59:59.999Z",
 "groupings": [
 {
 "type": "queue",
 "field": "name"
 }
 ],
 "select": [
 "handleTime",
 "wrapUpTime",
 "talkTime"
 ]
}

The response is a flat 413 Entity Too Large. I’ve checked the docs and I know the body size limit is relatively small, but I’m not sure if it’s the JSON string length or the calculated result set size causing the choke.

Steps I’ve tried:

  • Reduced the window to 30 days. Request succeeds.
  • Reduced the number of fields in select to just handleTime. 90-day window still fails with 413.
  • Added Content-Length header explicitly. No change.

I assume I need to break this into three separate 30-day requests and merge the results on the client side. Is there a parameter I’m missing to handle larger windows? Or should I just write a loop in my script to fire off multiple POST requests with adjusted dateFrom and dateTo?

Here is the Python I’m using to make the call:

import requests
import json

url = "https://api.mynice.com/api/v2/analytics/interactions/summary/query"
headers = {
 "Authorization": f"Bearer {token}",
 "Content-Type": "application/json"
}

payload = {
 "dateFrom": "2023-10-01T00:00:00.000Z",
 "dateTo": "2023-12-30T23:59:59.999Z",
 "groupings": [{"type": "queue", "field": "name"}],
 "select": ["handleTime"]
}

response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.status_code)
# Returns 413

Does the API support a limit or offset for the query window itself? I don’t see it in the swagger spec.