Menu

Expand
Rate this page:

REST API: TaskQueue Statistics

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

TaskQueue RealTime Statistics

If you are only concerned with the real time statistics of your TaskQueue, 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.

Resource URI

GET /v1/Workspaces/{WorkspaceSid}/TaskQueues/{TaskQueueSid}/RealTimeStatistics
Parameters in REST API format
workspace_sid
Path
get sid<WS> Not PII

The SID of the Workspace with the TaskQueue to fetch.

task_queue_sid
Path
get sid<WQ> Not PII

The SID of the TaskQueue for which to fetch statistics.

task_channel
Optional
get string Not PII

The TaskChannel for which to fetch statistics. Can be the TaskChannel's SID or its unique_name, such as voice, sms, or default.

Real time statistics relating to a TaskQueue include the following:

Resource Properties in REST API format
account_sid
sid<AC> Not PII

The SID of the Account that created the TaskQueue resource.

activity_statistics
object[] Not PII

The number of current Workers by Activity.

longest_task_waiting_age
integer Not PII

The age of the longest waiting Task.

longest_task_waiting_sid
sid<WT> Not PII

The SID of the longest waiting Task.

longest_relative_task_age_in_queue
integer Not PII

The relative age in the TaskQueue for the longest waiting Task. Calculation is based on the time when the Task entered the TaskQueue.

longest_relative_task_sid_in_queue
sid<WT> Not PII

The Task SID of the Task waiting in the TaskQueue the longest. Calculation is based on the time when the Task entered the TaskQueue.

task_queue_sid
sid<WQ> Not PII

The SID of the TaskQueue from which these statistics were calculated.

tasks_by_priority
object Not PII

The number of Tasks by priority. For example: {"0": "10", "99": "5"} shows 10 Tasks at priority 0 and 5 at priority 99.

tasks_by_status
object Not PII

The number of Tasks by their current status. For example: {"pending": "1", "reserved": "3", "assigned": "2", "completed": "5"}.

total_available_workers
integer Not PII

The total number of Workers available for Tasks in the TaskQueue.

total_eligible_workers
integer Not PII

The total number of Workers eligible for Tasks in the TaskQueue, independent of their Activity state.

total_tasks
integer Not PII

The total number of Tasks.

workspace_sid
sid<WS> Not PII

The SID of the Workspace that contains the TaskQueue.

url
url Not PII

The absolute URL of the TaskQueue statistics resource.

