REST API: Workflow Statistics

TaskRouter provides real time and historical statistics for Workflows.

Workflow Statistics

Resource URI

GET /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/Statistics
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const workflowSid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace
  .workflows(workflowSid)
  .statistics.get({}, (err, responseData) => {
    if (!err) {
      console.log(responseData.cumulative.avg_task_acceptance_time);
      console.log(responseData.cumulative.tasks_created);
      console.log(responseData.realtime.tasks_by_status.pending);
      console.log(responseData.realtime.tasks_by_status.assigned);
    }
  });
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
      .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
      .statistics()
      .fetch()
      .then(workflow_statistics => console.log(workflow_statistics.cumulative))
      .done();
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.TaskRouter;

class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string WorkflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var client = new TaskRouterClient(AccountSid, AuthToken);

    WorkflowStatistics stats = client.GetWorkflowStatistics(WorkspaceSid, WorkflowSid);
    Console.WriteLine(stats.Cumulative.AvgTaskAcceptanceTime);
    Console.WriteLine(stats.Cumulative.TasksEntered);
    Console.WriteLine(stats.Realtime.TasksByStatus.Pending);
    Console.WriteLine(stats.Realtime.TasksByStatus.Assigned);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$authToken = "your_auth_token";
$workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid);

$statistics = $client->getWorkflowStatistics(
    $workflowSid,
    array(
        'Minutes' => 60
    )
);
echo $statistics->cumulative->avg_task_acceptance_time;
echo $statistics->realtime->tasks_by_status->pending;
echo $statistics->realtime->tasks_by_status->assigned;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
workflow_sid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

client = Twilio::REST::TaskRouterClient.new account_sid,
                                            auth_token,
                                            workspace_sid

statistics = client.workspace.workflows.get(workflow_sid).statistics
puts statistics.cumulative['avg_task_acceptance_time']
puts statistics.cumulative['tasks_created']
puts statistics.realtime['tasks_by_status']['pending']
puts statistics.realtime['tasks_by_status']['assigned']
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace.Workflow;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflowStatistics = WorkflowStatisticsResource.Fetch(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathWorkflowSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflowStatistics.Cumulative);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow_statistics = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                              ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                              ->statistics()
                                              ->fetch();

print($workflow_statistics->cumulative);
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
workflow_sid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

statistics = client.workflows(workspace_sid).get(workflow_sid).statistics.get()
print(statistics.cumulative["avg_task_acceptance_time"])
print(statistics.cumulative["tasks_entered"])
print(statistics.realtime["tasks_by_status"]["pending"])
print(statistics.realtime["tasks_by_status"]["assigned"])
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow_statistics = @client.taskrouter
                             .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                             .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                             .statistics
                             .fetch

puts workflow_statistics.cumulative
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.WorkflowStatistics;
import com.twilio.sdk.resource.instance.taskrouter.Workflow;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String WORKFLOW_SID = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws TwilioRestException {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    WorkflowStatistics statistics = client.getWorkflowStatistics(WORKSPACE_SID, WORKFLOW_SID);
    System.out.println("Avg Task Acceptance Time: "+statistics.getAverageTaskAcceptanceTime());
    System.out.println("Tasks Entered: "+statistics.getTasksEntered());
    System.out.println("Pending Tasks: "+statistics.getPendingTasks());
    System.out.println("Assigned Tasks: "+statistics.getAssignedTasks());

    //alternatively
    Workflow workflow = client.getWorkflow(WORKSPACE_SID, WORKFLOW_SID);
    statistics = workflow.getStatistics();
    System.out.println("Avg Task Acceptance Time: "+statistics.getAverageTaskAcceptanceTime());
    System.out.println("Tasks Entered: "+statistics.getTasksEntered());
    System.out.println("Pending Tasks: "+statistics.getPendingTasks());
    System.out.println("Assigned Tasks: "+statistics.getAssignedTasks());
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow_statistics = client.taskrouter \
                            .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                            .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                            .statistics() \
                            .fetch()

print(workflow_statistics.cumulative)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.workflow.WorkflowStatistics;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        WorkflowStatistics workflowStatistics = WorkflowStatistics.fetcher(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .fetch();

        System.out.println(workflowStatistics.getCumulative());
    }
}
curl -X GET 'https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
  "cumulative": {
    "avg_task_acceptance_time": 0.0,
    "end_time": "2008-01-02T00:00:00Z",
    "reservations_accepted": 0,
    "reservations_rejected": 0,
    "reservations_timed_out": 0,
    "start_time": "2008-01-02T00:00:00Z",
    "tasks_canceled": 0,
    "tasks_entered": 0,
    "tasks_moved": 0,
    "tasks_timed_out_in_workflow": 0
  },
  "realtime": {
    "longest_task_waiting_age": 0,
    "longest_task_waiting_sid": null,
    "tasks_by_status": {
      "assigned": 1,
      "pending": 0,
      "reserved": 0,
      "wrapping": 0
    },
    "total_tasks": 1
  },
  "workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
