Skip to contentSkip to navigationSkip to topbar
On this page

Task Channel Resource


Task Channels provide a mechanism to separate tasks of different types.

You can specify different concurrent capacity for tasks of each type. For example, one Worker might be able to handle 10 SMS Tasks at any given time, but only a single phone call Task. When MultiTasking is enabled, you can specify the task type by passing the Unique Name or SID of the Task Channel. For details on limitations around the Task Channel Unique Name, see the FAQ on the Multitasking page.


TaskChannel Properties

taskchannel-properties page anchor
(warning)

Warning

Task Channel friendlyName and uniqueName values do not support hyphens. Using hyphens may cause a parsing error.

(warning)

Warning

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

Property nameTypeRequiredDescriptionChild properties
account_sidSID<AC>

Optional

Not PII

The SID of the Account that created the Task Channel resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

date_updatedstring<date-time>

Optional

The date and time in GMT when the resource was last updated specified in ISO 8601(link takes you to an external page) format.


friendly_namestring

Optional

The string that you assigned to describe the resource.


sidSID<TC>

Optional

The unique string that we created to identify the Task Channel resource.

Pattern: ^TC[0-9a-fA-F]{32}$Min length: 34Max length: 34

unique_namestring

Optional

An application-defined string that uniquely identifies the Task Channel, such as voice or sms.


workspace_sidSID<WS>

Optional

The SID of the Workspace that contains the Task Channel.

Pattern: ^WS[0-9a-fA-F]{32}$Min length: 34Max length: 34

channel_optimized_routingboolean

Optional

Whether the Task Channel will prioritize Workers that have been idle. When true, Workers that have been idle the longest are prioritized.


urlstring<uri>

Optional

The absolute URL of the Task Channel resource.


linksobject<uri-map>

Optional

The URLs of related resources.


Create a TaskChannel resource

create-a-taskchannel-resource page anchor
POST https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/TaskChannels

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace that the new Task Channel belongs to.

Pattern: ^WS[0-9a-fA-F]{32}$Min length: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestringrequired

A descriptive string that you create to describe the Task Channel. It can be up to 64 characters long.


UniqueNamestringrequired

An application-defined string that uniquely identifies the Task Channel, such as voice or sms.


ChannelOptimizedRoutingboolean

Optional

Whether the Task Channel should prioritize Workers that have been idle. If true, Workers that have been idle the longest are prioritized.

Create a TaskChannelLink to code sample: Create a TaskChannel
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 createTaskChannel() {
11
const taskChannel = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.taskChannels.create({
14
friendlyName: "FriendlyName",
15
uniqueName: "UniqueName",
16
});
17
18
console.log(taskChannel.accountSid);
19
}
20
21
createTaskChannel();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"friendly_name": "FriendlyName",
6
"unique_name": "UniqueName",
7
"date_created": "2016-04-14T17:35:54Z",
8
"date_updated": "2016-04-14T17:35:54Z",
9
"channel_optimized_routing": true,
10
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels/TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
11
"links": {
12
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
13
}
14
}

Fetch a TaskChannel resource

fetch-a-taskchannel-resource page anchor
GET https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/TaskChannels/{Sid}

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the Task Channel to fetch.

Pattern: ^WS[0-9a-fA-F]{32}$Min length: 34Max length: 34

Sidstringrequired

The SID of the Task Channel resource to fetch.

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 fetchTaskChannel() {
11
const taskChannel = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.taskChannels("Sid")
14
.fetch();
15
16
console.log(taskChannel.accountSid);
17
}
18
19
fetchTaskChannel();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"date_created": "2016-04-14T17:35:54Z",
4
"date_updated": "2016-04-14T17:35:54Z",
5
"friendly_name": "Default",
6
"sid": "Sid",
7
"unique_name": "default",
8
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels/TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
9
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
10
"channel_optimized_routing": true,
11
"links": {
12
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
13
}
14
}

Read multiple TaskChannel resources

read-multiple-taskchannel-resources page anchor
GET https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/TaskChannels

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the Task Channel to read.

Pattern: ^WS[0-9a-fA-F]{32}$Min length: 34Max length: 34
Property nameTypeRequiredPIIDescription
PageSizeinteger

Optional

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum: 1Maximum: 1000

Pageinteger

Optional

The page index. This value is simply for client state.

Minimum: 0

PageTokenstring

Optional

The page token. This is provided by the API.

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 listTaskChannel() {
11
const taskChannels = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.taskChannels.list({ limit: 20 });
14
15
taskChannels.forEach((t) => console.log(t.accountSid));
16
}
17
18
listTaskChannel();

Output

1
{
2
"channels": [
3
{
4
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"date_created": "2016-04-14T17:35:54Z",
6
"date_updated": "2016-04-14T17:35:54Z",
7
"friendly_name": "Default",
8
"sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
9
"unique_name": "default",
10
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels/TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
11
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
12
"channel_optimized_routing": true,
13
"links": {
14
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
15
}
16
}
17
],
18
"meta": {
19
"first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels?PageSize=50&Page=0",
20
"key": "channels",
21
"next_page_url": null,
22
"page": 0,
23
"page_size": 50,
24
"previous_page_url": null,
25
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels?PageSize=50&Page=0"
26
}
27
}

Update a TaskChannel resource

update-a-taskchannel-resource page anchor
POST https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/TaskChannels/{Sid}

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the Task Channel to update.

Pattern: ^WS[0-9a-fA-F]{32}$Min length: 34Max length: 34

Sidstringrequired

The SID of the Task Channel resource to update.

Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestring

Optional

A descriptive string that you create to describe the Task Channel. It can be up to 64 characters long.


ChannelOptimizedRoutingboolean

Optional

Whether the TaskChannel should prioritize Workers that have been idle. If true, Workers that have been idle the longest are prioritized.

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 updateTaskChannel() {
11
const taskChannel = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.taskChannels("Sid")
14
.update({ friendlyName: "FriendlyName" });
15
16
console.log(taskChannel.accountSid);
17
}
18
19
updateTaskChannel();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"sid": "Sid",
5
"friendly_name": "FriendlyName",
6
"unique_name": "default",
7
"date_created": "2016-04-14T17:35:54Z",
8
"date_updated": "2016-04-14T17:35:54Z",
9
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels/TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
10
"channel_optimized_routing": true,
11
"links": {
12
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
13
}
14
}

Delete a TaskChannel resource

delete-a-taskchannel-resource page anchor
DELETE https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/TaskChannels/{Sid}

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the Task Channel to delete.

Pattern: ^WS[0-9a-fA-F]{32}$Min length: 34Max length: 34

Sidstringrequired

The SID of the Task Channel resource to delete.

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 deleteTaskChannel() {
11
await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.taskChannels("Sid")
14
.remove();
15
}
16
17
deleteTaskChannel();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.