Skip to contentSkip to navigationSkip to topbar
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
1
GET /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/Statistics
2
Retrieve Workflow StatisticsLink to code sample: Retrieve Workflow Statistics
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchWorkflowStatistics() {
11
const statistic = await client.taskrouter.v1
12
.workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
14
.statistics()
15
.fetch();
16
17
console.log(statistic.accountSid);
18
}
19
20
fetchWorkflowStatistics();

Output

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": 0
15
},
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": 0
24
},
25
"total_tasks": 1
26
},
27
"workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
28
"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.

1
GET /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/RealTimeStatistics
2
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchWorkflowRealTimeStatistics() {
11
const realTimeStatistic = await client.taskrouter.v1
12
.workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
14
.realTimeStatistics()
15
.fetch();
16
17
console.log(realTimeStatistic.accountSid);
18
}
19
20
fetchWorkflowRealTimeStatistics();

Output

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": 0
12
},
13
"workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
14
"total_tasks": 100,
15
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
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.

1
GET /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/CumulativeStatistics
2
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchWorkflowCumulativeStatistics() {
11
const cumulativeStatistic = await client.taskrouter.v1
12
.workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
14
.cumulativeStatistics()
15
.fetch();
16
17
console.log(cumulativeStatistic.accountSid);
18
}
19
20
fetchWorkflowCumulativeStatistics();

Output

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": 0
13
},
14
"wait_duration_until_accepted": {
15
"avg": 0,
16
"min": 0,
17
"max": 0,
18
"total": 0
19
},
20
"split_by_wait_time": {
21
"5": {
22
"above": {
23
"tasks_canceled": 0,
24
"reservations_accepted": 0
25
},
26
"below": {
27
"tasks_canceled": 0,
28
"reservations_accepted": 0
29
}
30
},
31
"10": {
32
"above": {
33
"tasks_canceled": 0,
34
"reservations_accepted": 0
35
},
36
"below": {
37
"tasks_canceled": 0,
38
"reservations_accepted": 0
39
}
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": 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.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.