Skip to contentSkip to navigationSkip to topbar
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
1
GET /v1/Workspaces/{WorkspaceSid}/Tasks/{TaskSid}/Reservations/{ReservationSid}
2

Returns the single reservation resource identified by {ReservationSid}.

Example

example page anchor
Fetch a ReservationLink to code sample: Fetch a Reservation
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchTaskReservation() {
11
const reservation = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.fetch();
16
17
console.log(reservation.accountSid);
18
}
19
20
fetchTaskReservation();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2014-05-14T10:50:02Z",
4
"date_updated": "2014-05-15T16:03:42Z",
5
"links": {
6
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
9
},
10
"reservation_status": "accepted",
11
"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
12
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"worker_name": "Doug",
15
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"attention": 0
18
}

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
1
POST /v1/Workspaces/{WorkspaceSid}/Tasks/{TaskSid}/Reservations/{ReservationSid}
2

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.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateTaskReservation() {
11
const reservation = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.update({ reservationStatus: "accepted" });
16
17
console.log(reservation.accountSid);
18
}
19
20
updateTaskReservation();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2014-05-14T10:50:02Z",
4
"date_updated": "2014-05-15T16:03:42Z",
5
"links": {
6
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
9
},
10
"reservation_status": "accepted",
11
"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
12
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"worker_name": "Doug",
15
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"attention": 0
18
}
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
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateTaskReservation() {
11
const reservation = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.update({ reservationStatus: "rejected" });
16
17
console.log(reservation.accountSid);
18
}
19
20
updateTaskReservation();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2014-05-14T10:50:02Z",
4
"date_updated": "2014-05-15T16:03:42Z",
5
"links": {
6
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
9
},
10
"reservation_status": "rejected",
11
"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
12
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"worker_name": "Doug",
15
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"attention": 0
18
}
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>"}

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateTaskReservation() {
11
const reservation = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.update({
16
conferenceStatusCallbackEvent: [
17
"start",
18
"end",
19
"join",
20
"leave",
21
"mute",
22
"hold",
23
],
24
from: "+18001231234",
25
instruction: "conference",
26
statusCallback: "https://www.example.com/ConferenceEvents",
27
});
28
29
console.log(reservation.accountSid);
30
}
31
32
updateTaskReservation();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2014-05-14T10:50:02Z",
4
"date_updated": "2014-05-15T16:03:42Z",
5
"links": {
6
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
9
},
10
"reservation_status": "accepted",
11
"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
12
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"worker_name": "Doug",
15
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"attention": 0
18
}

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. Must be a string. Required if the worker's attributes do not include a contact_uri property. (📇 PII )
FromNoThe caller ID for the call to the worker. Must be a string. 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: 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

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateTaskReservation() {
11
const reservation = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.update({
16
dequeueFrom: "+18001231234",
17
instruction: "dequeue",
18
});
19
20
console.log(reservation.accountSid);
21
}
22
23
updateTaskReservation();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2014-05-14T10:50:02Z",
4
"date_updated": "2014-05-15T16:03:42Z",
5
"links": {
6
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
9
},
10
"reservation_status": "accepted",
11
"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
12
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"worker_name": "Doug",
15
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"attention": 0
18
}
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
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateTaskReservation() {
11
const reservation = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.update({
16
callAccept: true,
17
callFrom: "+15558675310",
18
callStatusCallbackUrl: "http://example.com/agent_answer_status_callbac",
19
callUrl: "http://example.com/agent_answer",
20
instruction: "call",
21
});
22
23
console.log(reservation.accountSid);
24
}
25
26
updateTaskReservation();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2014-05-14T10:50:02Z",
4
"date_updated": "2014-05-15T16:03:42Z",
5
"links": {
6
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
9
},
10
"reservation_status": "accepted",
11
"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
12
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"worker_name": "Doug",
15
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"attention": 0
18
}
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
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateTaskReservation() {
11
const reservation = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.update({
16
instruction: "redirect",
17
redirectCallSid: "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
18
redirectUrl: "http://example.com/assignment_redirect",
19
});
20
21
console.log(reservation.accountSid);
22
}
23
24
updateTaskReservation();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2014-05-14T10:50:02Z",
4
"date_updated": "2014-05-15T16:03:42Z",
5
"links": {
6
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
9
},
10
"reservation_status": "accepted",
11
"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
12
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"worker_name": "Doug",
15
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"attention": 0
18
}
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
1
GET /v1/Workspaces/{WorkspaceSid}/Tasks/{TaskSid}/Reservations
2

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

Example
example-8 page anchor
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listTaskReservation() {
11
const reservations = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.reservations.list({ limit: 20 });
15
16
reservations.forEach((r) => console.log(r.accountSid));
17
}
18
19
listTaskReservation();

Output

1
{
2
"meta": {
3
"first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0",
4
"key": "reservations",
5
"next_page_url": null,
6
"page": 0,
7
"page_size": 50,
8
"previous_page_url": null,
9
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0"
10
},
11
"reservations": [
12
{
13
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"date_created": "2014-05-14T10:50:02Z",
15
"date_updated": "2014-05-15T16:03:42Z",
16
"links": {
17
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
18
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
19
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
20
},
21
"reservation_status": "accepted",
22
"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
23
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
24
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
25
"worker_name": "Doug",
26
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
27
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
28
"attention": 0
29
}
30
]
31
}
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

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.