On this page

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

Twilio offers the following APIs for TaskQueue statistics:

- Retrieving real-time statistics for a single queue
- Retrieving real-time statistics for up to 50 queues
- Retrieving cumulative statistics over a specific interval for a single queue
- Retrieving both real-time and cumulative statistics for a single queue

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

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

_10GET /v1/Workspaces/{WorkspaceSid}/TaskQueues/{TaskQueueSid}/RealTimeStatistics

Path Parameter

The SID of the TaskQueue for which to fetch statistics.

Query Parameter

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:

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

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

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

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

shows 10 Tasks at priority 0 and 5 at priority 99.

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

.

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

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

The absolute URL of the TaskQueue statistics resource.

To retrieve real-time statistics for multiple queues, you can utilize the below endpoint.

_10POST /v1/Workspaces/{WorkspaceSid}/TaskQueues/RealTimeStatistics

Uri Parameters |
---|

WorkspaceSid`POST` `SID<WS>` `NOT PII` The unique SID identifier of the Workspace. |

Field | Required? | Description |
---|---|---|

QueueSids | Yes | String array where each string represents one TaskQueueSID. (🏢 Not PII ) |

Real time statistics for TaskQueueSIDs provided as `POST`

parameter include the following:

The real-time statistics for each requested TaskQueue SID. `task_queue_data`

returns the following attributes:

`task_queue_sid`

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

`total_available_workers`

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

`total_eligible_workers`

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

`total_tasks`

: The total number of Tasks.

`longest_task_waiting_age`

: The age of the longest waiting Task.

`longest_task_waiting_sid`

: The SID of the longest waiting Task.

`tasks_by_status`

: The number of Tasks grouped by their current status.

`tasks_by_priority`

: The number of Tasks grouped by priority.

`activity_statistics`

: The number of current Workers grouped by Activity.

The number of TaskQueue statistics received in task_queue_data.

The absolute URL of the TaskQueue statistics resource.

The request body is validated for the following conditions:

- If the number of TaskQueueSIDs in the request body is less than 1 or exceeds 50, an HTTP 400 error is returned.
- If the request body contains invalid TaskQueueSIDs, an HTTP 400 error is returned.
- If the request body includes valid TaskQueueSIDs that are not part of this account, these TaskQueueSIDs are included in the response but with zero values for all statistics.
- This Bulk Retrieval API has a rate limit of 5 requests per second. If this rate limit is exceeded, an HTTP 429 error is returned.

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.

_10GET /v1/Workspaces/{WorkspaceSid}/TaskQueues/{TaskQueueSid}/CumulativeStatistics

Path Parameter

The SID of the TaskQueue for which to fetch statistics.

Query Parameter

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

Query Parameter

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

Query Parameter

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

Query Parameter

Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`

, such as `voice`

, `sms`

, or `default`

.

Query Parameter

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:

The average time in seconds between Task creation and acceptance.

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

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

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

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

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

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

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

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

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

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.

The wait duration statistics (`avg`

, `min`

, `max`

, `total`

) for Tasks canceled while in the TaskQueue.

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.

The absolute URL of the TaskQueue statistics resource.

(information)

Note that for transfers, the splitByWaitTime does not include the wait time post transfer, and hence transfers should not impact SLA calculations based on the above endpoint.

_10GET /v1/Workspaces/{WorkspaceSid}/TaskQueues/{TaskQueueSid}/Statistics

Path Parameter

The SID of the TaskQueue for which to fetch statistics.

Query Parameter

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

Query Parameter

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

Query Parameter

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

Query Parameter

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`

.

Query Parameter

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.

(warning)

`Minutes`

cannot be used in combination with `StartDate`

and `EndDate`

parameters. If no parameters are passed, 15 minutes will be the default.

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

The absolute URL of the TaskQueue statistics resource.