NAME

Twilio::Jwt::TaskRouter::CapabilityToken - A TaskRouter capability token

SYNOPSIS

use Twilio::Jwt::TaskRouter::WorkerCapability;

my $capability = Twilio::Jwt::TaskRouter::WorkerCapability->new(
  $account_sid, $auth_token, $workspace_sid, $worker_sid
);
$capability->allow_activity_updates;

print $capability->generate_token(3600);

DESCRIPTION

The base class of Twilio::Jwt::TaskRouter::WorkerCapability, Twilio::Jwt::TaskRouter::TaskQueueCapability and Twilio::Jwt::TaskRouter::WorkspaceCapability, which are the ones to use. Each token can use its own event channel and read its own resource, and these methods add more.

METHODS

new

my $capability = Twilio::Jwt::TaskRouter::CapabilityToken->new(
  $account_sid, $auth_token, $workspace_sid, $channel_id,
  $resource_url, $base_url, $base_ws_url
);

The last three are optional. It throws Twilio::Exceptions::TwilioException when a SID does not look right.

allow

$capability->allow($url, $method, \%query_filter, \%post_filter);

Adds a policy that allows a request. A filter that is left out is empty, and an undefined one is left out of the token.

deny

$capability->deny($url, $method, \%query_filter, \%post_filter);

Adds a policy that denies a request.

add_policy_deconstructed

my $policy = $capability->add_policy_deconstructed(
  $url, $method, \%query_filter, \%post_filter, $allow
);

Adds a policy, and returns its Twilio::Jwt::TaskRouter::Policy.

allow_fetch_subresources

allow_updates

allow_updates_subresources

allow_delete

allow_delete_subresources

Allow what each name says, on the resource of the token.

generate_token

my $token = $capability->generate_token($ttl, \%extra_attributes);

Returns the token. $ttl is in seconds, and defaults to 3600.

setup_resource

Sets the URL of the resource. Subclasses implement it.

LICENSE

Copyright (c) 2026 Francisco Zarabozo. Released under the MIT License.