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

Worker Resource


Workers represent an entity that is able to perform tasks, such as an agent working in a call center, or a salesperson handling leads.

The default maximum number of registered Workers that can be created in the system is 15,000.


Worker Properties

worker-properties page anchor
(warning)

Warning

Worker attribute values do not support hyphens. Using a hyphen in a worker attribute value may cause a parsing error.

(warning)

Warning

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

Worker Attributes
Every Worker has a set of Attributes that describe what sort of tasks the Worker is able to complete. Attributes are modeled as a JSON string and may contain string, integer, and array data. These attributes will be used to link a Worker to one or more TaskQueues, and thus determine which Tasks the Worker is eligible to handle.

For example, let's say we have two agents. The first worker, Alice, speaks English and handles Support and Sales Tasks:


_10
{
_10
"skills": ["support", "sales"],
_10
"languages":["english"]
_10
}

The second worker, Bob, handles only Sales requests and speaks Spanish and English:


_10
{
_10
"skills": ["sales"],
_10
"languages": ["spanish", "english"]
_10
}

(information)

Info

A property of contact_uri is required on the WorkerAttributes to indicate whom to call when issuing a Dequeue Instruction.


_10
{
_10
"skills": ["sales"],
_10
"languages": ["spanish", "english"],
_10
"contact_uri": "client\:Bob"
_10
}

Worker Activity

Each worker also has an Activity, represented by an ActivitySid. This Activity determines the worker's current state in the system, as well as whether the worker can accept new Task assignments.

Property nameTypePIIDescription
account_sidSID<AC>
Not PII

The SID of the Account that created the Worker resource.

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

activity_namestring

The friendly_name of the Worker's current Activity.


activity_sidSID<WA>

The SID of the Worker's current Activity.

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

attributesstring
PII MTL: 30 days

The JSON string that describes the Worker. For example: { "email": "Bob@example.com", "phone": "+5095551234" }. Note If this property has been assigned a value, it will only be displayed in FETCH actions that return a single resource. Otherwise, this property will be null, even if it has a value. This data is passed to the assignment_callback_url when TaskRouter assigns a Task to the Worker.


availableboolean

Whether the Worker is available to perform tasks.


date_status_changedstring<date-time>

The date and time in GMT of the last change to the Worker's activity specified in ISO 8601(link takes you to an external page) format. Used to calculate Workflow statistics.


date_updatedstring<date-time>

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

The string that you assigned to describe the resource. Friendly names are case insensitive, and unique within the TaskRouter Workspace.


sidSID<WK>

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

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

workspace_sidSID<WS>

The SID of the Workspace that contains the Worker.

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

urlstring<uri>

The absolute URL of the Worker resource.


linksobject<uri-map>

The URLs of related resources.


Create a Worker resource

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

Path parameters

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

The SID of the Workspace that the new Worker belongs to.

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

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


ActivitySidSID<WA>Optional

The SID of a valid Activity that will describe the new Worker's initial state. See Activities for more information. If not provided, the new Worker's initial state is the default_activity_sid configured on the Workspace.

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

AttributesstringOptional

A valid JSON string that describes the new Worker. For example: { "email": "Bob@example.com", "phone": "+5095551234" }. This data is passed to the assignment_callback_url when TaskRouter assigns a Task to the Worker. Defaults to {}.

Create a Worker

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

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.workers
_11
.create({friendlyName: 'friendly_name'})
_11
.then(worker => console.log(worker.sid));

Output

_25
{
_25
"sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"friendly_name": "NewWorker",
_25
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"activity_sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"activity_name": "Offline",
_25
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"attributes": {},
_25
"available": false,
_25
"date_created": "2017-05-30T23:19:38Z",
_25
"date_updated": "2017-05-30T23:19:38Z",
_25
"date_status_changed": "2017-05-30T23:19:38Z",
_25
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"links": {
_25
"channels": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_25
"activity": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Activities/WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/Statistics",
_25
"real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/RealTimeStatistics",
_25
"cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/CumulativeStatistics",
_25
"worker_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
_25
"worker_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_25
"reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations"
_25
}
_25
}


GET https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Workers/{Sid}

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the Worker to fetch.

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

SidSID<WK>required

The SID of the Worker resource to fetch.

Pattern: ^WK[0-9a-fA-F]{32}$Min length: 34Max length: 34
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

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

Output

