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

Workflow Statistics Resource


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

(warning)

Warning

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


Workflow Statistics

workflow-statistics page anchor

Resource URI

resource-uri page anchor

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

Retrieve Workflow Statistics

retrieve-workflow-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
.workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.statistics()
_12
.fetch()
_12
.then(workflow_statistics => console.log(workflow_statistics.cumulative));

Output

_29
{
_29
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
_29
"cumulative": {
_29
"avg_task_acceptance_time": 0.0,
_29
"end_time": "2008-01-02T00:00:00Z",
_29
"reservations_accepted": 0,
_29
"reservations_rejected": 0,
_29
"reservations_timed_out": 0,
_29
"start_time": "2008-01-02T00:00:00Z",
_29
"tasks_canceled": 0,
_29
"tasks_entered": 0,
_29
"tasks_moved": 0,
_29
"tasks_timed_out_in_workflow": 0
_29
},
_29
"realtime": {
_29
"longest_task_waiting_age": 0,
_29
"longest_task_waiting_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"tasks_by_status": {
_29
"assigned": 1,
_29
"pending": 0,
_29
"reserved": 0,
_29
"wrapping": 0
_29
},
_29
"total_tasks": 1
_29
},
_29
"workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_29
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_29
}

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 Workflow include the following:

PropertyDescription
LongestTaskWaitingSidThe ID of the longest waiting Task
LongestTaskWaitingAgeThe age of the longest waiting Task
TotalTasksThe total number of Tasks
TasksByStatusThe Tasks broken down by status (for example: pending: 1, reserved = 3, assigned = 2, completed = 5)

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

PropertyDescription
TasksEnteredThe total number of Tasks that entered this Workflow
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.

Workflow RealTime Statistics

workflow-realtime-statistics page anchor

If you are only concerned with the real time statistics of your workflow, 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}/Workflows/{WorkflowSid}/RealTimeStatistics

Retrieve Workflow RealTime Statistics

retrieve-workflow-realtime-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
.workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.realTimeStatistics()
_12
.fetch()
_12
.then(workflow_real_time_statistics => console.log(workflow_real_time_statistics.longestTaskWaitingAge));

Output

_16
{
_16
"longest_task_waiting_age": 100,
_16
"longest_task_waiting_sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
_16
"tasks_by_priority": {},
_16
"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"tasks_by_status": {
_16
"reserved": 0,
_16
"pending": 0,
_16
"assigned": 0,
_16
"wrapping": 0
_16
},
_16
"workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_16
"total_tasks": 100,
_16
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_16
}

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 Workflow include the following:

PropertyDescription
LongestTaskWaitingSidThe ID of the longest waiting Task
LongestTaskWaitingAgeThe age of the longest waiting Task
TotalTasksThe total number of Tasks
TasksByStatusThe Tasks broken down by status (for example: pending: 1, reserved = 3, assigned = 2, completed = 5)

Workflow Cumulative Statistics

workflow-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}/Workflows/{WorkflowSid}/CumulativeStatistics

Retrieve Workflow Cumulative Statistics

retrieve-workflow-cumulative-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
.workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12
.cumulativeStatistics()
_12
.fetch()
_12
.then(workflow_cumulative_statistics => console.log(workflow_cumulative_statistics.avgTaskAcceptanceTime));

Output

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

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 Workflow include the following over the interval:

PropertyDescription
TasksEnteredThe total number of Tasks that entered this Workflow
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: