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

REST API: Workspace Statistics


TaskRouter provides real time and historical statistics for Workspaces. Historical statistics allow you to analyze data from the past 30 days.


Workspace Statistics

workspace-statistics page anchor

Resource URI

resource-uri page anchor

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

Retrieve workspace statistics

retrieve-workspace-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
.statistics()
_11
.fetch()
_11
.then(workspace_statistics => console.log(workspace_statistics.realtime));

Output

_65
{
_65
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_65
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
_65
"cumulative": {
_65
"avg_task_acceptance_time": 0.0,
_65
"start_time": "2008-01-02T00:00:00Z",
_65
"reservations_accepted": 0,
_65
"reservations_canceled": 0,
_65
"reservations_created": 0,
_65
"reservations_rejected": 0,
_65
"reservations_rescinded": 0,
_65
"reservations_timed_out": 0,
_65
"end_time": "2008-01-02T00:00:00Z",
_65
"tasks_canceled": 0,
_65
"tasks_created": 0,
_65
"tasks_deleted": 0,
_65
"tasks_moved": 0,
_65
"tasks_timed_out_in_workflow": 0
_65
},
_65
"realtime": {
_65
"activity_statistics": [
_65
{
_65
"friendly_name": "Offline",
_65
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_65
"workers": 1
_65
},
_65
{
_65
"friendly_name": "Idle",
_65
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_65
"workers": 0
_65
},
_65
{
_65
"friendly_name": "80fa2beb-3a05-11e5-8fc8-98e0d9a1eb73",
_65
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_65
"workers": 0
_65
},
_65
{
_65
"friendly_name": "Reserved",
_65
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_65
"workers": 0
_65
},
_65
{
_65
"friendly_name": "Busy",
_65
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_65
"workers": 0
_65
},
_65
{
_65
"friendly_name": "817ca1c5-3a05-11e5-9292-98e0d9a1eb73",
_65
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_65
"workers": 0
_65
}
_65
],
_65
"longest_task_waiting_age": 0,
_65
"longest_task_waiting_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_65
"tasks_by_status": {
_65
"assigned": 0,
_65
"pending": 0,
_65
"reserved": 0,
_65
"wrapping": 0
_65
},
_65
"total_tasks": 0,
_65
"total_workers": 1
_65
},
_65
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_65
}

ParameterDescription
MinutesFilter cumulative statistics by up to 'x' minutes in the past. This is helpful for statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends. Defaults to 15 minutes.
StartDateFilter cumulative statistics by a start date. This is helpful for defining a range of statistics to capture. Input is a GMT ISO 8601 Timestamp
EndDateFilter cumulative statistics by an end date. This is helpful for defining a range of statistics to capture. Input is a GMT ISO 8601 Timestamp
TaskChannelFilter real-time and cumulative statistics by TaskChannel. Takes in a Unique Name ("voice", "sms", "default", etc.) or a TaskChannelSid.
SplitByWaitTimeA comma separated values for viewing splits of tasks canceled and accepted above the given threshold in seconds. Ex: "5,30" would show splits of tasks that were canceled or accepted before or after 5 seconds and respectively, 30 seconds. This is great for showing short abandoned tasks or tasks that failed to meet your SLA.

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

Real time statistics relating to a Workspace include the following:

PropertyDescription
LongestTaskWaitingSidThe ID of the longest waiting Task
LongestTaskWaitingAgeThe age of the longest waiting Task
TotalTasksThe total number of Tasks
TotalWorkersThe total number of Workers in the workspace
TasksByStatusThe Tasks broken down by status (for example: pending: 1, reserved = 3, assigned = 2, completed = 5)
ActivityStatisticsA breakdown of Workers by Activity (for example: Idle : 0, Busy: 5, Reserved = 0, Offline = 2)

Cumulative statistics relating to a Workspace include the following over the interval:

PropertyDescription
TasksCreatedThe total number of Tasks created
TasksCanceledThe total number of Tasks that were canceled
TasksCompletedThe total number of Tasks that were completed
TasksDeletedThe total number of Tasks that were deleted
TasksMovedThe total number of Tasks that were moved from one queue to another
TasksTimedOutInWorkflowThe total number of Tasks that were timed out of their Workflows (and deleted)
AvgTaskAcceptanceTimeThe average time (in seconds) from Task creation to acceptance
ReservationsCreatedThe total number of Reservations that were created for Workers
ReservationsAcceptedThe total number of Reservations accepted by Workers
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
WaitDurationUntilCanceledThe wait duration stats (avg, min, max, total) for tasks that were canceled.
WaitDurationUntilAcceptedThe wait duration stats (avg, min, max, total) for tasks that were accepted.
SplitByWaitTimeThe splits of the tasks canceled and accepted based on the provided SplitByWaitTime parameter.

Workspace RealTime Statistics

workspace-realtime-statistics page anchor

If you are only concerned with the real time statistics of your workspace, you can utilize the below endpoint.

(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}/RealTimeStatistics

Retrieve workspace real time statistics

retrieve-workspace-real-time-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(workspace_real_time_statistics => console.log(workspace_real_time_statistics.activityStatistics));

Output

