We’ve got a Terraform module that provisions Genesys Cloud resources, and part of the validation suite involves programmatically triggering test calls to ensure queue routing works as expected. I’m using the Genesys Cloud Platform SDK for Python to automate this. The setup is straightforward: I get an agent’s ID, fetch their current state, and then fire off a POST to /api/v2/conversations/calls to initiate an outbound call on their behalf.
Here’s the payload I’m sending:
payload = {
"from": {
"phoneNumber": "+15551234567"
},
"to": {
"phoneNumber": "+15559876543"
},
"wrapUpCode": {
"id": "some-wrapup-id"
},
"context": {
"agentId": "agent-uuid-here"
}
}
The first call works perfectly. The conversation starts, I can see it in the UI, and the agent gets the ring. But when I try to initiate a second call immediately after the first one is still active, the API slaps me with a 400 Bad Request. The error message in the response body is pretty vague:
{
"code": "badRequest",
"message": "Invalid state for the requested operation."
}
I’ve checked the agent’s status, and they’re definitely in available or interacting state depending on the step. I know agents can’t handle multiple simultaneous outbound calls initiated via API if the skill isn’t configured for it, but I’m testing with a single-skill queue just to keep it simple. Is there a specific header I’m missing? Or maybe the context object needs more fields to tell Genesys it’s a new distinct conversation rather than trying to hijack the existing one? I’ve tried adding a conversationId in the context, but that just makes it worse. Feels like I’m hitting a rate limit or a state lock that isn’t documented clearly. Anyone else wrestle with this when scripting call flows?