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

_19
// Download the helper library from https://www.twilio.com/docs/node/install
_19
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19
_19
// Find your Account SID and Auth Token at twilio.com/console
_19
// and set the environment variables. See http://twil.io/secure
_19
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19
const authToken = process.env.TWILIO_AUTH_TOKEN;
_19
const client = twilio(accountSid, authToken);
_19
_19
async function fetchWorkerStatistics() {
_19
const statistic = await client.taskrouter.v1
_19
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.workers.statistics()
_19
.fetch();
_19
_19
console.log(statistic.realtime);
_19
}
_19
_19
fetchWorkerStatistics();

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": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_74
"friendly_name": "Offline",
_74
"avg": 1080,
_74
"total": 5400
_74
},
_74
{
_74
"max": 0,
_74
"min": 900,
_74
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_74
"friendly_name": "Busy",
_74
"avg": 1012,
_74
"total": 8100
_74
},
_74
{
_74
"max": 0,
_74
"min": 0,
_74
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_74
"friendly_name": "Idle",
_74
"avg": 0,
_74
"total": 0
_74
},
_74
{
_74
"max": 0,
_74
"min": 0,
_74
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_74
},
_74
{
_74
"friendly_name": "Busy",
_74
"workers": 9,
_74
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_74
},
_74
{
_74
"friendly_name": "Offline",
_74
"workers": 6,
_74
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_74
},
_74
{
_74
"friendly_name": "Reserved",
_74
"workers": 0,
_74
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_74
}
_74
]
_74
},
_74
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_74
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_74
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/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

_19
// Download the helper library from https://www.twilio.com/docs/node/install
_19
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19
_19
// Find your Account SID and Auth Token at twilio.com/console
_19
// and set the environment variables. See http://twil.io/secure
_19
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19
const authToken = process.env.TWILIO_AUTH_TOKEN;
_19
const client = twilio(accountSid, authToken);
_19
_19
async function fetchWorkersRealTimeStatistics() {
_19
const realTimeStatistic = await client.taskrouter.v1
_19
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.workers.realTimeStatistics()
_19
.fetch();
_19
_19
console.log(realTimeStatistic.accountSid);
_19
}
_19
_19
fetchWorkersRealTimeStatistics();

Output

_28
{
_28
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/RealTimeStatistics",
_28
"total_workers": 15,
_28
"activity_statistics": [
_28
{
_28
"friendly_name": "Idle",
_28
"workers": 0,
_28
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_28
},
_28
{
_28
"friendly_name": "Busy",
_28
"workers": 9,
_28
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_28
},
_28
{
_28
"friendly_name": "Offline",
_28
"workers": 6,
_28
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_28
},
_28
{
_28
"friendly_name": "Reserved",
_28
"workers": 0,
_28
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_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

_19
// Download the helper library from https://www.twilio.com/docs/node/install
_19
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19
_19
// Find your Account SID and Auth Token at twilio.com/console
_19
// and set the environment variables. See http://twil.io/secure
_19
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19
const authToken = process.env.TWILIO_AUTH_TOKEN;
_19
const client = twilio(accountSid, authToken);
_19
_19
async function fetchWorkersCumulativeStatistics() {
_19
const cumulativeStatistic = await client.taskrouter.v1
_19
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.workers.cumulativeStatistics()
_19
.fetch();
_19
_19
console.log(cumulativeStatistic.accountSid);
_19
}
_19
_19
fetchWorkersCumulativeStatistics();

Output

_47
{
_47
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/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": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"friendly_name": "Offline",
_47
"avg": 1080,
_47
"total": 5400
_47
},
_47
{
_47
"max": 0,
_47
"min": 900,
_47
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"friendly_name": "Busy",
_47
"avg": 1012,
_47
"total": 8100
_47
},
_47
{
_47
"max": 0,
_47
"min": 0,
_47
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_47
"friendly_name": "Idle",
_47
"avg": 0,
_47
"total": 0
_47
},
_47
{
_47
"max": 0,
_47
"min": 0,
_47
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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

_20
// Download the helper library from https://www.twilio.com/docs/node/install
_20
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20
_20
// Find your Account SID and Auth Token at twilio.com/console
_20
// and set the environment variables. See http://twil.io/secure
_20
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20
const authToken = process.env.TWILIO_AUTH_TOKEN;
_20
const client = twilio(accountSid, authToken);
_20
_20
async function fetchWorkerInstanceStatistics() {
_20
const statistic = await client.taskrouter.v1
_20
.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20
.workers("WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20
.statistics()
_20
.fetch();
_20
_20
console.log(statistic.accountSid);
_20
}
_20
_20
fetchWorkerInstanceStatistics();

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": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_50
"friendly_name": "Offline",
_50
"avg": 1080,
_50
"total": 5400
_50
},
_50
{
_50
"max": 0,
_50
"min": 900,
_50
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_50
"friendly_name": "Busy",
_50
"avg": 1012,
_50
"total": 8100
_50
},
_50
{
_50
"max": 0,
_50
"min": 0,
_50
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_50
"friendly_name": "Idle",
_50
"avg": 0,
_50
"total": 0
_50
},
_50
{
_50
"max": 0,
_50
"min": 0,
_50
"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_50
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_50
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_50
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics"
_50
}


Rate this page: