Issue
The endpoint /api/v2/quality/evaluations/{evaluationId} keeps returning 200 OK while the surveyResponse object stays null. We’ve appended ?expand=interaction,survey to the query string, but the outbound JSON just drops the survey data anyway.
{
"status": 200,
"evaluation": {
"interactionId": "a1b2c3d4",
"surveyResponse": null
}
}
Documentation skips this exact mapping. Need the correct query structure for tied interactions.
The surveyResponse field being null isn’t a bug. It’s a scoping issue. The Quality API doesn’t automatically bridge the gap between the Interaction domain and the Survey domain just because you passed an expand parameter. You need to verify that the client credentials used for the Quality API call have the correct permissions to read the survey data, and that the survey is actually linked to the interaction in the backend.
Check these three things:
- Survey Association: Ensure the interaction actually has a survey response associated with it. If the customer didn’t complete the survey, or if the survey wasn’t triggered by the interaction flow, the data simply doesn’t exist. You can verify this by checking the interaction details directly via
/api/v2/analytics/interactions/summary or the specific interaction endpoint.
- API Scopes: The client ID you’re using needs the
quality:view scope, but more importantly, it needs access to the survey data. If the survey was created in a different division or by a different user, and the client credentials are restricted, you might hit a silent fail where the expand parameter is ignored due to insufficient rights.
- Data Latency: Survey data can take up to 15 minutes to propagate to the Quality API. If you’re calling this immediately after the interaction ends, the data might not be ready yet.
Here’s a quick check to see if the survey data exists at all:
GET /api/v2/surveys/responses/{surveyResponseId}
If that returns a 404, the survey response isn’t linked or doesn’t exist. If it returns data, then your Quality API client lacks the proper scopes or the interaction isn’t properly tagged with the survey ID.
The documentation notes that expand=survey pulls from the survey service, but it requires the interaction to have a valid surveyResponseId field populated first. If that field is empty on the interaction object, the expand does nothing.
Check the interaction object directly. Look for surveyResponseId. If it’s null, the problem is upstream in the survey trigger logic, not the Quality API.
The documentation for the Quality API explicitly states that surveyResponse is not populated via the standard expand parameters because it resides in a separate data store. The null value is expected behavior when the evaluation record hasn’t been fully synchronized with the survey completion event. You’re hitting a race condition where the interaction is closed before the survey payload is linked.
Don’t rely on the immediate response from the evaluation endpoint. Instead, poll the /api/v2/quality/evaluations/{evaluationId} endpoint with a retry mechanism or use the webhook event quality.evaluation.updated to trigger your payload extraction. The survey data only becomes available after the surveyResponse object is non-null, which can take up to 5 minutes depending on backend queue depth.
Here’s the corrected approach using a simple polling script in Python:
import requests
import time
def get_survey_response(eval_id, token):
headers = {"Authorization": f"Bearer {token}"}
for _ in range(10):
resp = requests.get(
f"https://mycompany.mygen.com/api/v2/quality/evaluations/{eval_id}",
headers=headers
)
data = resp.json()
if data.get("surveyResponse") is not None:
return data["surveyResponse"]
time.sleep(10) # Wait 10 seconds between checks
return None
This avoids the null pointer errors you’re seeing. The API is working as designed, but the timing is off. Ensure your integration handles the delay gracefully.