_33
{
_33
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
_33
"tasks_by_priority": {},
_33
"activity_statistics": [
_33
{
_33
"friendly_name": "Idle",
_33
"workers": 0,
_33
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_33
},
_33
{
_33
"friendly_name": "Busy",
_33
"workers": 9,
_33
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_33
},
_33
{
_33
"friendly_name": "Offline",
_33
"workers": 6,
_33
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_33
},
_33
{
_33
"friendly_name": "Reserved",
_33
"workers": 0,
_33
"sid": "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_33
}
_33
],
_33
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_33
"longest_task_waiting_age": 100,
_33
"longest_task_waiting_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_33
"total_workers": 100,
_33
"total_tasks": 100,
_33
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_33
"tasks_by_status": {}
_33
}

ParameterDescription
TaskChannelFilter real-time statistics by TaskChannel. Takes in a Unique Name ("voice", "sms", "default", etc.) or a TaskChannelSid.

Real time statistics relating to a Workspace include the following:

PropertyDescription
LongestTaskWaitingSidThe ID of the longest waiting Task
LongestTaskWaitingAgeThe age of the longest waiting Task
TotalTasksThe total number of Tasks
TotalWorkersThe total number of Workers in the workspace
TasksByStatusThe Tasks broken down by status (for example: pending: 1, reserved = 3, assigned = 2, completed = 5)
ActivityStatisticsA breakdown of Workers by Activity (for example: Idle : 0, Busy: 5, Reserved = 0, Offline = 2)

Workspace Cumulative Statistics

workspace-cumulative-statistics page anchor

If you are only concerned with the cumulative statistics over a certain time period, you can utilize the below endpoint. Cumulative statistics allow you to analyze data from the past 30 days.


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

Retrieve workspace cumulative statistics

retrieve-workspace-cumulative-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(workspace_cumulative_statistics => console.log(workspace_cumulative_statistics.avgTaskAcceptanceTime));

Output

_54
{
_54
"reservations_accepted": 100,
_54
"tasks_completed": 100,
_54
"start_time": "2015-07-30T20:00:00Z",
_54
"reservations_rescinded": 100,
_54
"tasks_timed_out_in_workflow": 100,
_54
"end_time": "2015-07-30T20:00:00Z",
_54
"avg_task_acceptance_time": 100,
_54
"tasks_canceled": 100,
_54
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics",
_54
"tasks_moved": 100,
_54
"tasks_deleted": 100,
_54
"tasks_created": 100,
_54
"reservations_canceled": 100,
_54
"reservations_timed_out": 100,
_54
"wait_duration_until_canceled": {
_54
"avg": 0,
_54
"min": 0,
_54
"max": 0,
_54
"total": 0
_54
},
_54
"wait_duration_until_accepted": {
_54
"avg": 0,
_54
"min": 0,
_54
"max": 0,
_54
"total": 0
_54
},
_54
"split_by_wait_time": {
_54
"5": {
_54
"above": {
_54
"tasks_canceled": 0,
_54
"reservations_accepted": 0
_54
},
_54
"below": {
_54
"tasks_canceled": 0,
_54
"reservations_accepted": 0
_54
}
_54
},
_54
"10": {
_54
"above": {
_54
"tasks_canceled": 0,
_54
"reservations_accepted": 0
_54
},
_54
"below": {
_54
"tasks_canceled": 0,
_54
"reservations_accepted": 0
_54
}
_54
}
_54
},
_54
"reservations_created": 100,
_54
"reservations_rejected": 100,
_54
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_54
}

ParameterDescription
MinutesFilter cumulative statistics by up to 'x' minutes in the past. This is helpful for statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends. Defaults to 15 minutes.
StartDateFilter cumulative statistics by a start date. This is helpful for defining a range of statistics to capture. Input is a GMT ISO 8601 Timestamp
EndDateFilter cumulative statistics by an end date. This is helpful for defining a range of statistics to capture. Input is a GMT ISO 8601 Timestamp
TaskChannelFilter cumulative statistics by TaskChannel. Takes in a Unique Name ("voice", "sms", "default", etc.) or a TaskChannelSid.
SplitByWaitTimeA comma separated values for viewing splits of tasks canceled and accepted above the given threshold in seconds. Ex: "5,30" would show splits of tasks that were canceled or accepted before or after 5 seconds and respectively, 30 seconds. This is great for showing short abandoned tasks or tasks that failed to meet your SLA.

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

Cumulative statistics relating to a Workspace include the following over the interval:

PropertyDescription
TasksCreatedThe total number of Tasks created
TasksCanceledThe total number of Tasks that were canceled
TasksCompletedThe total number of Tasks that were completed
TasksDeletedThe total number of Tasks that were deleted
TasksMovedThe total number of Tasks that were moved from one queue to another
TasksTimedOutInWorkflowThe total number of Tasks that were timed out of their Workflows (and deleted)
AvgTaskAcceptanceTimeThe average time (in seconds) from Task creation to acceptance
ReservationsCreatedThe total number of Reservations that were created for Workers
ReservationsAcceptedThe total number of Reservations accepted by Workers
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
WaitDurationUntilCanceledThe wait duration stats (avg, min, max, total) for tasks that were canceled.
WaitDurationUntilAcceptedThe wait duration stats (avg, min, max, total) for tasks that were accepted.
SplitByWaitTimeThe splits of the tasks canceled and accepted based on the provided SplitByWaitTime parameter.

Rate this page: