Hey folks,
I’m trying to pull agent state history for the last 24 hours using the CXone Reporting API (v2). The goal is to get a timeline of when agents were logged in, available, or on break for a specific date range.
Here’s what I’m working with:
- Endpoint:
GET /api/v2/reporting/agents/history - Language: Python with
requestslibrary - Auth: OAuth2 client credentials flow
- Date Range: Last 24 hours (calculated in UTC)
The request seems to go through fine (200 OK), but the response is either empty or missing chunks of data. Here’s the basic structure of my call:
import requests
import datetime
start_time = (datetime.datetime.utcnow() - datetime.timedelta(hours=24)).isoformat() + 'Z'
end_time = datetime.datetime.utcnow().isoformat() + 'Z'
headers = {
'Authorization': 'Bearer ' + access_token,
'Accept': 'application/json'
}
params = {
'startTime': start_time,
'endTime': end_time,
'granularity': 'hourly'
}
response = requests.get('https://platform.my-cxone.com/api/v2/reporting/agents/history', headers=headers, params=params)
print(response.json())
The JSON response comes back with a structure like:
{
"data": [
{
"agentId": "12345",
"state": "Available",
"timestamp": "2023-10-27T10:00:00Z"
}
]
}
But it’s not complete. Some hours are missing, and the granularity doesn’t seem to match what I’m expecting. I’ve tried changing the granularity to minute but that just makes the payload huge and still gaps in the data.
Is there a specific parameter I’m missing? Or is this a known limitation with the v2 reporting API for agent history? I’ve checked the docs but they’re pretty light on this specific endpoint.
Thanks!