Agent scripting api 400 on flow reference

looking for advice on agent scripting deployment. using gc cli v2.0.4. terraform apply fails with 400 bad request on genesyscloud_flow_resource. error says flow_id ‘f-123’ is invalid. verified flow exists in architect. id matches. region is us-east-1. script definition json parses fine locally. any ideas why the api rejects the valid flow ref during provisioning?

2 Likes

I’d suggest checking out at the flow status in Architect; it must be published before the API accepts the reference during provisioning. See support article KB-9921 for details on deployment prerequisites.

The problem here is the flow probably isn’t published yet. terraform needs that true state to link it.

  • flow publish status
  • genesyscloud_flow resource
  • state drift
1 Like

Check your flow publish status in Architect.

Cause:
Draft flows return 400s via API. The CLI needs a published state to validate the reference.

Solution:
Publish the flow in Architect, then run terraform apply. If it still fails, check the region endpoint config in your provider block.

I usually solve this by checking if the flow is actually published, but there’s a bigger risk here you might be missing. In regulated environments like ours, linking a script to an unpublished or draft flow via automation can create a compliance gap if the flow state changes unexpectedly during a legal hold or audit. The API might accept the ID, but if the flow isn’t locked down, your script could point to a void. Make sure your terraform state explicitly waits for the published status before proceeding with the script resource. It’s not just about the 400 error; it’s about ensuring the reference is stable for recording retention policies.

resource "genesyscloud_flow" "my_flow" {
 name = "Compliance Script Flow"
 published = true # Critical for audit trails
}

resource "genesyscloud_script" "my_script" {
 depends_on = [genesyscloud_flow.my_flow] # Explicit dependency
 flow_id = genesyscloud_flow.my_flow.id
}

Check your audit logs if the flow was ever unpublished recently.