NAME

Twilio::Jwt::ClientToken - A capability token for older Twilio Client applications

SYNOPSIS

use Twilio::Jwt::ClientToken;

my $capability = Twilio::Jwt::ClientToken->new($account_sid, $auth_token);
$capability->allow_client_incoming('alice');
$capability->allow_client_outgoing($application_sid, { caller => 'alice' });

print $capability->generate_token(3600);

DESCRIPTION

Twilio has deprecated Capability Tokens, and says they will eventually reach end of life. New code should use Twilio::Jwt::AccessToken, which is signed with an API key instead of your auth token, and works in every region. Capability Tokens only work in the US1 region. See Twilio's guide.

This class exists for applications that still rely on them.

METHODS

new

my $capability = Twilio::Jwt::ClientToken->new($account_sid, $auth_token);

allow_client_incoming

$capability->allow_client_incoming($client_name);

Lets the client receive calls under a name, which can only have letters, digits and underscores. It throws Twilio::Exceptions::TwilioException on any other name.

allow_client_outgoing

$capability->allow_client_outgoing($application_sid, \%params);

Lets the client make calls through a TwiML application.

allow_event_stream

$capability->allow_event_stream(\%filters);

Lets the client subscribe to its event stream.

add_claim

$capability->add_claim($name, $value);

Adds a claim of your own. It cannot replace scope, iss or exp.

generate_token

my $token = $capability->generate_token($ttl);

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

LICENSE

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