Agent Script payload rejected with 400 on /api/v2/scripts

resource “genesyscloud_script” “checkout_v3” {
name = “Checkout Flow”
flow { nodes { type = “scriptNode” config = jsonencode({ steps = [“verify”, “pay”] }) } }
}

Terraform doesn’t complain during plan. State locks after retry. CXone media engine drops a 400 on /api/v2/scripts.

  • Provider v1.104.0
  • EU-2 London region
  • Terraform v1.6.4
  • Manual API call yields invalid_script_structure

Parser chokes on the nested array despite matching the schema.

Cause: The /api/v2/scripts endpoint expects a strict JSON tree. The parser drops the payload when topology violates the schema, like a misrouted packet failing a QoS check. Check v2.14.0 rules here: https://developer.nice.com/docs/api/scripts

Solution: Flatten the config into a proper flow object with explicit start edges. Rerun the plan. It’s malformed routing logic, not bandwidth, causing the 400.

{
 "flow": {
 "start": "verify_node",
 "nodes": {
 "verify_node": {
 "type": "scriptNode",
 "steps": ["verify", "pay"]
 }
 }
 }
}

The /api/v2/scripts parser expects a strict tree, so you’ll need to define a start edge first. Then map each step inside a nodes object instead of a raw array. I’ve seen this exact mismatch when platformClient validates webhook events in Rails. Flattening the JSON usually clears the 400. Just swap the array for the object structure. Works every time.