Retrieve Workflow Statistics
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

Real time statistics relating to a Workflow include the following:

Field 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

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

Field 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.

Workflow RealTime Statistics

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

Resource URI

GET /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/RealTimeStatistics
Loading Code Samples...
Language
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .realTimeStatistics()
  .fetch()
  .then(workflow_real_time_statistics => console.log(workflow_real_time_statistics.longestTaskWaitingAge))
  .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace.Workflow;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflowRealTimeStatistics = WorkflowRealTimeStatisticsResource.Fetch(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathWorkflowSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflowRealTimeStatistics.LongestTaskWaitingAge);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow_real_time_statistics = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                                        ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                                        ->realTimeStatistics()
                                                        ->fetch();

print($workflow_real_time_statistics->longestTaskWaitingAge);
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow_real_time_statistics = @client.taskrouter
  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .real_time_statistics
  .fetch

puts workflow_real_time_statistics.longest_task_waiting_age
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow_real_time_statistics = client.taskrouter \
    .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
    .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
    .real_time_statistics() \
    .fetch()

print(workflow_real_time_statistics.longest_task_waiting_age)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.workflow.WorkflowRealTimeStatistics;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        WorkflowRealTimeStatistics workflowRealTimeStatistics = 
            WorkflowRealTimeStatistics.fetcher(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .fetch();

        System.out.println(workflowRealTimeStatistics.getLongestTaskWaitingAge());
    }
}
curl -X GET 'https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "longest_task_waiting_age": 100,
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
  "tasks_by_priority": {},
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "tasks_by_status": {
    "reserved": 0,
    "pending": 0,
    "assigned": 0,
    "wrapping": 0
  },
  "workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "total_tasks": 100,
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
Retrieve Workflow RealTime Statistics
Parameter Description
TaskChannel Filter real-time statistics by TaskChannel. Takes in a Unique Name ("voice", "sms", "default", etc.) or a TaskChannelSid.

Real Time

Real time statistics relating to a Workflow include the following:

Field 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)

Workflow Cumulative Statistics

If you are only concerned with the cumulative statistics over a certain time period, you can utilize the below endpoint.

Resource URI

GET /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/CumulativeStatistics
Loading Code Samples...
Language
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .cumulativeStatistics()
  .fetch()
  .then(workflow_cumulative_statistics => console.log(workflow_cumulative_statistics.avgTaskAcceptanceTime))
  .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace.Workflow;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflowCumulativeStatistics = WorkflowCumulativeStatisticsResource.Fetch(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathWorkflowSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflowCumulativeStatistics.AvgTaskAcceptanceTime);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow_cumulative_statistics = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                                         ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                                         ->cumulativeStatistics()
                                                         ->fetch();

print($workflow_cumulative_statistics->avgTaskAcceptanceTime);
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow_cumulative_statistics = @client.taskrouter
  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .cumulative_statistics
  .fetch

puts workflow_cumulative_statistics.avg_task_acceptance_time
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow_cumulative_statistics = client.taskrouter \
    .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
    .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
    .cumulative_statistics() \
    .fetch()

print(workflow_cumulative_statistics.avg_task_acceptance_time)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.workflow.WorkflowCumulativeStatistics;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        WorkflowCumulativeStatistics workflowCumulativeStatistics = 
            WorkflowCumulativeStatistics.fetcher(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .fetch();

        System.out.println(workflowCumulativeStatistics.getAvgTaskAcceptanceTime());
    }
}
curl -X GET 'https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "avg_task_acceptance_time": 100,
  "tasks_canceled": 100,
  "start_time": "2015-07-30T20:00:00Z",
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "tasks_moved": 100,
  "tasks_entered": 100,
  "wait_duration_until_canceled": {
    "avg": 0,
    "min": 0,
    "max": 0,
    "total": 0
  },
  "wait_duration_until_accepted": {
    "avg": 0,
    "min": 0,
    "max": 0,
    "total": 0
  },
  "split_by_wait_time": {
    "5": {
      "above": {
        "tasks_canceled": 0,
        "reservations_accepted": 0
      },
      "below": {
        "tasks_canceled": 0,
        "reservations_accepted": 0
      }
    },
    "10": {
      "above": {
        "tasks_canceled": 0,
        "reservations_accepted": 0
      },
      "below": {
        "tasks_canceled": 0,
        "reservations_accepted": 0
      }
    }
  },
  "reservations_canceled": 100,
  "end_time": "2015-07-30T20:00:00Z",
  "workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "reservations_created": 100,
  "reservations_accepted": 100,
  "reservations_rescinded": 100,
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "reservations_rejected": 100,
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics",
  "tasks_deleted": 100,
  "tasks_timed_out_in_workflow": 100,
  "tasks_completed": 100,
  "reservations_timed_out": 100
}
Retrieve Workflow Cumulative Statistics
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

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

