NAME
Twilio::Rest::Taskrouter::V1::Workspace::Task - The Task resource
SYNOPSIS
my $client = Twilio::Rest::Client->new($account_sid, $auth_token);
my $task = $client->taskrouter->v1->workspaces($workspace_sid)->tasks->create(\%options);
for my $task ($client->taskrouter->v1->workspaces($workspace_sid)->tasks->read({}, 20)) {
...
}
my $task = $client->taskrouter->v1->workspaces($workspace_sid)->tasks($sid)->fetch;
$client->taskrouter->v1->workspaces($workspace_sid)->tasks($sid)->update(\%options);
$client->taskrouter->v1->workspaces($workspace_sid)->tasks($sid)->delete;
DESCRIPTION
This file holds TaskList, TaskPage, TaskContext and TaskInstance. Methods that make a request throw Twilio::Exceptions::RestException on an error response.
TaskList
Returned by $client->taskrouter->v1->workspaces($workspace_sid)->tasks. See also Twilio::ListResource.
create
my $task = $client->taskrouter->v1->workspaces($workspace_sid)->tasks->create(\%options);
Returns a TaskInstance.
The options are:
attributes-
A JSON string with the attributes of the new task. This value is passed to the Workflow's
assignment_callback_urlwhen the Task is assigned to a Worker. For example:{ "task_type": "call", "twilio_call_sid": "CAxxx", "customer_ticket_number": "12345" }. ignore_capacity-
A boolean that indicates if the Task should respect a Worker's capacity and availability during assignment. This field can only be used when the
RoutingTargetfield is set to a Worker SID. By settingIgnoreCapacityto a value oftrue,1, oryes, the Task will be routed to the Worker without respecting their capacity and availability. Any other value will enforce the Worker's capacity and availability. The default value ofIgnoreCapacityistruewhen theRoutingTargetis set to a Worker SID. priority-
The priority to assign the new task and override the default. When supplied, the new Task will have this priority unless it matches a Workflow Target with a Priority set. When not supplied, the new Task will have the priority of the matching Workflow Target. Value can be 0 to 2^31^ (2,147,483,647).
routing_target-
A SID of a Worker, Queue, or Workflow to route a Task to
task_channel-
When MultiTasking is enabled, specify the TaskChannel by passing either its
unique_nameorsid. Default value isdefault. task_queue_sid-
The SID of the TaskQueue in which the Task belongs
timeout-
The amount of time in seconds the new task can live before being assigned. Can be up to a maximum of 2 weeks (1,209,600 seconds). The default value is 24 hours (86,400 seconds). On timeout, the
task.canceledevent will fire with descriptionTask TTL Exceeded. virtual_start_time-
The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to
date_created. Value can't be in the future or before the year of 1900. A string, or an object with anepochmethod. See "iso8601_date_time" in Twilio::Serialize. workflow_sid-
The SID of the Workflow that you would like to handle routing for the new Task. If there is only one Workflow defined for the Workspace that you are posting the new task to, this parameter is optional.
read
my @records = $client->taskrouter->v1->workspaces($workspace_sid)->tasks->read(\%options, $limit, $page_size);
Returns the records as a list, fetching as many pages as it needs.
The options are:
assignment_status-
The
assignment_statusof the Tasks you want to read. Can be:pending,reserved,assigned,canceled,wrapping, orcompleted. Returns all Tasks in the Workspace with the specifiedassignment_status. An array reference. evaluate_task_attributes-
The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter.
has_addons-
Whether to read Tasks with Add-ons. If
true, returns only Tasks with Add-ons. Iffalse, returns only Tasks without Add-ons. ordering-
How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as:
Attribute:Order, whereAttributecan be eitherDateCreated,Priority, orVirtualStartTimeandOrdercan be eitherascordesc. For example,Priority:descreturns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such asPriority:desc,DateCreated:asc, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime. priority-
The priority value of the Tasks to read. Returns the list of all Tasks in the Workspace with the specified priority.
routing_target-
A SID of a Worker, Queue, or Workflow to route a Task to
task_queue_name-
The
friendly_nameof the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name. task_queue_sid-
The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID.
workflow_name-
The friendly name of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this friendly name.
workflow_sid-
The SID of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this SID.
stream
my $stream = $client->taskrouter->v1->workspaces($workspace_sid)->tasks->stream(\%options, $limit, $page_size);
Takes the same arguments as "read", and returns a Twilio::Stream.
page
my $page = $client->taskrouter->v1->workspaces($workspace_sid)->tasks->page(\%options, $page_size, $page_token, $page_number);
Fetches one page, and returns a Twilio::Page.
get_page
my $page = $client->taskrouter->v1->workspaces($workspace_sid)->tasks->get_page($url);
Fetches the page at a URL given by Twilio.
get_context
my $context = $client->taskrouter->v1->workspaces($workspace_sid)->tasks->get_context($sid);
Returns a TaskContext, and makes no request.
TaskPage
A Twilio::Page of TaskInstance objects.
records_key
build_instance
Used by Twilio::Page.
TaskContext
Returned by $client->taskrouter->v1->workspaces($workspace_sid)->tasks($sid). It makes no request until one of these methods is called.
fetch
my $task = $client->taskrouter->v1->workspaces($workspace_sid)->tasks($sid)->fetch;
Returns a TaskInstance.
update
my $task = $client->taskrouter->v1->workspaces($workspace_sid)->tasks($sid)->update(\%options);
Returns a TaskInstance.
The options are:
assignment_status-
One of
pending,reserved,assigned,canceled,completedorwrapping. attributes-
The JSON string that describes the custom attributes of the task.
priority-
The Task's new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647).
reason-
The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason.
task_channel-
When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel's SID or its
unique_name, such asvoice,sms, ordefault. virtual_start_time-
The task's new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can't be in the future or before the year of 1900. A string, or an object with an
epochmethod. See "iso8601_date_time" in Twilio::Serialize. if_match-
If provided, applies this mutation if (and only if) the ETag header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP If-Match header.
delete
$client->taskrouter->v1->workspaces($workspace_sid)->tasks($sid)->delete(\%options);
Returns true.
The options are:
if_match-
If provided, deletes this Task if (and only if) the ETag header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP If-Match header.
reservations
my $list = $object->reservations;
my $context = $object->reservations($sid);
See Twilio::Rest::Taskrouter::V1::Workspace::Task::Reservation.
TaskInstance
See also Twilio::InstanceResource.
It has fetch, update, delete and reservations, which work as they do on the context.
Its fields are:
- account_sid
-
The SID of the Account that created the Task resource.
- addons
-
An object that contains the Add-on data for all installed Add-ons.
- age
-
The number of seconds since the Task was created.
- assignment_status
-
One of
pending,reserved,assigned,canceled,completedorwrapping. - attributes
-
The JSON string with custom attributes of the work. Note If this property has been assigned a value, it will only be displayed in FETCH action that returns a single resource. Otherwise, it will be null.
- date_created
-
The date and time in GMT when the resource was created specified in ISO 8601 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.
- date_updated
-
The date and time in GMT when the resource was last updated specified in ISO 8601 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.
- ignore_capacity
-
A boolean that indicates if the Task should respect a Worker's capacity and availability during assignment. This field can only be used when the
RoutingTargetfield is set to a Worker SID. By settingIgnoreCapacityto a value oftrue,1, oryes, the Task will be routed to the Worker without respecting their capacity and availability. Any other value will enforce the Worker's capacity and availability. The default value ofIgnoreCapacityistruewhen theRoutingTargetis set to a Worker SID. - links
-
The URLs of related resources.
- priority
-
The current priority score of the Task as assigned to a Worker by the workflow. Tasks with higher priority values will be assigned before Tasks with lower values.
- reason
-
The reason the Task was canceled or completed, if applicable.
- routing_target
-
A SID of a Worker, Queue, or Workflow to route a Task to
- sid
-
The unique string that we created to identify the Task resource.
- task_channel_sid
-
The SID of the TaskChannel.
- task_channel_unique_name
-
The unique name of the TaskChannel.
- task_queue_entered_date
-
The date and time in GMT when the Task entered the TaskQueue, specified in ISO 8601 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.
- task_queue_friendly_name
-
The friendly name of the TaskQueue.
- task_queue_sid
-
The SID of the TaskQueue.
- timeout
-
The amount of time in seconds that the Task can live before being assigned.
- url
-
The absolute URL of the Task resource.
- virtual_start_time
-
The date and time in GMT indicating the ordering for routing of the Task specified in ISO 8601 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.
- workflow_friendly_name
-
The friendly name of the Workflow that is controlling the Task.
- workflow_sid
-
The SID of the Workflow that is controlling the Task.
- workspace_sid
-
The SID of the Workspace that contains the Task.
CONSTRUCTORS
new
Objects here come from the methods above, so there is no need to call new directly.
LICENSE
Copyright (c) 2026 Francisco Zarabozo. Released under the MIT License.