Studio Session Handover to Cognigy failing with 400 Bad Request

We’re trying to implement a session handover from a CXone Studio script to a NICE Cognigy voicebot. The flow works fine in the simulator, but in production, the transition fails consistently.

The Studio script uses the TransferToExternal action. I’ve configured the external URL and the payload correctly. Here is the JSON payload being sent:

{
 "sessionId": "{{session.id}}",
 "callerId": "{{session.caller.phoneNumber}}",
 "context": {
 "intent": "sales"
 }
}```

The Cognigy bot receives the initial connection, but the subsequent handover API call returns a `400 Bad Request`. The error message in the logs is vague: `Invalid session state for handover`.

I've checked the OAuth token generation code in the middleware. It's using the `bot:write` scope, which should be sufficient. Is there a specific header or parameter missing for Cognigy integration? The documentation is sparse on this edge case.