NAME
Twilio::Metadata - The status code and headers of Twilio's answer, with the result
SYNOPSIS
my $answer = $client->messages->with_metadata(create => $to, { from => $from, body => 'Hi' });
my $message = $answer->get_data;
say $answer->get_status_code; # 201
say $answer->get_header('Twilio-Request-Id');
my $listed = $client->messages->with_metadata(read => {}, 20);
say scalar @{ $listed->get_data }, ' messages';
my $fetched = $client->messages($sid)->with_metadata('fetch');
DESCRIPTION
Every list and context has with_metadata, which runs one of its operations and returns an object of this class. It holds what the operation returns, and the status code and headers of Twilio's answer to it. twilio-php has the same with a WithMetadata twin of each operation, twilio-python with _with_http_info and twilio-node with WithHttpInfo.
When an operation makes more than one request, the first answer counts: for a read that goes through several pages, the first page's. A request repeated after HTTP 429 counts once, with its last answer.
An error answer still throws, as it does without with_metadata; the exception has the status code.
METHODS
capture
my $answer = Twilio::Metadata->capture($list_or_context, $operation, @arguments);
What with_metadata calls. It runs $list_or_context->$operation(@arguments) and records the answers the client gets meanwhile. It dies when there is no such operation, or when the operation makes no request.
new
my $answer = Twilio::Metadata->new($data, $status_code, \%headers);
get_data
What the operation returns:
for
create,fetch,updateandpatch, the instance;for
delete, 1;for
read, an array reference of the records;for
stream, the Twilio::Stream, and forpage, the page.
get_status_code
The HTTP status of the answer, such as 200 or 201.
get_headers
A hash reference of the answer's headers, as the HTTP client gave them. With the default client their names are in lower case.
get_header
my $value = $answer->get_header('Twilio-Request-Id');
One header, whatever the case of its name, or undef when the answer does not have it. A header sent more than once comes as one value, joined with commas.
LICENSE
Copyright (c) 2026 Francisco Zarabozo. Released under the MIT License.