Issue
In Twilio Flex, when an agent (or a plugin) tries to accept a task, the browser Twilio Console may show the following error:
Could not accept call: Request failed with status code 400. Reservation WRxxxxxxxxxxxxxxxx
not in expected state [pending] and cannot be updated to [onHold]
Product
Twilio Flex
Environment
legacy Twilio Console
Cause
This occurs when the same TaskRouter Reservation is accepted more than once.
A Reservation starts in the "pending" status. This means a qualified Flex agent has been found, and the system is waiting for a response from the agent.
When the agent attempts to accept the task, the Reservation resource moves into a protected, back-end state ("onHold") while Flex orchestration sets up the channel (e.g., creates a Conference for Voice or adds the agent to the Conversation/Interaction for Messaging).
A second attempt to accept the task while the Reservation is already "onHold" triggers this 400 error to prevent duplicate orchestration.
Common reasons for duplicate accepts:
- Triggering both auto-accept and a manual accept.
- Custom Flex plugins invoking
AcceptTaskin addition to the default action (e.g., not replacing the action, or registering multiple listeners). - Retry logic or race conditions calling
Reservation.accept()without checking the current status.
Resolution
If the task is connecting or connected, you can safely ignore the second error, it indicates the first accept is already in progress.
To prevent future duplicates:
UI/Plugins
- If customizing, use
Actions.replaceAction('AcceptTask', ...)instead of callingAcceptTaskin addition to the default handler. - Ensure listeners are registered only once and cleaned up (avoid duplicates on hot reload or component remount).
Server-side Solution
- If using a server-side solution to trigger Reservation acceptance, review your back-end code to prevent duplicate attempts to accept the task.
If the issue persists, gather the Task SID (WT…), Reservation SID (WR…), Worker SID (WK…), timestamp, and relevant logs/HAR files before contacting Support.
Additional Information
The initial accept continues normally; the error is for the duplicate request only.
For background on states and orchestration, see: