Agent Scripting API rejects AU DIDs with 400 validation error

Trying to push a dynamic compliance script to our Sydney agents using the Agent Scripting REST API. It’s working fine in staging, but production won’t accept the payload when we inject local AU DIDs. Console throws a 400 Bad Request on the /api/v2/scripts endpoint. Error log says Validation failed for phone_number: Invalid E.164 format for AU region. Base URL is set to mypurecloud.com.au and the scriptVersionId matches the latest draft.

The ACMA retention disclaimer block causes the real headache. It relies on a Data Action to pull the current timestamp, but the timezone offset keeps defaulting to PST instead of AEST. Voice latency spikes to 280ms during peak hours, and the script engine chokes before the agent even sees the prompt. We’ve switched the number format to +61, but the validation error still fires. Execution log shows context.phone_number as null after the split block. API response body returns a 500 Internal Server Error when forcing the region override. Tracing the request through Charles proxy shows the payload hitting the gateway fine, but the script service drops it.

Have you checked if the validation library on the backend is choking on the specific formatting of that disclaimer text? Sometimes the regex for E.164 gets too aggressive if there are hidden characters.

Try stripping the input strictly before sending. In Node, a simple replace usually fixes the invisible char issue.

const cleanNumber = phoneNumber.replace(/[^0-9+]/g, '');
if (!cleanNumber.startsWith('+')) {
 throw new Error('Missing country code');
}

Also, ensure you’re using application/json and not application/x-www-form-urlencoded for that PUT request. The SDK handles this, but raw fetch calls often default wrong. If it’s still failing, try sending a static +61212345678 instead of the variable. If that passes, the issue is definitely your string sanitization logic, not the API schema. Check the request headers in the network tab too.