Statistics API /api/v2/analytics/queues/realtime returns empty data for active queues

We are building a Terraform module that validates queue health metrics before applying configuration changes. The requirement is to fetch real-time observation data, specifically the number of waiting interactions and available agents, for a set of queues defined in our state file. We are using the Statistics API endpoint /api/v2/analytics/queues/observations/query to get current state.

The request is authenticated using a client_credentials token, which we have verified is valid by successfully calling /api/v2/users/me. However, the response payload consistently returns an empty data array, even though we know these queues have active traffic.

Here is the Python snippet we are using to make the request:

import requests
import json

def get_queue_metrics(queue_id, auth_token):
 url = f"https://api.mypurecloud.com/api/v2/analytics/queues/observations/query"
 headers = {
 "Authorization": f"Bearer {auth_token}",
 "Content-Type": "application/json"
 }
 body = {
 "interval": "PT0S",
 "query": json.dumps({
 "predicates": [
 {
 "type": "in",
 "field": "queue.id",
 "values": [queue_id]
 }
 ]
 })
 }
 
 response = requests.post(url, headers=headers, json=body)
 return response.json()

# Usage
result = get_queue_metrics("abc-123-xyz", token)
print(result)

The response we receive looks like this:

{
 "totalCount": 0,
 "pageSize": 100,
 "page": 1,
 "data": []
}

We have tried adjusting the interval to PT1H but that only returns historical data, not the real-time snapshot we need for the validation logic. The documentation mentions that real-time data is available for queues, but we are not seeing any records. Is there a specific permission scope missing from our OAuth client, or is the query predicate format incorrect for the observations endpoint? We have checked the analytics permissions in the Genesys Cloud admin console, and the service account has analytics:read enabled.

3 Likes