CXone Reporting API: Querying agent state history for last 24 hours via OData

I’m trying to build a custom widget that shows an agent their state history for the previous 24 hours. The goal is to see exactly when they went from Available to After-Call Work. I’ve looked at the Embeddable Client App SDK docs, but there doesn’t seem to be a direct method for this in the client-side library. So I’m hitting the REST API directly using axios.

Here is what I’ve tried so far:

  • Endpoint: GET /api/v2/analytics/queues/realtime/agents
  • I passed the agent ID in the query string.
  • I tried adding $filter=stateHistory/eq(true) but got a 400 Bad Request saying the syntax is invalid.
  • I also tried GET /api/v2/analytics/icm/report/queries with a custom report definition, but that feels like overkill for a simple 24-hour window.

The response from the realtime endpoint only shows the current state, not the history. I need the timestamps for state changes.

Here is the payload I’m sending:

const params = new URLSearchParams({
 'agentId': '12345678-1234-1234-1234-123456789012',
 '$select': 'id,name,stateHistory'
});

const response = await axios.get(`/api/v2/analytics/queues/realtime/agents?${params}`, {
 headers: {
 'Authorization': `Bearer ${token}`,
 'Content-Type': 'application/json'
 }
});

The error I get is 400 Bad Request with message Invalid filter clause.

Is there a specific OData syntax for filtering history? Or should I be using a different endpoint entirely? I’ve been stuck on this for two days. Any pointers would be appreciated.