_25
{
_25
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"activity_name": "available",
_25
"activity_sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"attributes": {},
_25
"available": false,
_25
"date_created": "2017-05-30T23:32:39Z",
_25
"date_status_changed": "2017-05-30T23:32:39Z",
_25
"date_updated": "2017-05-30T23:32:39Z",
_25
"friendly_name": "NewWorker3",
_25
"sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"links": {
_25
"channels": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_25
"activity": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Activities/WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/Statistics",
_25
"real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/RealTimeStatistics",
_25
"cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/CumulativeStatistics",
_25
"worker_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
_25
"worker_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_25
"reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations"
_25
}
_25
}


Read multiple Worker resources

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

By default, this will return the first 50 Workers. Supply a PageSize parameter to fetch more than 50 Workers. See pagination information for more information.

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the Workers to read.

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

The activity_name of the Worker resources to read.


ActivitySidSID<WA>Optional

The activity_sid of the Worker resources to read.

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

AvailablestringOptional

Whether to return only Worker resources that are available or unavailable. Can be true, 1, or yes to return Worker resources that are available, and false, or any value returns the Worker resources that are not available.


FriendlyNamestringOptional

The friendly_name of the Worker resources to read.


TargetWorkersExpressionstringOptional

Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: sid, friendly_name, activity_sid, or activity_name


TaskQueueNamestringOptional

The friendly_name of the TaskQueue that the Workers to read are eligible for.


TaskQueueSidSID<WQ>Optional

The SID of the TaskQueue that the Workers to read are eligible for.

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

OrderingstringOptional

Sorting parameter for Workers


PageSizeintegerOptional

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

Minimum: 1Maximum: 1000

PageintegerOptional

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

Minimum: 0

PageTokenstringOptional

The page token. This is provided by the API.

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

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

Output

_39
{
_39
"meta": {
_39
"page": 0,
_39
"page_size": 50,
_39
"first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers?Available=available&TargetWorkersExpression=target_workers_expression&TaskQueueName=task_queue_name&ActivityName=activity_name&ActivitySid=WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&TaskQueueSid=WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&FriendlyName=friendly_name&PageSize=50&Page=0",
_39
"previous_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers?Available=available&TargetWorkersExpression=target_workers_expression&TaskQueueName=task_queue_name&ActivityName=activity_name&ActivitySid=WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&TaskQueueSid=WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&FriendlyName=friendly_name&PageSize=50&Page=0",
_39
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers?Available=available&TargetWorkersExpression=target_workers_expression&TaskQueueName=task_queue_name&ActivityName=activity_name&ActivitySid=WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&TaskQueueSid=WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&FriendlyName=friendly_name&PageSize=50&Page=0",
_39
"next_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers?Available=available&TargetWorkersExpression=target_workers_expression&TaskQueueName=task_queue_name&ActivityName=activity_name&ActivitySid=WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&TaskQueueSid=WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&FriendlyName=friendly_name&PageSize=50&Page=1",
_39
"key": "workers"
_39
},
_39
"workers": [
_39
{
_39
"sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"friendly_name": "testWorker",
_39
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"activity_sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"activity_name": "Offline",
_39
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"attributes": {},
_39
"available": false,
_39
"date_created": "2017-05-30T23:05:29Z",
_39
"date_updated": "2017-05-30T23:05:29Z",
_39
"date_status_changed": "2017-05-30T23:05:29Z",
_39
"operating_unit_sid": "OUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"links": {
_39
"channels": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_39
"activity": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Activities/WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/Statistics",
_39
"real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/RealTimeStatistics",
_39
"cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/CumulativeStatistics",
_39
"worker_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
_39
"worker_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_39
"reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations"
_39
}
_39
}
_39
]
_39
}

List Workers with Target Expression

list-workers-with-target-expression page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = require('twilio')(accountSid, authToken);
_14
_14
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_14
.workers
_14
.list({
_14
targetWorkersExpression: `name IN ['Alice','Bob','Connie','David']`,
_14
limit: 20
_14
})
_14
.then(workers => workers.forEach(w => console.log(w.sid)));

Output

