Agent Scripting API 422 Unprocessable Entity on Dynamic Variable Injection

Looking for advice on a persistent validation error when attempting to inject dynamic carrier data into agent scripts via the POST /api/v2/analytics/real-time/agent-scripts endpoint. We are managing 15 BYOC trunks across APAC regions, and the current requirement is to display the active carrier’s latency status directly within the agent’s softphone interface during inbound calls. The goal is to help agents identify if a call is routed through a degraded secondary trunk without requiring manual lookup.

The issue arises when the script payload includes a variable reference to the call’s originating trunk ID. While the API accepts static text and standard system variables like {agent.name}, it returns a 422 Unprocessable Entity when the JSON body contains a nested object referencing {call.trunk.id} or {call.media.stream.latency}. The error message provided in the response body is generic: "message": "The request was well-formed but was unable to be followed due to semantic errors." This lack of specificity makes it difficult to determine if the issue lies with the variable syntax, the permissions scope of the API key, or a limitation in the real-time analytics engine’s ability to resolve carrier-specific metadata in this context.

We have verified that the API key has analytics:read and agent-scripting:write scopes. The environment is Genesys Cloud version 2024-05. The following payload triggers the failure consistently:

{
 "scriptText": "Current Carrier Status: {{carrierStatus}}",
 "variables": [
 {
 "name": "carrierStatus",
 "value": "Latency: {call.media.stream.latency}ms via {call.trunk.id}"
 }
 ],
 "targetId": "agent-uuid-here",
 "type": "popup"
}

Is there a known restriction on exposing trunk-level metadata in real-time scripts, or is the syntax for variable interpolation different for BYOC-specific attributes? We need a reliable way to surface this data to agents during high-volume periods.