CXone Reporting API v2: Agent State History query returns empty array for last 24h

So I’m seeing a very odd bug with the CXone Reporting API v2 when querying agent state history. I am using a simple GET request to /api/v2/reporting/agent/state-history with a time filter for the last 24 hours. The authentication is solid, as I can fetch other metrics without issue. However, the response payload consistently returns an empty data array, even for agents who were clearly online and handling calls during the specified window. I have verified the interval parameter is set correctly to PT1H and the since timestamp is in proper ISO 8601 format with UTC timezone. The API returns a 200 OK status, which makes it feel like a silent failure in the query logic rather than an auth error. I have checked the documentation multiple times and cannot find any requirement for additional headers or query parameters beyond the standard ones.

Here is the exact cURL command I am using for testing:

curl -X GET "https://us-1.api.niceincontact.com/api/v2/reporting/agent/state-history?since=2023-10-25T00:00:00Z&until=2023-10-26T00:00:00Z&interval=PT1H" \
-H "Authorization: Bearer <TOKEN>" \
-H "Accept: application/json"

The response is simply {"data": [], "nextPageToken": null}. Is there a known issue with the 24-hour lookback window for state history in the US-1 region, or am I missing a specific filter that forces the engine to populate the results?

If I remember correctly, this empty array issue usually stems from timezone mismatch or insufficient reporting granularity. The CXone API expects ISO 8601 timestamps in UTC, but many clients pass local time. Also, ensure you are querying the correct agent ID format.

Here is how I handle this in my React Native wrapper:

  • Convert start/end times to UTC ISO strings explicitly.
  • Verify the agentId is the UUID, not the login name.
  • Check if the agent actually changed states. If they stayed in “Available” for 24 hours, some endpoints might not return granular ticks unless interval is specified.
const startDate = new Date().toISOString();
const endDate = new Date(Date.now() - 86400000).toISOString();

const response = await platformClient.AnalyticsApi.postReportingQueuesMetrics(
 {
 agentIds: [agentUuid],
 interval: 'PT1H', // Request hourly granularity
 dateRangeStart: endDate,
 dateRangeEnd: startDate
 }
);

Check the interval parameter. Without it, the default might skip periods with no state changes. This fixed my React Native dashboard lag.