_39
{
_39
"meta": {
_39
"page": 0,
_39
"page_size": 50,
_39
"first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers?Available=available&TargetWorkersExpression=target_workers_expression&TaskQueueName=task_queue_name&ActivityName=activity_name&ActivitySid=WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&TaskQueueSid=WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&FriendlyName=friendly_name&PageSize=50&Page=0",
_39
"previous_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers?Available=available&TargetWorkersExpression=target_workers_expression&TaskQueueName=task_queue_name&ActivityName=activity_name&ActivitySid=WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&TaskQueueSid=WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&FriendlyName=friendly_name&PageSize=50&Page=0",
_39
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers?Available=available&TargetWorkersExpression=target_workers_expression&TaskQueueName=task_queue_name&ActivityName=activity_name&ActivitySid=WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&TaskQueueSid=WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&FriendlyName=friendly_name&PageSize=50&Page=0",
_39
"next_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers?Available=available&TargetWorkersExpression=target_workers_expression&TaskQueueName=task_queue_name&ActivityName=activity_name&ActivitySid=WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&TaskQueueSid=WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&FriendlyName=friendly_name&PageSize=50&Page=1",
_39
"key": "workers"
_39
},
_39
"workers": [
_39
{
_39
"sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"friendly_name": "testWorker",
_39
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"activity_sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"activity_name": "Offline",
_39
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"attributes": {},
_39
"available": false,
_39
"date_created": "2017-05-30T23:05:29Z",
_39
"date_updated": "2017-05-30T23:05:29Z",
_39
"date_status_changed": "2017-05-30T23:05:29Z",
_39
"operating_unit_sid": "OUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"links": {
_39
"channels": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_39
"activity": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Activities/WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_39
"statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/Statistics",
_39
"real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/RealTimeStatistics",
_39
"cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/CumulativeStatistics",
_39
"worker_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
_39
"worker_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_39
"reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations"
_39
}
_39
}
_39
]
_39
}

You can use the TargetWorkersExpression parameter to see which workers are matching the expression, or to understand why a certain queue isn't mapping to the workers you would expect.

This example checks which workers have a name attribute of Alice, Bob, Connie or David - and, by extension, if we had a queue that mapped to workers with those names, we can be confident that these workers would be associated with the queue.


Update a Worker resource

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

Updating a Worker's current activity is a common operation in any TaskRouter application. You can do this using TaskRouter's Worker.js library, or using this REST API.

Property nameTypeRequiredPIIDescription
If-MatchstringOptional

The If-Match HTTP request header

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the Worker to update.

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

SidSID<WK>required

The SID of the Worker resource to update.

Pattern: ^WK[0-9a-fA-F]{32}$Min length: 34Max length: 34
Property nameTypeRequiredPIIDescription
ActivitySidSID<WA>Optional

The SID of a valid Activity that will describe the Worker's initial state. See Activities for more information.

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

AttributesstringOptional

The JSON string that describes the Worker. For example: { "email": "Bob@example.com", "phone": "+5095551234" }. This data is passed to the assignment_callback_url when TaskRouter assigns a Task to the Worker. Defaults to {}.


FriendlyNamestringOptional

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


RejectPendingReservationsbooleanOptional

Whether to reject the Worker's pending reservations. This option is only valid if the Worker's new Activity resource has its availability property set to False.

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

_13
// Download the helper library from https://www.twilio.com/docs/node/install
_13
// Find your Account SID and Auth Token at twilio.com/console
_13
// and set the environment variables. See http://twil.io/secure
_13
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_13
const authToken = process.env.TWILIO_AUTH_TOKEN;
_13
const client = require('twilio')(accountSid, authToken);
_13
_13
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_13
.workers('WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_13
.update({
_13
activitySid: 'WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
_13
})
_13
.then(worker => console.log(worker.activityName));

Output

_25
{
_25
"sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"friendly_name": "blah",
_25
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"activity_sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"activity_name": "Offline",
_25
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"attributes": {},
_25
"available": false,
_25
"date_created": "2017-05-30T23:32:22Z",
_25
"date_updated": "2017-05-31T00:05:57Z",
_25
"date_status_changed": "2017-05-30T23:32:22Z",
_25
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"links": {
_25
"channels": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_25
"activity": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Activities/WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/Statistics",
_25
"real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/RealTimeStatistics",
_25
"cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/CumulativeStatistics",
_25
"worker_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
_25
"worker_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels",
_25
"reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Reservations"
_25
}
_25
}


Delete a Worker resource

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

Property nameTypeRequiredPIIDescription
If-MatchstringOptional

The If-Match HTTP request header

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the Worker to delete.

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

SidSID<WK>required

The SID of the Worker resource to delete.

Pattern: ^WK[0-9a-fA-F]{32}$Min length: 34Max length: 34
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.workers('WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.remove();

(information)

Info

If you wish to view Reservations for a particular worker, use the Worker Reservation Resource.


Rate this page: