TaskRouter provides real time and historical statistics for Workflows. Historical statistics allow you to analyze Workflow data from the past 30 days.
These resources may not be accessible if your Workspace exceeds 100 workers. Please contact support for additional assistance.
1GET /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/Statistics2
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchWorkflowStatistics() {11const statistic = await client.taskrouter.v112.workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")13.workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")14.statistics()15.fetch();1617console.log(statistic.accountSid);18}1920fetchWorkflowStatistics();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics",4"cumulative": {5"avg_task_acceptance_time": 0,6"end_time": "2008-01-02T00:00:00Z",7"reservations_accepted": 0,8"reservations_rejected": 0,9"reservations_timed_out": 0,10"start_time": "2008-01-02T00:00:00Z",11"tasks_canceled": 0,12"tasks_entered": 0,13"tasks_moved": 0,14"tasks_timed_out_in_workflow": 015},16"realtime": {17"longest_task_waiting_age": 0,18"longest_task_waiting_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",19"tasks_by_status": {20"assigned": 1,21"pending": 0,22"reserved": 0,23"wrapping": 024},25"total_tasks": 126},27"workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",28"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"29}
Parameter | Description |
---|---|
Minutes | Filter 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. |
StartDate | Filter cumulative statistics by a start date. This is helpful for defining a range of statistics to capture. Input is a GMT ISO 8601 Timestamp |
EndDate | Filter cumulative statistics by an end date. This is helpful for defining a range of statistics to capture. Input is a GMT ISO 8601 Timestamp |
TaskChannel | Filter real-time and cumulative statistics by TaskChannel. Takes in a Unique Name ("voice", "sms", "default", etc.) or a TaskChannelSid. |
SplitByWaitTime | A 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:
Property | Description |
---|---|
LongestTaskWaitingSid | The ID of the longest waiting Task |
LongestTaskWaitingAge | The age of the longest waiting Task |
TotalTasks | The total number of Tasks |
TasksByStatus | The 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:
Property | Description |
---|---|
TasksEntered | The total number of Tasks that entered this Workflow |
TasksCanceled | The total number of Tasks that were canceled |
TasksCompleted | The total number of Tasks that were completed |
TasksDeleted | The total number of Tasks that were deleted |
TasksMoved | The total number of Tasks that were moved from one queue to another |
TasksTimedOutInWorkflow | The total number of Tasks that were timed out of their Workflows (and deleted) |
AvgTaskAcceptanceTime | The average time (in seconds) from Task creation to acceptance |
ReservationsCreated | The total number of Reservations that were created for Workers |
ReservationsAccepted | The total number of Reservations accepted by Workers |
ReservationsRejected | The total number of Reservations that were rejected |
ReservationsTimedOut | The total number of Reservations that were timed out |
ReservationsCanceled | The total number of Reservations that were canceled |
ReservationsRescinded | The total number of Reservations that were rescinded |
WaitDurationUntilCanceled | The wait duration stats (avg, min, max, total) for tasks that were canceled. |
WaitDurationUntilAccepted | The wait duration stats (avg, min, max, total) for tasks that were accepted. |
SplitByWaitTime | The splits of the tasks canceled and accepted based on the provided SplitByWaitTime parameter. |
If you are only concerned with the real time statistics of your workflow, you can utilize the below endpoint.
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.
1GET /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/RealTimeStatistics2
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchWorkflowRealTimeStatistics() {11const realTimeStatistic = await client.taskrouter.v112.workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")13.workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")14.realTimeStatistics()15.fetch();1617console.log(realTimeStatistic.accountSid);18}1920fetchWorkflowRealTimeStatistics();
1{2"longest_task_waiting_age": 100,3"longest_task_waiting_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics",5"tasks_by_priority": {},6"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",7"tasks_by_status": {8"reserved": 0,9"pending": 0,10"assigned": 0,11"wrapping": 012},13"workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",14"total_tasks": 100,15"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"16}
Parameter | Description |
---|---|
TaskChannel | Filter 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:
Property | Description |
---|---|
LongestTaskWaitingSid | The ID of the longest waiting Task |
LongestTaskWaitingAge | The age of the longest waiting Task |
TotalTasks | The total number of Tasks |
TasksByStatus | The Tasks broken down by status (for example: pending: 1, reserved = 3, assigned = 2, completed = 5) |
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.
1GET /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/CumulativeStatistics2
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchWorkflowCumulativeStatistics() {11const cumulativeStatistic = await client.taskrouter.v112.workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")13.workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")14.cumulativeStatistics()15.fetch();1617console.log(cumulativeStatistic.accountSid);18}1920fetchWorkflowCumulativeStatistics();
1{2"avg_task_acceptance_time": 100,3"tasks_canceled": 100,4"start_time": "2015-07-30T20:00:00Z",5"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"tasks_moved": 100,7"tasks_entered": 100,8"wait_duration_until_canceled": {9"avg": 0,10"min": 0,11"max": 0,12"total": 013},14"wait_duration_until_accepted": {15"avg": 0,16"min": 0,17"max": 0,18"total": 019},20"split_by_wait_time": {21"5": {22"above": {23"tasks_canceled": 0,24"reservations_accepted": 025},26"below": {27"tasks_canceled": 0,28"reservations_accepted": 029}30},31"10": {32"above": {33"tasks_canceled": 0,34"reservations_accepted": 035},36"below": {37"tasks_canceled": 0,38"reservations_accepted": 039}40}41},42"reservations_canceled": 100,43"end_time": "2015-07-30T20:00:00Z",44"workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",45"reservations_created": 100,46"reservations_accepted": 100,47"reservations_rescinded": 100,48"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",49"reservations_rejected": 100,50"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics",51"tasks_deleted": 100,52"tasks_timed_out_in_workflow": 100,53"tasks_completed": 100,54"reservations_timed_out": 10055}
Parameter | Description |
---|---|
Minutes | Filter 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. |
StartDate | Filter cumulative statistics by a start date. This is helpful for defining a range of statistics to capture. Input is a GMT ISO 8601 Timestamp |
EndDate | Filter cumulative statistics by an end date. This is helpful for defining a range of statistics to capture. Input is a GMT ISO 8601 Timestamp |
TaskChannel | Filter cumulative statistics by TaskChannel. Takes in a Unique Name ("voice", "sms", "default", etc.) or a TaskChannelSid. |
SplitByWaitTime | A 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:
Property | Description |
---|---|
TasksEntered | The total number of Tasks that entered this Workflow |
TasksCanceled | The total number of Tasks that were canceled |
TasksCompleted | The total number of Tasks that were completed |
TasksDeleted | The total number of Tasks that were deleted |
TasksMoved | The total number of Tasks that were moved from one queue to another |
TasksTimedOutInWorkflow | The total number of Tasks that were timed out of their Workflows (and deleted) |
AvgTaskAcceptanceTime | The average time (in seconds) from Task creation to acceptance |
ReservationsCreated | The total number of Reservations that were created for Workers |
ReservationsAccepted | The total number of Reservations accepted by Workers |
ReservationsRejected | The total number of Reservations that were rejected |
ReservationsTimedOut | The total number of Reservations that were timed out |
ReservationsCanceled | The total number of Reservations that were canceled |
ReservationsRescinded | The total number of Reservations that were rescinded |
WaitDurationUntilCanceled | The wait duration stats (avg, min, max, total) for tasks that were canceled. |
WaitDurationUntilAccepted | The wait duration stats (avg, min, max, total) for tasks that were accepted. |
SplitByWaitTime | The splits of the tasks canceled and accepted based on the provided SplitByWaitTime parameter. |