CXone GET /agents/states returns empty array for logged in agent

Calling the CXone REST endpoint GET /api/v2/agents/states/{agentId} returns 200 OK but the response body contains an empty array []. The agent is definitely logged in and active in the WFM dashboard. I’ve checked the auth token and it has the correct wem scope. Here is the raw response:

{
 "code": 200,
 "data": []
}

Is there a specific filter parameter I’m missing?

The issue usually isn’t the endpoint itself but rather how you’re fetching the agent ID or the state history window. The /api/v2/agents/states/{agentId} endpoint returns the history of state changes, not the current live state. If the agent just logged in and hasn’t changed states, or if you’re querying a window with no events, you get an empty array. It’s also worth checking if the {agentId} you’re passing is the internal Genesys Cloud ID (UUID) and not the user’s email or extension. The API is strict about that.

Here’s how I typically handle this in our custom desktop app to get the actual current state, which is usually what people actually need:

// First, get the current state directly instead of history
const currentStates = await platformClient.WfmScheduleGroupsApi.getWfmAgentStates(agentId);

// If you absolutely need history, ensure you pass a valid range
const historyParams = {
 pageSize: 10,
 pageNumber: 1,
 // Ensure the time range covers recent activity
 filter: 'startTime>=2023-10-01T00:00:00Z' 
};
const history = await platformClient.WfmScheduleGroupsApi.getWfmAgentStatesHistory(agentId, historyParams);

Also, double-check your scopes. wem is for workforce management editing. Reading agent states usually requires wem:read or sometimes just agent:state:read depending on your org’s permissions model. If the agent is “logged in” in WFM but hasn’t explicitly set a state (like “Available” or “Busy”), the state history might be sparse.

I’d recommend switching to the getWfmAgentStates call for real-time status. It’s cleaner and avoids the pagination headaches of the history endpoint. If that still returns nothing, your agent ID is likely wrong. Log the UUID you’re using and compare it against the agent’s profile URL in the Genesys Cloud admin portal. The ID in the URL is the one the API expects.