Field 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.

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

Loading Code Samples...
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const workflowSid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace
  .workflows(workflowSid)
  .statistics.get({}, (err, responseData) => {
    if (!err) {
      console.log(responseData.cumulative.avg_task_acceptance_time);
      console.log(responseData.cumulative.tasks_created);
      console.log(responseData.realtime.tasks_by_status.pending);
      console.log(responseData.realtime.tasks_by_status.assigned);
    }
  });
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
      .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
      .statistics()
      .fetch()
      .then(workflow_statistics => console.log(workflow_statistics.cumulative))
      .done();
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.TaskRouter;

class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string WorkflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var client = new TaskRouterClient(AccountSid, AuthToken);

    WorkflowStatistics stats = client.GetWorkflowStatistics(WorkspaceSid, WorkflowSid);
    Console.WriteLine(stats.Cumulative.AvgTaskAcceptanceTime);
    Console.WriteLine(stats.Cumulative.TasksEntered);
    Console.WriteLine(stats.Realtime.TasksByStatus.Pending);
    Console.WriteLine(stats.Realtime.TasksByStatus.Assigned);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$authToken = "your_auth_token";
$workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid);

$statistics = $client->getWorkflowStatistics(
    $workflowSid,
    array(
        'Minutes' => 60
    )
);
echo $statistics->cumulative->avg_task_acceptance_time;
echo $statistics->realtime->tasks_by_status->pending;
echo $statistics->realtime->tasks_by_status->assigned;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
workflow_sid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

client = Twilio::REST::TaskRouterClient.new account_sid,
                                            auth_token,
                                            workspace_sid

statistics = client.workspace.workflows.get(workflow_sid).statistics
puts statistics.cumulative['avg_task_acceptance_time']
puts statistics.cumulative['tasks_created']
puts statistics.realtime['tasks_by_status']['pending']
puts statistics.realtime['tasks_by_status']['assigned']
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace.Workflow;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflowStatistics = WorkflowStatisticsResource.Fetch(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathWorkflowSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflowStatistics.Cumulative);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow_statistics = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                              ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                              ->statistics()
                                              ->fetch();

print($workflow_statistics->cumulative);
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
workflow_sid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

statistics = client.workflows(workspace_sid).get(workflow_sid).statistics.get()
print(statistics.cumulative["avg_task_acceptance_time"])
print(statistics.cumulative["tasks_entered"])
print(statistics.realtime["tasks_by_status"]["pending"])
print(statistics.realtime["tasks_by_status"]["assigned"])
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow_statistics = @client.taskrouter
                             .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                             .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                             .statistics
                             .fetch

puts workflow_statistics.cumulative
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.WorkflowStatistics;
import com.twilio.sdk.resource.instance.taskrouter.Workflow;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String WORKFLOW_SID = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws TwilioRestException {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    WorkflowStatistics statistics = client.getWorkflowStatistics(WORKSPACE_SID, WORKFLOW_SID);
    System.out.println("Avg Task Acceptance Time: "+statistics.getAverageTaskAcceptanceTime());
    System.out.println("Tasks Entered: "+statistics.getTasksEntered());
    System.out.println("Pending Tasks: "+statistics.getPendingTasks());
    System.out.println("Assigned Tasks: "+statistics.getAssignedTasks());

    //alternatively
    Workflow workflow = client.getWorkflow(WORKSPACE_SID, WORKFLOW_SID);
    statistics = workflow.getStatistics();
    System.out.println("Avg Task Acceptance Time: "+statistics.getAverageTaskAcceptanceTime());
    System.out.println("Tasks Entered: "+statistics.getTasksEntered());
    System.out.println("Pending Tasks: "+statistics.getPendingTasks());
    System.out.println("Assigned Tasks: "+statistics.getAssignedTasks());
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow_statistics = client.taskrouter \
                            .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                            .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                            .statistics() \
                            .fetch()

print(workflow_statistics.cumulative)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.workflow.WorkflowStatistics;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        WorkflowStatistics workflowStatistics = WorkflowStatistics.fetcher(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .fetch();

        System.out.println(workflowStatistics.getCumulative());
    }
}
curl -X GET 'https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
  "cumulative": {
    "avg_task_acceptance_time": 0.0,
    "end_time": "2008-01-02T00:00:00Z",
    "reservations_accepted": 0,
    "reservations_rejected": 0,
    "reservations_timed_out": 0,
    "start_time": "2008-01-02T00:00:00Z",
    "tasks_canceled": 0,
    "tasks_entered": 0,
    "tasks_moved": 0,
    "tasks_timed_out_in_workflow": 0
  },
  "realtime": {
    "longest_task_waiting_age": 0,
    "longest_task_waiting_sid": null,
    "tasks_by_status": {
      "assigned": 1,
      "pending": 0,
      "reserved": 0,
      "wrapping": 0
    },
    "total_tasks": 1
  },
  "workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .realTimeStatistics()
  .fetch()
  .then(workflow_real_time_statistics => console.log(workflow_real_time_statistics.longestTaskWaitingAge))
  .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace.Workflow;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflowRealTimeStatistics = WorkflowRealTimeStatisticsResource.Fetch(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathWorkflowSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflowRealTimeStatistics.LongestTaskWaitingAge);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow_real_time_statistics = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                                        ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                                        ->realTimeStatistics()
                                                        ->fetch();

