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:

  • I attempted to query the agent status using POST /api/v2/analytics/agents/status/query.
  • 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 looked into using GET /api/v2/analytics/reporting/settings/dashboards/query with a custom report definition, but that feels like overkill for a simple 24-hour window.

The response from the status query 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.post(`/api/v2/analytics/agents/status/query`, {
 agentId: '12345678-1234-1234-1234-123456789012'
}, {
 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.