Service Level calc from /api/v2/analytics/queues/summary returns weird percentages

I’ve been trying to build a custom dashboard that calculates Service Level (SL%) using the raw interval data from the Genesys Cloud Analytics API. The standard summary endpoint gives me a pre-calculated serviceLevelPercent, but I want to verify it against the raw counts because the numbers are drifting slightly in our internal reports.

I’m hitting GET /api/v2/analytics/queues/summary with a filter for the last hour, grouping by interval. The response looks fine, but when I sum up the answered and answeredWithinTarget fields across all intervals, my calculated percentage is way off. It’s coming out to 112%, which is obviously impossible.

Here’s the snippet I’m using in Python to process the response:

import requests
import json

def calculate_sl(data):
 total_answered = 0
 total_within_target = 0
 
 for interval in data['summaryResult']['intervals']:
 # Assuming 'conversations' is the key for call metrics
 metrics = interval.get('conversations', {})
 total_answered += metrics.get('answered', 0)
 total_within_target += metrics.get('answeredWithinTarget', 0)
 
 if total_answered == 0:
 return 0
 
 sl_percent = (total_within_target / total_answered) * 100
 return sl_percent

# Mock response structure
response_data = {
 "summaryResult": {
 "intervals": [
 {
 "interval": "2023-10-27T10:00:00.000Z",
 "conversations": {
 "answered": 100,
 "answeredWithinTarget": 85
 }
 },
 {
 "interval": "2023-10-27T10:05:00.000Z",
 "conversations": {
 "answered": 50,
 "answeredWithinTarget": 60 # This looks wrong? Or is it cumulative?
 }
 }
 ]
 }
}

print(calculate_sl(response_data))

The issue seems to be that answeredWithinTarget might be cumulative or includes calls that spilled over from previous intervals? Or maybe I’m summing the wrong fields. The documentation says answeredWithinTarget is the number of conversations answered within the target time, but it doesn’t explicitly say if it’s incremental per interval or a running total.

If it’s a running total, summing them across intervals would double-count. If it’s incremental, why would the second interval show 60 within target when only 50 were answered? That breaks the math.

Has anyone dug into the interval data structure before? Is there a specific field I should be using for the denominator instead of answered? I feel like I’m missing a basic concept about how these intervals aggregate.