Skip to contentSkip to navigationSkip to topbar
On this page

Worker Channel Resource


Worker Channels show the Worker's capacity for handling multiple concurrent Tasks. Workers receive Task reservation requests in parallel for each task type until the configured Task Channel capacity is reached. In addition, Worker Channels can also be marked as unavailable, which is useful for temporarily removing the capacity for a given Worker Channel and then restoring to the previous capacity when marking available again.


Channel Properties

channel-properties page anchor
Property nameTypeRequiredDescriptionChild properties
account_sidSID<AC>

Optional

Not PII

The SID of the Account that created the Worker resource.

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

assigned_tasksinteger

Optional

The total number of Tasks assigned to Worker for the TaskChannel type.

Default: 0

availableboolean

Optional

Whether the Worker should receive Tasks of the TaskChannel type.


available_capacity_percentageinteger

Optional

The current percentage of capacity the TaskChannel has available. Can be a number between 0 and 100. A value of 0 indicates that TaskChannel has no capacity available and a value of 100 means the Worker is available to receive any Tasks of this TaskChannel type.

Default: 0

configured_capacityinteger

Optional

The current configured capacity for the WorkerChannel. TaskRouter will not create any reservations after the assigned Tasks for the Worker reaches the value.

Default: 0

date_updatedstring<date-time>

Optional

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


sidSID<WC>

Optional

The unique string that we created to identify the WorkerChannel resource.

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

task_channel_sidSID<TC>

Optional

The SID of the TaskChannel.

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

task_channel_unique_namestring

Optional

The unique name of the TaskChannel, such as voice or sms.


worker_sidSID<WK>

Optional

The SID of the Worker that contains the WorkerChannel.

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

workspace_sidSID<WS>

Optional

The SID of the Workspace that contains the WorkerChannel.

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

urlstring<uri>

Optional

The absolute URL of the WorkerChannel resource.


Fetch a WorkerChannel resource

fetch-a-workerchannel-resource page anchor
GET https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Workers/{WorkerSid}/Channels/{Sid}

Returns a single Worker Channel resource identified by either WorkerChannelUniqueName or WorkerChannelSid

Path parameters

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

The SID of the Workspace with the WorkerChannel to fetch.

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

WorkerSidSID<WK>required

The SID of the Worker with the WorkerChannel to fetch.

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

Sidstringrequired

The SID of the WorkerChannel to fetch.

Fetch a ChannelLink to code sample: Fetch a Channel
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 fetchWorkerChannel() {
11
const workerChannel = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.workers("WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.workerChannels("Sid")
15
.fetch();
16
17
console.log(workerChannel.accountSid);
18
}
19
20
fetchWorkerChannel();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"assigned_tasks": 0,
4
"available": true,
5
"available_capacity_percentage": 100,
6
"configured_capacity": 1,
7
"date_created": "2016-04-14T17:35:54Z",
8
"date_updated": "2016-04-14T17:35:54Z",
9
"sid": "Sid",
10
"task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
11
"task_channel_unique_name": "default",
12
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
15
}

Read multiple WorkerChannel resources

read-multiple-workerchannel-resources page anchor
GET https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Workers/{WorkerSid}/Channels

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the WorkerChannels to read.

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

WorkerSidSID<WK>required

The SID of the Worker with the WorkerChannels to read.

Pattern: ^WK[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 listWorkerChannel() {
11
const workerChannels = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.workers("WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.workerChannels.list({ limit: 20 });
15
16
workerChannels.forEach((w) => console.log(w.accountSid));
17
}
18
19
listWorkerChannel();

Output

1
{
2
"meta": {
3
"first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0",
4
"key": "channels",
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/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0"
10
},
11
"channels": [
12
{
13
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"assigned_tasks": 0,
15
"available": true,
16
"available_capacity_percentage": 100,
17
"configured_capacity": 1,
18
"date_created": "2016-04-14T17:35:54Z",
19
"date_updated": "2016-04-14T17:35:54Z",
20
"sid": "WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
21
"task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
22
"task_channel_unique_name": "default",
23
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
24
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
25
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
26
}
27
]
28
}

Update a WorkerChannel resource

update-a-workerchannel-resource page anchor
POST https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Workers/{WorkerSid}/Channels/{Sid}

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the WorkerChannel to update.

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

WorkerSidSID<WK>required

The SID of the Worker with the WorkerChannel to update.

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

Sidstringrequired

The SID of the WorkerChannel to update.

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

Optional

The total number of Tasks that the Worker should handle for the TaskChannel type. TaskRouter creates reservations for Tasks of this TaskChannel type up to the specified capacity. If the capacity is 0, no new reservations will be created.


Availableboolean

Optional

Whether the WorkerChannel is available. Set to false to prevent the Worker from receiving any new Tasks of this TaskChannel type.

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 updateWorkerChannel() {
11
const workerChannel = await client.taskrouter.v1
12
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.workers("WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.workerChannels("Sid")
15
.update({ capacity: 42 });
16
17
console.log(workerChannel.accountSid);
18
}
19
20
updateWorkerChannel();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"assigned_tasks": 0,
4
"available": true,
5
"available_capacity_percentage": 100,
6
"configured_capacity": 3,
7
"date_created": "2016-04-14T17:35:54Z",
8
"date_updated": "2016-04-14T17:35:54Z",
9
"sid": "Sid",
10
"task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
11
"task_channel_unique_name": "default",
12
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
15
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.