I’m trying to pull agent states for our WFM adherence dashboard using the CXone API. The agent is definitely logged in and available in the portal, but the API keeps returning an empty array.
Here’s the call:
requests.get('https://api.nice.incontact.com/wfaapi/v1/agents/states', headers=headers)
Response is just []. Status 200. I’ve checked the token and it’s valid. Is there a specific filter I need to add to see active agents?
You’re hitting the right endpoint but missing the critical query parameter. The /agents/states endpoint doesn’t return a list of all agents by default; it requires an explicit agent ID filter. Without it, the API assumes you want nothing or returns an empty set if the scope isn’t narrowed.
Try adding the agentIds parameter to your request. Since you’re using Python requests, you can pass it via the params dict:
import requests
headers = {
'Authorization': f'Bearer {access_token}',
'Accept': 'application/json'
}
# You MUST provide the specific agent ID
params = {
'agentIds': '12345678-1234-1234-1234-1234567890ab' # Replace with actual ID
}
response = requests.get(
'https://api.nice.incontact.com/wfaapi/v1/agents/states',
headers=headers,
params=params
)
print(response.json())
Make sure the agentIds value matches the UUID of the logged-in agent. If you’re unsure of the ID, you can fetch it from the /agents endpoint first. Also, double-check that the OAuth token has the wfm:agent:view scope. Missing that scope will silently fail or return empty data depending on the client implementation. It’s a common gotcha when moving from manual testing to scripted automation. The API is strict about filtering for performance reasons.