print($workflow_real_time_statistics->longestTaskWaitingAge);
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow_real_time_statistics = @client.taskrouter
  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .real_time_statistics
  .fetch

puts workflow_real_time_statistics.longest_task_waiting_age
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow_real_time_statistics = client.taskrouter \
    .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
    .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
    .real_time_statistics() \
    .fetch()

print(workflow_real_time_statistics.longest_task_waiting_age)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.workflow.WorkflowRealTimeStatistics;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        WorkflowRealTimeStatistics workflowRealTimeStatistics = 
            WorkflowRealTimeStatistics.fetcher(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .fetch();

        System.out.println(workflowRealTimeStatistics.getLongestTaskWaitingAge());
    }
}
curl -X GET 'https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "longest_task_waiting_age": 100,
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
  "tasks_by_priority": {},
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "tasks_by_status": {
    "reserved": 0,
    "pending": 0,
    "assigned": 0,
    "wrapping": 0
  },
  "workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "total_tasks": 100,
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .cumulativeStatistics()
  .fetch()
  .then(workflow_cumulative_statistics => console.log(workflow_cumulative_statistics.avgTaskAcceptanceTime))
  .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace.Workflow;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflowCumulativeStatistics = WorkflowCumulativeStatisticsResource.Fetch(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathWorkflowSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflowCumulativeStatistics.AvgTaskAcceptanceTime);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow_cumulative_statistics = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                                         ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                                         ->cumulativeStatistics()
                                                         ->fetch();

print($workflow_cumulative_statistics->avgTaskAcceptanceTime);
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow_cumulative_statistics = @client.taskrouter
  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .cumulative_statistics
  .fetch

puts workflow_cumulative_statistics.avg_task_acceptance_time
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow_cumulative_statistics = client.taskrouter \
    .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
    .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
    .cumulative_statistics() \
    .fetch()

print(workflow_cumulative_statistics.avg_task_acceptance_time)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.workflow.WorkflowCumulativeStatistics;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        WorkflowCumulativeStatistics workflowCumulativeStatistics = 
            WorkflowCumulativeStatistics.fetcher(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .fetch();

        System.out.println(workflowCumulativeStatistics.getAvgTaskAcceptanceTime());
    }
}
curl -X GET 'https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "avg_task_acceptance_time": 100,
  "tasks_canceled": 100,
  "start_time": "2015-07-30T20:00:00Z",
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "tasks_moved": 100,
  "tasks_entered": 100,
  "wait_duration_until_canceled": {
    "avg": 0,
    "min": 0,
    "max": 0,
    "total": 0
  },
  "wait_duration_until_accepted": {
    "avg": 0,
    "min": 0,
    "max": 0,
    "total": 0
  },
  "split_by_wait_time": {
    "5": {
      "above": {
        "tasks_canceled": 0,
        "reservations_accepted": 0
      },
      "below": {
        "tasks_canceled": 0,
        "reservations_accepted": 0
      }
    },
    "10": {
      "above": {
        "tasks_canceled": 0,
        "reservations_accepted": 0
      },
      "below": {
        "tasks_canceled": 0,
        "reservations_accepted": 0
      }
    }
  },
  "reservations_canceled": 100,
  "end_time": "2015-07-30T20:00:00Z",
  "workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "reservations_created": 100,
  "reservations_accepted": 100,
  "reservations_rescinded": 100,
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "reservations_rejected": 100,
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics",
  "tasks_deleted": 100,
  "tasks_timed_out_in_workflow": 100,
  "tasks_completed": 100,
  "reservations_timed_out": 100
}