Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Task Reservation Resource


(warning)

Warning

Pagination is not supported under this resource. Please avoid usage of the page query parameter.


Reservation Instance Subresource

reservation page anchor

TaskRouter creates a Reservation subresource whenever a Task is reserved for a Worker. TaskRouter will provide the details of this Reservation Instance subresource in the Assignment Callback HTTP request it makes to your application server.

You have multiple options for handling a Reservation:

  1. Respond to the Assignment Callback with an Assignment Instruction.
  2. Call the REST API with how to handle it.
  3. Allow your Worker to decide if they can take the Reservation with the Worker JS SDK .

The following details the REST API.

Important: If you do not respond with how to handle your Reservation within the TaskReservationTimeout configured on a Workflow, then the Reservation will timeout and the Task will be available for other workers.




Retrieve a Reservation

action-get page anchor

Resource URI

resource-uri page anchor

_10
GET /v1/Workspaces/{WorkspaceSid}/Tasks/{TaskSid}/Reservations/{ReservationSid}

Returns the single reservation resource identified by {ReservationSid}.

Example

example page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.tasks('WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.reservations('WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.fetch()
_12
.then(reservation => console.log(reservation.workerName));

Output

_17
{
_17
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"date_created": "2014-05-14T10:50:02Z",
_17
"date_updated": "2014-05-15T16:03:42Z",
_17
"links": {
_17
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
},
_17
"reservation_status": "accepted",
_17
"sid": "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"task_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations/WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker_name": "Doug",
_17
"worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
}

A Reservation has the following properties.

FieldDescription
SidThe unique ID of this Reservation.
AccountSidThe ID of the Account that owns this Task
WorkspaceSidThe ID of the Workspace that this task is contained within.
TaskSidThe ID of the reserved Task
WorkerSidThe ID of the reserved Worker
WorkerNameHuman readable description of the Worker that is reserved
ReservationStatusThe current status of the reservation. See the table below for possible values.

Possible values for ReservationStatus:

StatusDescription
acceptedThe Reservation was accepted by the Worker.
canceledThe Reservation was canceled because the reservation timeout was reached.
completedThe Reservation was marked as completed.
pendingA Worker has been reserved for this task and TaskRouter is waiting on a reservation response.
rejectedThe Reservation was rejected by the Worker.
rescindedThe Reservation was removed from the Worker.
timeoutThe Reservation timed out waiting for a response. When this happens, the Task will remain in the queue and TaskRouter will attempt to assign the Task to the next eligible Worker.
wrappingThe Worker has finished the primary work and is finishing additional duties for the Reservation.


Update Reservation

action-update page anchor

_10
POST /v1/Workspaces/{WorkspaceSid}/Tasks/{TaskSid}/Reservations/{ReservationSid}

To indicate that a Worker has accepted or rejected a Reservation, you make an HTTP POST request to a Reservation instance resource URI.

You can issue a simple Accept or Reject request. You can also issue an Instruction, similar to Responding to an Assignment Callback. We'll detail what parameters need to be provided for each method:

  1. Accept a Reservation
  2. Reject a Reservation
  3. Issue a Conference Instruction
  4. Issue a Dequeue Instruction
  5. Issue a Call Instruction
  6. Redirect an active phone call to TwiML document

Accept a Reservation

accept page anchor

Accepting a reservation means that the worker will work on the task, but you will need to do whatever work is required to connect the details of that task to the worker. You can think of accept as the bare minimum option for task acceptance. For voice tasks, the other methods described below are supersets of accept.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.tasks('WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.reservations('WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.update({reservationStatus: 'accepted'})
_12
.then(reservation => console.log(reservation.workerName));

Output

_17
{
_17
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"date_created": "2014-05-14T10:50:02Z",
_17
"date_updated": "2014-05-15T16:03:42Z",
_17
"links": {
_17
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
},
_17
"reservation_status": "accepted",
_17
"sid": "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"task_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations/WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker_name": "Doug",
_17
"worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
}

FieldRequired?Description
ReservationStatusYesaccepted. Specifying accepted means the Worker has received the Task and will process it. TaskRouter will no longer consider this task eligible for assignment, and no other Worker will receive this Task. (🏢 not PII )

Reject a Reservation

reject page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.tasks('WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.reservations('WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.update({reservationStatus: 'rejected'})
_12
.then(reservation => console.log(reservation.workerName));

Output

_17
{
_17
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"date_created": "2014-05-14T10:50:02Z",
_17
"date_updated": "2014-05-15T16:03:42Z",
_17
"links": {
_17
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
},
_17
"reservation_status": "rejected",
_17
"sid": "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"task_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations/WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker_name": "Doug",
_17
"worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
}

FieldRequired?Description
ReservationStatusYesrejected. Specifying rejected means the Worker has refused the assignment and TaskRouter will attempt to assign this Task to the next eligible Worker. (🏢 not PII )
WorkerActivitySidNoIf rejecting a reservation, change the worker that is tied to this reservation to the supplied activity. If not provided, the WorkerPreviousActivitySid on the Reservation will be used. (🏢 not PII )

Important: Tasks are automatically canceled after 1,000 rejections.

Please note: Although Tasks have always been cancelled after 1,000 rejections, the documentation previously incorrectly showed that Tasks are automatically cancelled after 10 rejections. If your solution requires Tasks to be cancelled after 10 rejections instead, please contact our support team(link takes you to an external page) for help.

Please see Manually accepting or rejecting a reservation for more information.

Conference Instruction

conference page anchor
(information)

Info

Conference instruction is the recommended way to connect calls between customer and agents. This should be used in almost all cases instead of dequeue or call for call center scenarios

Conference instruction takes care of a lot of the call orchestration which you would otherwise do yourself. For a given call represented by a task in TaskRouter, issuing a conference instruction will:

  • Call the worker on either the specified contact_uri of the worker, or the provided to field
  • Monitor call status to check that the agent has answered the call
  • Put the agent call into a Conference, named by TaskSid
  • Monitor that the above has succeeded
  • Move the caller out of the queue and into the conference
  • Mark the task as accepted if and only if all the above succeeded, and handle corner cases (such as caller hangs up during this process) gracefully.

Note that conference instruction works out of the box with calls that have been in TaskRouter using the native TaskRouter integration. If you are creating the task manually for a voice call, in order to use conference instruction you must at minimum include in the Task Attributes {"call_sid" : "<callsid>", "to" : "<E.164 to number>"}

Update Conference Instructions

update-conference-instructions page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_17
// Download the helper library from https://www.twilio.com/docs/node/install
_17
// Find your Account SID and Auth Token at twilio.com/console
_17
// and set the environment variables. See http://twil.io/secure
_17
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_17
const authToken = process.env.TWILIO_AUTH_TOKEN;
_17
const client = require('twilio')(accountSid, authToken);
_17
_17
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_17
.tasks('WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_17
.reservations('WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_17
.update({
_17
instruction: 'conference',
_17
from: '+18001231234',
_17
statusCallback: 'https://www.example.com/ConferenceEvents',
_17
conferenceStatusCallbackEvent: ['start', 'end', 'join', 'leave', 'mute', 'hold']
_17
})
_17
.then(reservation => console.log(reservation.workerName));

Output

_17
{
_17
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"date_created": "2014-05-14T10:50:02Z",
_17
"date_updated": "2014-05-15T16:03:42Z",
_17
"links": {
_17
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
},
_17
"reservation_status": "accepted",
_17
"sid": "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"task_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations/WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker_name": "Doug",
_17
"worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
}

Conference instruction uses the Conference Participants API. All values valid for that API can be provided as part of the conference instruction. Note that those parameter names are not replicated here. Please refer to linked documentation for valid values.

Note that the Participant API parameters provided apply to the worker leg of the call, not the customer leg of the call. In particular, note that endConferenceOnExit can only be set for the worker leg. If the customer hangs up if you want the agent call leg to be torn down you should do that via API.

FieldRequired?Description
InstructionYesConference (🏢 not PII )
ToNoThe contact URI of the Worker. A phone number or client ID. Required if the worker's attributes do not include a "contact_uri" property. (📇 PII )
FromNoThe caller ID for the call to the worker. Note: This needs to be a verified Twilio number. If you need this to be the original caller number, please contact Support (📇 PII )
PostWorkActivitySidNo(Deprecated) The activity to move a worker to after executing a conference instruction. Not valid in multi-tasking workspaces. (🏢 not PII )
TimeoutNoThe integer number of seconds that Twilio should allow the phone associated with "contact_uri" to ring before assuming there is no answer. Default is 60 seconds, the maximum is 999 seconds. Note, you could set this to a low value, such as 15, to hang up before reaching an answering machine or voicemail. (🏢 not PII )
All other Participant API possible parameters except for the following: jitter-buffer-size caller-id byoc recording-track label recording-status-callback-event conference-recording-status-callback-event coaching call-sid-to-coach call-reason speakerNoSee linked documentation

Note: A property of contact_uri is required on the WorkerAttributes to indicate whom to call. See more information on this here.

Dequeue Instruction

dequeue page anchor
(warning)

Warning

In most situations we would recommend you use Conference Instruction instead of dequeue

Update Dequeue Instructions

update-dequeue-instructions page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_15
// Download the helper library from https://www.twilio.com/docs/node/install
_15
// Find your Account SID and Auth Token at twilio.com/console
_15
// and set the environment variables. See http://twil.io/secure
_15
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_15
const authToken = process.env.TWILIO_AUTH_TOKEN;
_15
const client = require('twilio')(accountSid, authToken);
_15
_15
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_15
.tasks('WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_15
.reservations('WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_15
.update({
_15
instruction: 'dequeue',
_15
dequeueFrom: '+18001231234'
_15
})
_15
.then(reservation => console.log(reservation.workerName));

Output

_17
{
_17
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"date_created": "2014-05-14T10:50:02Z",
_17
"date_updated": "2014-05-15T16:03:42Z",
_17
"links": {
_17
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
},
_17
"reservation_status": "accepted",
_17
"sid": "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"task_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations/WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker_name": "Doug",
_17
"worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
}

FieldRequired?Description
InstructionYesDequeue (🏢 not PII )
DequeueToNoThe contact URI of the Worker. A phone number or client ID. Required if the worker's attributes do not include a "contact_uri" property. (📇 PII )
DequeueFromYesThe caller ID for the call to the worker. Note: This needs to be a verified Twilio number. If you need this to be the original callee number, please contact Support (📇 PII )
DequeuePostWorkActivitySidNoThe activity to move a worker to after executing a dequeue instruction. (🏢 not PII )
DequeueRecordNoThe 'DequeueRecord' attribute lets you record both legs of a call. Set to "record-from-answer" to record the call from answer. Default to "do-not-record" which will not record the call. The RecordingUrl will be sent with DequeueStatusCallbackUrl. (🏢 not PII )
DequeueTimeoutNoThe integer number of seconds that Twilio should allow the phone associated with "contact_uri" to ring before assuming there is no answer. Default is 60 seconds, the maximum is 999 seconds. Note, you could set this to a low value, such as 15, to hangup before reaching an answering machine or voicemail. (🏢 not PII )
DequeueStatusCallbackUrlNoA URL that Twilio will send asynchronous webhook requests to on completed call event. **Note: TaskRouter sends "taskCallSid" as parameter with sid of the call that created the Task. This is very useful in the event a call to worker fails, where you could remove the original call from queue and send to voice mail or enqueue again with new workflow to route to different group of workers. (🏢 not PII )
DequeueStatusCallbackEventNoThe call progress events that will be sent via webhooks on a worker's call. Available values are initiated, ringing, answered, and completed. If you want to receive multiple events, please provide multiple DequeueStatusCallbackEvent values as individual parameters in the POST request. If no event is specified, defaults to completed. For example to receive webhooks on answered and completed events pass "DequeueStatusCallbackEvent=answered&DequeueStatusCallbackEvent=completed". Please click here for more details. (🏢 not PII )

Note: A property of contact_uri is required on the WorkerAttributes to indicate whom to call. See more information on this here.

Please see issuing a Dequeue Instruction for more information.

Call Instruction

call page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = require('twilio')(accountSid, authToken);
_18
_18
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_18
.tasks('WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_18
.reservations('WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_18
.update({
_18
instruction: 'call',
_18
callFrom: '+15558675310',
_18
callUrl: 'http://example.com/agent_answer',
_18
callStatusCallbackUrl: 'http://example.com/agent_answer_status_callbac',
_18
callAccept: true
_18
})
_18
.then(reservation => console.log(reservation.workerName));

Output

_17
{
_17
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"date_created": "2014-05-14T10:50:02Z",
_17
"date_updated": "2014-05-15T16:03:42Z",
_17
"links": {
_17
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
},
_17
"reservation_status": "accepted",
_17
"sid": "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"task_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations/WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker_name": "Doug",
_17
"worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
}

FieldRequired?Description
InstructionYesCall (🏢 not PII )
CallToNoThe contact URI of the Worker. A phone number or client ID. Required if the worker's attributes do not include a "contact_uri" property. (📇 PII )
CallFromYesThe caller ID to use when placing the outbound call (📇 PII )
CallUrlYesA valid TwiML URI that is executed on the answering Worker's leg. (🏢 not PII )
CallAcceptNoIf set to "true", the reservation will be accepted. Otherwise, a separate call to the REST API is responsible for moving the state to accept or reject. (🏢 not PII )
CallRecordNoThe 'CallRecord' attribute lets you record both legs of a call. Set to "record-from-answer" to record the call from answer. Default to "do-not-record" which will not record the call. The RecordingUrl will be sent with DequeueStatusCallbackUrl. (🏢 not PII )
CallTimeoutNoThe integer number of seconds that Twilio should allow the phone associated with "contact_uri" to ring before assuming there is no answer. Default is 60 seconds, the maximum is 999 seconds. Note, you could set this to a low value, such as 15, to hangup before reaching an answering machine or voicemail. (🏢 not PII )
CallStatusCallbackUrlNoA URL that Twilio will send asynchronous webhook requests to on completed call event. **Note: TaskRouter sends "taskCallSid" as parameter with sid of the call that created the Task. This is very useful in the event a call to worker fails, where you could remove the original call from queue and send to voice mail or enqueue again with new workflow to route to different group of workers. (🏢 not PII )

Note: A property of contact_uri is required on the WorkerAttributes to indicate whom to call. See more information on this here.

Please see issuing a Call Instruction for more information.

Redirect Instruction

redirect page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_16
// Download the helper library from https://www.twilio.com/docs/node/install
_16
// Find your Account SID and Auth Token at twilio.com/console
_16
// and set the environment variables. See http://twil.io/secure
_16
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16
const authToken = process.env.TWILIO_AUTH_TOKEN;
_16
const client = require('twilio')(accountSid, authToken);
_16
_16
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_16
.tasks('WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_16
.reservations('WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_16
.update({
_16
instruction: 'redirect',
_16
redirectCallSid: 'CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
_16
redirectUrl: 'http://example.com/assignment_redirect'
_16
})
_16
.then(reservation => console.log(reservation.workerName));

Output

_17
{
_17
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"date_created": "2014-05-14T10:50:02Z",
_17
"date_updated": "2014-05-15T16:03:42Z",
_17
"links": {
_17
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
},
_17
"reservation_status": "accepted",
_17
"sid": "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"task_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations/WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"worker_name": "Doug",
_17
"worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_17
}

FieldRequired?Description
InstructionYesRedirect (🏢 not PII )
RedirectCallSidYesThe Twilio call sid of the call which was parked in the queue(via enqueue for example). (🏢 not PII )
RedirectUrlYesA valid TwiML URI to redirect the call to. (🏢 not PII )
RedirectAcceptNoBoolean. If true, the reservation will be accepted, otherwise, it is your application's responsibility to accept or reject the task at a later point. Defaults to false. (🏢 not PII )

Please see Redirect a call to a new TwiML document for more information.

Reservations List Resource

reservations-list-resource page anchor

_10
GET /v1/Workspaces/{WorkspaceSid}/Tasks/{TaskSid}/Reservations

Returns a representation of all the list of Reservations waiting for a Task identified by {TaskSid}.

Example
example-8 page anchor

Retrieve all Reservations

retrieve-all-reservations page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.tasks('WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.reservations
_12
.list({limit: 20})
_12
.then(reservations => reservations.forEach(r => console.log(r.sid)));

Output

_30
{
_30
"meta": {
_30
"first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations?PageSize=50&Page=0",
_30
"key": "reservations",
_30
"next_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations?PageSize=50&Page=1",
_30
"page": 0,
_30
"page_size": 50,
_30
"previous_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations?PageSize=50&Page=0",
_30
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations?PageSize=50&Page=0"
_30
},
_30
"reservations": [
_30
{
_30
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_30
"date_created": "2014-05-14T10:50:02Z",
_30
"date_updated": "2014-05-15T16:03:42Z",
_30
"links": {
_30
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_30
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_30
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_30
},
_30
"reservation_status": "accepted",
_30
"sid": "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_30
"task_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_30
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations/WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_30
"worker_name": "Doug",
_30
"worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_30
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_30
}
_30
]
_30
}

FieldDescription
WorkerSidReturns the list of reservations for a task for a specified worker
ReservationStatusReturns the list of reservations for a task with a specified ReservationStatus

Rate this page: