CXone Reporting API v2 agent state history query

Need to pull agent state history for the last 24 hours using the CXone Reporting API v2. The documentation is sparse on OData filters for this specific endpoint.

Here is the current request:

GET /api/v2/reporting/agents/{agentId}/statehistory

I am trying to filter by date, but the standard OData syntax isn’t working as expected. The response returns all states from the agent’s entire history, which is way too much data. I’ve tried appending $filter=timestamp ge 2023-10-27T00:00:00Z but get a 400 Bad Request. The error message says invalid filter syntax.

Is there a specific format for the timestamp? Or is this endpoint not fully OData compliant for date ranges? Any working examples would be appreciated.

Cause: The endpoint expects ISO 8601 with timezone offsets. Missing the ‘Z’ or offset breaks the OData parser, causing it to ignore the filter entirely.

Solution: Append the ‘Z’ suffix and ensure the date format is strict. Here is the correct curl command:

curl -X GET "https://api.mypurecloud.com/api/v2/reporting/agents/{agentId}/statehistory?$filter=timestamp ge 2023-10-27T00:00:00Z" -H "Authorization: Bearer <token>"