Calculating Service Level from /api/v2/analytics/users/summary interval data

I’m trying to calculate Service Level (SL) percentage using the raw interval data from the Analytics API instead of relying on the pre-aggregated report widgets. The endpoint is /api/v2/analytics/users/summary.

I’ve set up a script in CXone to fetch the JSON payload. The response contains arrays for offereds, handled, and abandoned. My logic is to sum offereds and handled across all intervals where waitTime is less than the SL threshold (e.g., 20 seconds).

Here is the logic I’m testing:

SET SL_Numerator = 0
SET SL_Denominator = 0

FOR EACH interval IN response.data.intervals:
 IF interval.offereds > 0:
 SL_Denominator = SL_Denominator + interval.offereds
 IF interval.handled > 0 AND interval.waitTime < 20000:
 SL_Numerator = SL_Numerator + interval.handled
 ENDIF
 ENDIF
ENDFOR

IF SL_Denominator > 0:
 SL_Percentage = (SL_Numerator / SL_Denominator) * 100
ELSE:
 SL_Percentage = 0
ENDIF

The issue is that interval.handled includes calls answered after the SL threshold too. The API doesn’t seem to separate “handled within SL” from “handled after SL” in the interval object itself. I see waitTime but it looks like an aggregate or average, not a per-call value.

Am I missing a specific field in the interval JSON? Or is the only way to get accurate SL from raw data to query the detailed call-level logs via a different endpoint? The summary endpoint feels insufficient for precise SL calculation if the handled count isn’t filtered by wait time at the source.