Analytics API 413 Error: How to split 90-day query in Terraform?

Can anyone clarify why I am hitting a 413 Entity Too Large error when trying to configure a Data Action in Terraform for a 90-day conversation analytics query? The specific error returned by the Genesys Cloud API is HTTP 413 Request Entity Too Large. I am using the genesyscloud.dataaction resource to map an external system call, but the JSON payload for the settings block exceeds the size limit when I include the full date range from 2023-10-01 to 2023-12-30 in the dateInterval field. My Terraform code looks like this:

resource "genesyscloud.dataaction" "analytics_query" {
 name = "MyAnalyticsQuery"
 enabled = true
 settings = jsonencode({
 endpoint = "/api/v2/analytics/conversations/summary"
 method = "POST"
 body = jsonencode({
 dateInterval = {
 start = "2023-10-01T00:00:00.000Z"
 end = "2023-12-30T23:59:59.999Z"
 }
 groupBy = ["queue.id"]
 })
 })
}

I am coming from an AWS Terraform background where I usually handle large datasets by splitting them into multiple API calls or using S3 for storage, but here the request payload itself is being rejected before it even hits the analytics engine. I tried reducing the pageSize in the query parameters, but that did not help because the error is related to the request body size, not the response size. I am based in Lagos and working on a migration project, so I need to understand if this is a hard limit on the Genesys Cloud side or if I am structuring the JSON incorrectly.

Is there a recommended way to split a 90-day query into smaller chunks within a single Data Action, or should I be using multiple Data Actions with staggered date intervals? I noticed that queries under 30 days work fine, so the issue seems strictly tied to the volume of metadata sent in the request. Any code examples for handling this pagination or splitting logic in Terraform would be greatly appreciated.

This happens because the payload size limit when embedding the full 90-day range in the settings block.

  1. Split the query into three 30-day segments in your Terraform configuration.
  2. Chain these segments using a sequential Data Action flow to aggregate results server-side.

This is actually a known issue with the Analytics API payload limits. Embedding large date ranges in settings triggers the 413 error because the JSON structure exceeds the server’s request entity size threshold.

Split the query into three 30-day segments as suggested. Use a sequential Data Action flow to aggregate the results server-side, ensuring each individual request stays under the limit.

It depends, but generally… I am trying to replicate the split logic in my Python backend to avoid the 413 error entirely. The documentation states: “Requests exceeding 2MB will be rejected with a 413 status code.” Instead of chaining Data Actions, I am using the PureCloudPlatformClientV2 SDK to batch the analytics queries programmatically.

from platformclientv2 import AnalyticsApi
api = AnalyticsApi()
# Split 90 days into 30-day chunks
for start, end in chunks:
 query = ConversationQuery()
 query.date_range = f"{start}/{end}"
 results = api.post_analytics_conversations_query(query_body=query)

This approach keeps each payload small. The previous suggestion to chain Data Actions works, but it adds latency. My script aggregates the results locally before storing them. It is more reliable for bulk operations.