CXone Reporting API v2: Querying Agent State History via OData

Trying to pull agent state changes for the last 24 hours. Using GET on /api/v2/reporting/agents/details with OData filter $filter=timestamp ge 2023-10-27T00:00:00Z. Returns 400 Bad Request. Error says invalid date format.

Payload:

{ "error": "Invalid filter syntax" }

Need correct OData syntax for timestamp range. Current code fails on validation. What’s the right format?

The endpoint you’re hitting doesn’t support OData filters in the query string for that specific field. The agents/details endpoint is strict about its query parameters. You can’t just dump an OData string into the URL like that. The API expects specific parameter names, not generic OData syntax.

You need to use the startTime and endTime query parameters directly. Also, the date format must be ISO 8601 with the T separator and Z for UTC, but passed as a string value, not part of a filter expression.

Here’s how you structure the request:

GET /api/v2/reporting/agents/details?startTime=2023-10-27T00:00:00Z&endTime=2023-10-28T00:00:00Z&interval=PT1H

If you’re using the .NET SDK, it handles this serialization for you. Don’t try to construct the URL manually. Use the GetReportingAgentsDetailsAsync method.

var client = new PureCloudPlatformClientV2();
var response = await client.AnalyticsApi.GetReportingAgentsDetailsAsync(
 startTime: "2023-10-27T00:00:00Z",
 endTime: "2023-10-28T00:00:00Z",
 interval: "PT1H",
 view: "agent"
);

The 400 Bad Request is happening because the parser expects key-value pairs, not a filter object. The timestamp field isn’t a filterable attribute in the query string for this endpoint. It’s a fixed range query.

Also, watch out for the interval parameter. If you don’t specify it, the API might default to a larger bucket or fail silently depending on the version. Stick to PT1H or PT15M for granular state changes.

If you need state transitions specifically, look at the stateChange view. The default agent view aggregates metrics, not raw state events. You’ll get a lot of noise if you just pull the default view. Switch the view parameter to stateChange if you want the actual history of when an agent went from Available to Busy or Offline.

The docs are vague on this. They show OData examples for other endpoints but not this one. It’s a common trap. Just use the explicit parameters.