Loading Code Sample...
        
        

        Retrieving TaskQueue RealTime Statistics

        TaskQueue Cumulative Statistics

        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.

        Resource URI

        GET /v1/Workspaces/{WorkspaceSid}/TaskQueues/{TaskQueueSid}/CumulativeStatistics
        
        Parameters in REST API format
        workspace_sid
        Path
        get sid<WS> Not PII

        The SID of the Workspace with the TaskQueue to fetch.

        task_queue_sid
        Path
        get sid<WQ> Not PII

        The SID of the TaskQueue for which to fetch statistics.

        end_date
        Optional
        get date_time<iso8601> Not PII

        Only calculate statistics from this date and time and earlier, specified in GMT as an ISO 8601 date-time.

        minutes
        Optional
        get integer Not PII

        Only calculate statistics since this many minutes in the past. The default is 15 minutes.

        start_date
        Optional
        get date_time<iso8601> Not PII

        Only calculate statistics from this date and time and later, specified in ISO 8601 format.

        task_channel
        Optional
        get string Not PII

        Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its unique_name, such as voice, sms, or default.

        split_by_wait_time
        Optional
        get string Not PII

        A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. TaskRouter will calculate statistics on up to 10,000 Tasks/Reservations for any given threshold.

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

        Resource Properties in REST API format
        account_sid
        sid<AC> Not PII

        The SID of the Account that created the TaskQueue resource.

        avg_task_acceptance_time
        integer Not PII

        The average time in seconds between Task creation and acceptance.

        start_time
        date_time<iso8601> Not PII

        The beginning of the interval during which these statistics were calculated, in ISO 8601 format.

        end_time
        date_time<iso8601> Not PII

        The end of the interval during which these statistics were calculated, in ISO 8601 format.

        reservations_created
        integer Not PII

        The total number of Reservations created for Tasks in the TaskQueue.

        reservations_accepted
        integer Not PII

        The total number of Reservations accepted for Tasks in the TaskQueue.

        reservations_rejected
        integer Not PII

        The total number of Reservations rejected for Tasks in the TaskQueue.

        reservations_timed_out
        integer Not PII

        The total number of Reservations that timed out for Tasks in the TaskQueue.

        reservations_canceled
        integer Not PII

        The total number of Reservations canceled for Tasks in the TaskQueue.

        reservations_rescinded
        integer Not PII

        The total number of Reservations rescinded.

        split_by_wait_time
        object Not PII

        A list of objects that describe the number of Tasks canceled and reservations accepted above and below the thresholds specified in seconds.

        task_queue_sid
        sid<WQ> Not PII

        The SID of the TaskQueue from which these statistics were calculated.

        wait_duration_until_accepted
        object Not PII

        The wait duration statistics (avg, min, max, total) for Tasks accepted while in the TaskQueue. Calculation is based on the time when the Tasks were created. For transfers, the wait duration is counted from the moment the Task was created, and not from when the transfer was initiated.

        wait_duration_until_canceled
        object Not PII

        The wait duration statistics (avg, min, max, total) for Tasks canceled while in the TaskQueue.

        wait_duration_in_queue_until_accepted
        object Not PII

        The relative wait duration statistics (avg, min, max, total) for Tasks accepted while in the TaskQueue. Calculation is based on the time when the Tasks entered the TaskQueue.

        tasks_canceled
        integer Not PII

        The total number of Tasks canceled in the TaskQueue.

        tasks_completed
        integer Not PII

        The total number of Tasks completed in the TaskQueue.

        tasks_deleted
        integer Not PII

        The total number of Tasks deleted in the TaskQueue.

        tasks_entered
        integer Not PII

        The total number of Tasks entered into the TaskQueue.

        tasks_moved
        integer Not PII

        The total number of Tasks that were moved from one queue to another.

        workspace_sid
        sid<WS> Not PII

        The SID of the Workspace that contains the TaskQueue.

        url
        url Not PII

        The absolute URL of the TaskQueue statistics resource.

        Loading Code Sample...
              
              

              Retrieving TaskQueue Cumulative Statistics

              TaskQueue Instance Statistics

              Resource URI

              GET /v1/Workspaces/{WorkspaceSid}/TaskQueues/{TaskQueueSid}/Statistics
              
              Parameters in REST API format
              workspace_sid
              Path
              get sid<WS> Not PII

              The SID of the Workspace with the TaskQueue to fetch.

              task_queue_sid
              Path
              get sid<WQ> Not PII

              The SID of the TaskQueue for which to fetch statistics.

              end_date
              Optional
              get date_time<iso8601> Not PII

              Only calculate statistics from this date and time and earlier, specified in GMT as an ISO 8601 date-time.

              minutes
              Optional
              get integer Not PII

              Only calculate statistics since this many minutes in the past. The default is 15 minutes.

              start_date
              Optional
              get date_time<iso8601> Not PII

              Only calculate statistics from this date and time and later, specified in ISO 8601 format.

              task_channel
              Optional
              get string Not PII

              Only calculate real-time and cumulative statistics for the specified TaskChannel. Can be the TaskChannel's SID or its unique_name, such as voice, sms, or default.

              split_by_wait_time
              Optional
              get string Not PII

              A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed.

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

              Resource Properties in REST API format
              account_sid
              sid<AC> Not PII

              The SID of the Account that created the TaskQueue resource.

              cumulative
              object Not PII

              An object that contains the cumulative statistics for the TaskQueue.

              realtime
              object Not PII

              An object that contains the real-time statistics for the TaskQueue.

              task_queue_sid
              sid<WQ> Not PII

              The SID of the TaskQueue from which these statistics were calculated.

              workspace_sid
              sid<WS> Not PII

              The SID of the Workspace that contains the TaskQueue.

              url
              url Not PII

              The absolute URL of the TaskQueue statistics resource.

              Loading Code Sample...
                    
                    

                    Retrieving TaskQueue Instance Statistics

                    Rate this page:

                    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 by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

                    Loading Code Sample...
                          
                          
                          

                          Thank you for your feedback!

                          Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

                          Sending your feedback...
                          🎉 Thank you for your feedback!
                          Something went wrong. Please try again.

                          Thanks for your feedback!

                          thanks-feedback-gif