CXone Reporting API: Agent state history query returning empty results

I’m trying to fetch agent state history for the last 24 hours using the CXone Reporting API. Specifically, I need to track when agents transitioned between Available, Busy, and Offline states to correlate with our Android app’s push notification delays.

I’m constructing an OData query against the /api/v2/analytics/agents/summary endpoint. The documentation suggests using $filter with gt and lt operators for time ranges. Here’s the Kotlin code I’m using to build the request:

val startTime = LocalDateTime.now().minusHours(24)
val endTime = LocalDateTime.now()
val filter = "startTime gt '${startTime.toInstant(ZoneOffset.UTC)}' and startTime lt '${endTime.toInstant(ZoneOffset.UTC)}'"
val endpoint = "/api/v2/analytics/agents/summary?aggregateId=agentStateHistory&$filter=$filter&$interval=PT1H"

The request returns a 200 OK status, but the data array in the JSON response is always empty. I’ve verified the aggregateId=agentStateHistory is correct by checking the Swagger docs. I’m also passing the correct OAuth token with analytics:read scope.

If I remove the $filter clause, I get some data, but it’s historical data from weeks ago, not the last 24 hours. This makes me think the timestamp format is wrong, or the startTime field in the backend isn’t indexed the way I expect.

I’ve tried formatting the timestamps as ISO 8601 strings with Z suffix, and as Unix epoch milliseconds. Both result in empty arrays. I’ve also tried using le and ge instead of lt and gt.

Has anyone successfully queried agent state history for a recent time window? Is there a specific timezone requirement for the filter values, or should they always be UTC? The API logs show no errors, just an empty result set.

One thing I noticed is that the interval parameter is set to PT1H (one hour). Could this be causing the aggregation to skip recent incomplete intervals? I’ve tried PT1M as well, but same result.

I’m debugging this on an Android device in the America/Chicago timezone, but I’m sending UTC timestamps as per the API docs. The app is using the genesys-cloud-sdk-java client to make the HTTP calls, but I’m building the query string manually because the SDK’s query builder doesn’t seem to support complex OData filters for custom aggregates.

Any pointers on the correct timestamp format or filter syntax would be appreciated. I’m stuck on this for two days now.