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

Worker Statistics Resource


TaskRouter provides real-time, cumulative, and historical statistics for Workers. Historical statistics allow you to analyze data from the past 30 days. There are various APIs for retrieving the data that is meaningful to your business.

(warning)

Warning

These resources may not be accessible if your Workspace exceeds 100 workers. Please contact support for additional assistance.


WorkerStatistics Properties

workerstatistics-properties page anchor
Property nameTypePIIDescription
realtimeobject
Not PII

An object that contains the real-time statistics for the Worker.


cumulativeobject

An object that contains the cumulative statistics for the Worker.


account_sidSID<AC>

The SID of the Account that created the Worker resource.

Pattern: ^AC[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 statistics resource.

Minutes cannot be used in combination with StartDate and EndDate parameters. If no parameters are passed, 15 minutes will be the default.


Fetch All Worker Statistics

fetch-all-worker-statistics page anchor

_10
GET /v1/Workspaces/{WorkspaceSid}/Workers/Statistics

Path parameters

path-parameters page anchor
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
Property nameTypeRequiredPIIDescription
MinutesintegerOptional

Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.


EndDatestring<date-time>Optional

Only calculate statistics from this date and time and earlier, specified in GMT as an ISO 8601(link takes you to an external page) date-time.


TaskQueueSidSID<WQ>Optional

The SID of the TaskQueue for which to fetch Worker statistics.

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

TaskQueueNamestringOptional

The friendly_name of the TaskQueue for which to fetch Worker statistics.


FriendlyNamestringOptional

Only include Workers with friendly_name values that match this parameter.


TaskChannelstringOptional

Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its unique_name, such as voice, sms, or default.

Fetch a Worker Statistics Resource

fetch-a-worker-statistics-resource 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
.workers
_12
.statistics()
_12
.fetch()
_12
.then(workers_statistics => console.log(workers_statistics.realtime));

Output

_74
{
_74
"cumulative": {
_74
"reservations_created": 0,
_74
"reservations_accepted": 0,
_74
"reservations_rejected": 0,
_74
"reservations_timed_out": 0,
_74
"reservations_canceled": 0,
_74
"reservations_rescinded": 0,
_74
"activity_durations": [
_74
{
_74
"max": 0,
_74
"min": 900,
_74
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_74
"friendly_name": "Offline",
_74
"avg": 1080,
_74
"total": 5400
_74
},
_74
{
_74
"max": 0,
_74
"min": 900,
_74
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_74
"friendly_name": "Busy",
_74
"avg": 1012,
_74
"total": 8100
_74
},
_74
{
_74
"max": 0,
_74
"min": 0,
_74
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_74
"friendly_name": "Idle",
_74
"avg": 0,
_74
"total": 0
_74
},
_74
{
_74
"max": 0,
_74
"min": 0,
_74
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_74
"friendly_name": "Reserved",
_74
"avg": 0,
_74
"total": 0
_74
}
_74
],
_74
"start_time": "2008-01-02T00:00:00Z",
_74
"end_time": "2008-01-02T00:00:00Z"
_74
},
_74
"realtime": {
_74
"total_workers": 15,
_74
"activity_statistics": [
_74
{
_74
"friendly_name": "Idle",
_74
"workers": 0,
_74
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_74
},
_74
{
_74
"friendly_name": "Busy",
_74
"workers": 9,
_74
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_74
},
_74
{
_74
"friendly_name": "Offline",
_74
"workers": 6,
_74
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_74
},
_74
{
_74
"friendly_name": "Reserved",
_74
"workers": 0,
_74
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_74
}
_74
]
_74
},
_74
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_74
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_74
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/Statistics"
_74
}


Fetch Real-Time Worker Statistics

fetch-real-time-worker-statistics page anchor
(warning)

Warning

We recommended leveraging caching when utilizing this endpoint from your backend application to ensure this endpoint can support your scaling needs.

In scenarios where this endpoint would be used from a client application, we recommend implementing a sync layer, e.g., via Twilio Sync, to help synchronize this endpoint's state across all clients, and to ensure this endpoint can scale with your user growth.


_10
GET /v1/Workspaces/{WorkspaceSid}/Workers/RealTimeStatistics

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the resource to fetch.

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

Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its unique_name, such as voice, sms, or default.

Retrieve Real-Time Worker Statistics

retrieve-real-time-worker-statistics 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
.realTimeStatistics()
_11
.fetch()
_11
.then(workers_real_time_statistics => console.log(workers_real_time_statistics.activityStatistics));

Output

_28
{
_28
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_28
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_28
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/RealTimeStatistics",
_28
"total_workers": 15,
_28
"activity_statistics": [
_28
{
_28
"friendly_name": "Idle",
_28
"workers": 0,
_28
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_28
},
_28
{
_28
"friendly_name": "Busy",
_28
"workers": 9,
_28
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_28
},
_28
{
_28
"friendly_name": "Offline",
_28
"workers": 6,
_28
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_28
},
_28
{
_28
"friendly_name": "Reserved",
_28
"workers": 0,
_28
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_28
}
_28
]
_28
}

Real-time statistics relating to a list of Workers include the following:

PropertyDescription
TotalWorkersThe total number of Workers
ActivityStatisticsThe current Worker status count breakdown by Activity

Fetch Cumulative Worker Statistics

fetch-cumulative-worker-statistics page anchor

Cumulative statistics allow you to analyze Worker data from the past 30 days.


_10
GET /v1/Workspaces/{WorkspaceSid}/Workers/CumulativeStatistics

Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required

The SID of the Workspace with the resource to fetch.

Pattern: ^WS[0-9a-fA-F]{32}$Min length: 34Max length: 34
Property nameTypeRequiredPIIDescription
EndDatestring<date-time>Optional

Only calculate statistics from this date and time and earlier, specified in ISO 8601(link takes you to an external page) format.


MinutesintegerOptional

Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.


StartDatestring<date-time>Optional

Only calculate statistics from this date and time and later, specified in ISO 8601(link takes you to an external page) format.


TaskChannelstringOptional

Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its unique_name, such as voice, sms, or default.

Retrieve Cumulative Worker Statistics

retrieve-cumulative-worker-statistics 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
.cumulativeStatistics()
_11
.fetch()
_11
.then(workers_cumulative_statistics => console.log(workers_cumulative_statistics.startTime));

Output

_47
{
_47
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_47
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_47
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/CumulativeStatistics",
_47
"reservations_created": 100,
_47
"reservations_accepted": 100,
_47
"reservations_rejected": 100,
_47
"reservations_timed_out": 100,
_47
"reservations_canceled": 100,
_47
"reservations_rescinded": 100,
_47
"activity_durations": [
_47
{
_47
"max": 0,
_47
"min": 900,
_47
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_47
"friendly_name": "Offline",
_47
"avg": 1080,
_47
"total": 5400
_47
},
_47
{
_47
"max": 0,
_47
"min": 900,
_47
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_47
"friendly_name": "Busy",
_47
"avg": 1012,
_47
"total": 8100
_47
},
_47
{
_47
"max": 0,
_47
"min": 0,
_47
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_47
"friendly_name": "Idle",
_47
"avg": 0,
_47
"total": 0
_47
},
_47
{
_47
"max": 0,
_47
"min": 0,
_47
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_47
"friendly_name": "Reserved",
_47
"avg": 0,
_47
"total": 0
_47
}
_47
],
_47
"start_time": "2015-07-30T20:00:00Z",
_47
"end_time": "2015-07-30T20:00:00Z"
_47
}

Cumulative statistics relating to a list of Workers include the following over the interval:

PropertyDescription
ReservationsCreatedThe total number of Reservations that were created
ReservationsAcceptedThe total number of Reservations that were accepted
ReservationsRejectedThe total number of Reservations that were rejected
ReservationsTimedOutThe total number of Reservations that were timed out
ReservationsCanceledThe total number of Reservations that were canceled
ReservationsRescindedThe total number of Reservations that were rescinded
ActivityDurationsThe minimum, average, maximum and total time (in seconds) Workers spent in each Activity

Fetch A Specific Worker's Statistics

fetch-a-specific-workers-statistics page anchor

_10
GET /v1/Workspaces/{WorkspaceSid}/Workers/{WorkerSid}/Statistics

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
Property nameTypeRequiredPIIDescription
MinutesintegerOptional

Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.


StartDatestring<date-time>Optional

Only calculate statistics from this date and time and later, specified in ISO 8601(link takes you to an external page) format.


EndDatestring<date-time>Optional

Only include usage that occurred on or before this date, specified in GMT as an ISO 8601(link takes you to an external page) date-time.


TaskChannelstringOptional

Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its unique_name, such as voice, sms, or default.

Retrieve a Specific Worker's Statistics

retrieve-a-specific-workers-statistics 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
.workers('WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.statistics()
_12
.fetch()
_12
.then(worker_statistics => console.log(worker_statistics.cumulative));

Output

_50
{
_50
"cumulative": {
_50
"reservations_created": 100,
_50
"reservations_accepted": 100,
_50
"reservations_rejected": 100,
_50
"reservations_timed_out": 100,
_50
"reservations_canceled": 100,
_50
"reservations_rescinded": 100,
_50
"activity_durations": [
_50
{
_50
"max": 0,
_50
"min": 900,
_50
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_50
"friendly_name": "Offline",
_50
"avg": 1080,
_50
"total": 5400
_50
},
_50
{
_50
"max": 0,
_50
"min": 900,
_50
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_50
"friendly_name": "Busy",
_50
"avg": 1012,
_50
"total": 8100
_50
},
_50
{
_50
"max": 0,
_50
"min": 0,
_50
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_50
"friendly_name": "Idle",
_50
"avg": 0,
_50
"total": 0
_50
},
_50
{
_50
"max": 0,
_50
"min": 0,
_50
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_50
"friendly_name": "Reserved",
_50
"avg": 0,
_50
"total": 0
_50
}
_50
],
_50
"start_time": "2008-01-02T00:00:00Z",
_50
"end_time": "2008-01-02T00:00:00Z"
_50
},
_50
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_50
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_50
"worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_50
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workers/WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics"
_50
}


Rate this page: