NAME
Twilio::Rest::Api::V2010::Account::Call - The Call resource
SYNOPSIS
my $client = Twilio::Rest::Client->new($account_sid, $auth_token);
my $call = $client->calls->create($to, $from, \%options);
for my $call ($client->calls->read({}, 20)) {
...
}
my $call = $client->calls($sid)->fetch;
$client->calls($sid)->update(\%options);
$client->calls($sid)->delete;
DESCRIPTION
A Call is an object that represents a connection between a telephone and Twilio.
This file holds CallList, CallPage, CallContext and CallInstance. Methods that make a request throw Twilio::Exceptions::RestException on an error response.
CallList
Returned by $client->calls. See also Twilio::ListResource.
create
my $call = $client->calls->create($to, $from, \%options);
Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections. Returns a CallInstance.
The required values are:
$to-
The phone number, SIP address, or client identifier to call.
$from-
The phone number or client identifier to use as the caller id. If using a phone number, it must be a Twilio number or a Verified outgoing caller id for your account. If the
toparameter is a phone number,Frommust also be a phone number.
The options are:
application_sid-
The SID of the Application resource that will handle the call, if the call will be handled by an application.
async_amd-
Select whether to perform answering machine detection in the background. Default, blocks the execution of the call until Answering Machine Detection is completed. Can be:
trueorfalse. async_amd_status_callback-
The URL that we should call using the
async_amd_status_callback_methodto notify customer application whether the call was answered by human, machine or fax. async_amd_status_callback_method-
The HTTP method we should use when calling the
async_amd_status_callbackURL. Can be:GETorPOSTand the default isPOST. One ofGETorPOST. byoc-
The SID of a BYOC (Bring Your Own Carrier) trunk to route this call with. Note that
byocis only meaningful whentois a phone number; it will otherwise be ignored. (Beta) call_reason-
The Reason for the outgoing call. Use it to specify the purpose of the call that is presented on the called party's phone. (Branded Calls Beta)
call_token-
A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call.
caller_id-
The phone number, SIP address, or Client identifier that made this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as
name@company.com. client_notification_url-
The URL that we should use to deliver
push call notification. fallback_method-
The HTTP method that we should use to request the
fallback_url. Can be:GETorPOSTand the default isPOST. If anapplication_sidparameter is present, this parameter is ignored. One ofGETorPOST. fallback_url-
The URL that we call using the
fallback_methodif an error occurs when requesting or executing the TwiML aturl. If anapplication_sidparameter is present, this parameter is ignored. machine_detection-
Whether to detect if a human, answering machine, or fax has picked up the call. Can be:
EnableorDetectMessageEnd. UseEnableif you would like us to returnAnsweredByas soon as the called party is identified. UseDetectMessageEnd, if you would like to leave a message on an answering machine. Ifsend_digitsis provided, this parameter is ignored. For more information, see Answering Machine Detection. machine_detection_silence_timeout-
The number of milliseconds of initial silence after which an
unknownAnsweredBy result will be returned. Possible Values: 2000-10000. Default: 5000. machine_detection_speech_end_threshold-
The number of milliseconds of silence after speech activity at which point the speech activity is considered complete. Possible Values: 500-5000. Default: 1200.
machine_detection_speech_threshold-
The number of milliseconds that is used as the measuring stick for the length of the speech activity, where durations lower than this value will be interpreted as a human and longer than this value as a machine. Possible Values: 1000-6000. Default: 2400.
machine_detection_timeout-
The number of seconds that we should attempt to detect an answering machine before timing out and sending a voice request with
AnsweredByofunknown. The default timeout is 30 seconds. method-
The HTTP method we should use when calling the
urlparameter's value. Can be:GETorPOSTand the default isPOST. If anapplication_sidparameter is present, this parameter is ignored. One ofGETorPOST. passports-
The STIR/SHAKEN passport for this call, provided as a base64 encoded string. Multiple passports (at max 5) are comma separated and provided as base64 encoded string
record-
Whether to record the call. Can be
trueto record the phone call, orfalseto not. The default isfalse. Therecording_urlis sent to thestatus_callbackURL. recording_channels-
The number of channels in the final recording. Can be:
monoordual. The default ismono.monorecords both legs of the call in a single channel of the recording file.dualrecords each leg to a separate channel of the recording file. The first channel of a dual-channel recording contains the parent call and the second channel contains the child call. recording_configuration_id-
The identifier of the configuration to be used when creating and processing the recording
recording_status_callback-
The URL that we call when the recording is available to be accessed.
recording_status_callback_event-
The recording status events that will trigger calls to the URL specified in
recording_status_callback. Can be:in-progress,completedandabsent. Defaults tocompleted. Separate multiple values with a space. An array reference. recording_status_callback_method-
The HTTP method we should use when calling the
recording_status_callbackURL. Can be:GETorPOSTand the default isPOST. One ofGETorPOST. recording_track-
The audio track to record for the call. Can be:
inbound,outboundorboth. The default isboth.inboundrecords the audio that is received by Twilio.outboundrecords the audio that is generated from Twilio.bothrecords the audio that is received and generated by Twilio. send_digits-
The string of keys to dial after connecting to the number, with a maximum length of 32 digits. Valid digits in the string include any digit (
0-9), 'A', 'B', 'C', 'D', '#', and '*'. You can also use 'w' to insert a half-second pause and 'W' to insert a one-second pause. For example, to pause for one second after connecting and then dial extension 1234 followed by the # key, set this parameter toW1234#. Be sure to URL-encode this string because the '#' character has special meaning in a URL. If bothSendDigitsandMachineDetectionparameters are provided, thenMachineDetectionwill be ignored. sip_auth_password-
The password required to authenticate the user account specified in
sip_auth_username. sip_auth_username-
The username used to authenticate the caller making a SIP call.
status_callback-
The URL we should call using the
status_callback_methodto send status information to your application. If nostatus_callback_eventis specified, we will send thecompletedstatus. If anapplication_sidparameter is present, this parameter is ignored. URLs must contain a valid hostname (underscores are not permitted). status_callback_event-
The call progress events that we will send to the
status_callbackURL. Can be:initiated,ringing,answered, andcompleted. If no event is specified, we send thecompletedstatus. If you want to receive multiple events, specify each one in a separatestatus_callback_eventparameter. See the code sample for monitoring call progress. If anapplication_sidis present, this parameter is ignored. An array reference. status_callback_method-
The HTTP method we should use when calling the
status_callbackURL. Can be:GETorPOSTand the default isPOST. If anapplication_sidparameter is present, this parameter is ignored. One ofGETorPOST. time_limit-
The maximum duration of the call in seconds. Constraints depend on account and configuration.
timeout-
The integer number of seconds that we should allow the phone to ring before assuming there is no answer. The default is
60seconds and the maximum is600seconds. For some call flows, we will add a 5-second buffer to the timeout value you provide. For this reason, a timeout value of 10 seconds could result in an actual timeout closer to 15 seconds. You can set this to a short time, such as15seconds, to hang up before reaching an answering machine or voicemail. trim-
Whether to trim any leading and trailing silence from the recording. Can be:
trim-silenceordo-not-trimand the default istrim-silence. twiml-
TwiML instructions for the call Twilio will use without fetching Twiml from url parameter. If both
twimlandurlare provided thentwimlparameter will be ignored. Max 4000 characters. url-
The absolute URL that returns the TwiML instructions for the call. We will call this URL using the
methodwhen the call connects. For more information, see the Url Parameter section in Making Calls.
read
my @records = $client->calls->read(\%options, $limit, $page_size);
Retrieves a collection of calls made to and from your account. Returns the records as a list, fetching as many pages as it needs.
The options are:
end_time-
Only include calls that ended on this date. Specify a date as
YYYY-MM-DDin UTC, for example:2009-07-06, to read only calls that ended on this date. A string, or an object with anepochmethod. See "iso8601_date_time" in Twilio::Serialize. end_time_before-
Only include calls that ended before this date. Specify a date as
YYYY-MM-DDin UTC, for example:2009-07-06, to read only calls that ended before this date. A string, or an object with anepochmethod. See "iso8601_date_time" in Twilio::Serialize. end_time_after-
Only include calls that ended on or after this date. Specify a date as
YYYY-MM-DDin UTC, for example:2009-07-06, to read only calls that ended on or after this date. A string, or an object with anepochmethod. See "iso8601_date_time" in Twilio::Serialize. from-
Only include calls from this phone number, SIP address, Client identifier or SIM SID.
parent_call_sid-
Only include calls spawned by calls with this SID.
start_time-
Only include calls that started on this date. Specify a date as
YYYY-MM-DDin UTC, for example:2009-07-06, to read only calls that started on this date. A string, or an object with anepochmethod. See "iso8601_date_time" in Twilio::Serialize. start_time_before-
Only include calls that started before this date. Specify a date as
YYYY-MM-DDin UTC, for example:2009-07-06, to read only calls that started before this date. A string, or an object with anepochmethod. See "iso8601_date_time" in Twilio::Serialize. start_time_after-
Only include calls that started on or after this date. Specify a date as
YYYY-MM-DDin UTC, for example:2009-07-06, to read only calls that started on or after this date. A string, or an object with anepochmethod. See "iso8601_date_time" in Twilio::Serialize. status-
The status of the calls to include. Can be:
queued,ringing,in-progress,canceled,completed,failed,busy, orno-answer. One ofqueued,ringing,in-progress,completed,busy,failed,no-answerorcanceled. to-
Only show calls made to this phone number, SIP address, Client identifier or SIM SID.
stream
my $stream = $client->calls->stream(\%options, $limit, $page_size);
Takes the same arguments as "read", and returns a Twilio::Stream.
page
my $page = $client->calls->page(\%options, $page_size, $page_token, $page_number);
Fetches one page, and returns a Twilio::Page.
get_page
my $page = $client->calls->get_page($url);
Fetches the page at a URL given by Twilio.
get_context
my $context = $client->calls->get_context($sid);
Returns a CallContext, and makes no request.
CallPage
A Twilio::Page of CallInstance objects.
records_key
build_instance
Used by Twilio::Page.
CallContext
Returned by $client->calls($sid). It makes no request until one of these methods is called.
fetch
my $call = $client->calls($sid)->fetch;
Fetch the call specified by the provided Call SID. Returns a CallInstance.
update
my $call = $client->calls($sid)->update(\%options);
Initiates a call redirect or terminates a call. Returns a CallInstance.
The options are:
fallback_method-
The HTTP method that we should use to request the
fallback_url. Can be:GETorPOSTand the default isPOST. If anapplication_sidparameter is present, this parameter is ignored. One ofGETorPOST. fallback_url-
The URL that we call using the
fallback_methodif an error occurs when requesting or executing the TwiML aturl. If anapplication_sidparameter is present, this parameter is ignored. method-
The HTTP method we should use when calling the
url. Can be:GETorPOSTand the default isPOST. If anapplication_sidparameter is present, this parameter is ignored. One ofGETorPOST. status-
One of
canceledorcompleted. status_callback-
The URL we should call using the
status_callback_methodto send status information to your application. If nostatus_callback_eventis specified, we will send thecompletedstatus. If anapplication_sidparameter is present, this parameter is ignored. URLs must contain a valid hostname (underscores are not permitted). status_callback_method-
The HTTP method we should use when requesting the
status_callbackURL. Can be:GETorPOSTand the default isPOST. If anapplication_sidparameter is present, this parameter is ignored. One ofGETorPOST. time_limit-
The maximum duration of the call in seconds. Constraints depend on account and configuration.
twiml-
TwiML instructions for the call Twilio will use without fetching Twiml from url. Twiml and url parameters are mutually exclusive
url-
The absolute URL that returns the TwiML instructions for the call. We will call this URL using the
methodwhen the call connects. For more information, see the Url Parameter section in Making Calls.
delete
$client->calls($sid)->delete;
Delete a Call record from your account. Once the record is deleted, it will no longer appear in the API and Account Portal logs. Returns true.
events
my $list = $object->events;
See Twilio::Rest::Api::V2010::Account::Call::Event.
notifications
my $list = $object->notifications;
my $context = $object->notifications($sid);
See Twilio::Rest::Api::V2010::Account::Call::Notification.
payments
my $list = $object->payments;
my $context = $object->payments($sid);
See Twilio::Rest::Api::V2010::Account::Call::Payment.
recordings
my $list = $object->recordings;
my $context = $object->recordings($sid);
See Twilio::Rest::Api::V2010::Account::Call::Recording.
siprec
my $list = $object->siprec;
my $context = $object->siprec($sid);
See Twilio::Rest::Api::V2010::Account::Call::Siprec.
streams
my $list = $object->streams;
my $context = $object->streams($sid);
See Twilio::Rest::Api::V2010::Account::Call::Stream.
transcriptions
my $list = $object->transcriptions;
my $context = $object->transcriptions($sid);
See Twilio::Rest::Api::V2010::Account::Call::Transcription.
user_defined_messages
my $list = $object->user_defined_messages;
See Twilio::Rest::Api::V2010::Account::Call::UserDefinedMessage.
user_defined_message_subscriptions
my $list = $object->user_defined_message_subscriptions;
my $context = $object->user_defined_message_subscriptions($sid);
See Twilio::Rest::Api::V2010::Account::Call::UserDefinedMessageSubscription.
CallInstance
See also Twilio::InstanceResource.
It has fetch, update, delete, events, notifications, payments, recordings, siprec, streams, transcriptions, user_defined_messages and user_defined_message_subscriptions, which work as they do on the context.
Its fields are:
- account_sid
-
The SID of the Account that created this Call resource.
- answered_by
-
Either
humanormachineif this call was initiated with answering machine detection. Empty otherwise. - api_version
-
The API version used to create the call.
- caller_name
-
The caller's name if this call was an incoming call to a phone number with caller ID Lookup enabled. Otherwise, empty.
- date_created
-
The date and time in UTC that this resource was created specified in RFC 2822 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.
- date_updated
-
The date and time in UTC that this resource was last updated, specified in RFC 2822 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.
- direction
-
A string describing the direction of the call. Can be:
inboundfor inbound calls,outbound-apifor calls initiated via the REST API oroutbound-dialfor calls initiated by a<Dial>verb. Using Elastic SIP Trunking, the values can betrunking-terminatingfor outgoing calls from your communications infrastructure to the PSTN ortrunking-originatingfor incoming calls to your communications infrastructure from the PSTN. - duration
-
The length of the call in seconds. This value is empty for busy, failed, unanswered, or ongoing calls.
- end_time
-
The time the call ended, given as UTC in RFC 2822 format. Empty if the call did not complete successfully. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.
- forwarded_from
-
The forwarding phone number if this call was an incoming call forwarded from another number (depends on carrier supporting forwarding). Otherwise, empty.
- from
-
The phone number, SIP address, Client identifier or SIM SID that made this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as
name@company.com. Client identifiers are formattedclient:name. SIM SIDs are formatted assim:sid. - from_formatted
-
The calling phone number, SIP address, or Client identifier formatted for display. Non-North American phone numbers are in E.164 format (e.g., +442071838750).
- group_sid
-
The Group SID associated with this call. If no Group is associated with the call, the field is empty.
- parent_call_sid
-
The SID that identifies the call that created this leg.
- phone_number_sid
-
If the call was inbound, this is the SID of the IncomingPhoneNumber resource that received the call. If the call was outbound, it is the SID of the OutgoingCallerId resource from which the call was placed.
- price
-
The charge for this call, in the currency associated with the account. Populated after the call is completed. May not be immediately available. The price associated with a call only reflects the charge for connectivity. Charges for other call-related features such as Answering Machine Detection, Text-To-Speech, and SIP REFER are not included in this value.
- price_unit
-
The currency in which
Priceis measured, in ISO 4127 format (e.g.,USD,EUR,JPY). Always capitalized for calls. - queue_time
-
The wait time in milliseconds before the call is placed.
- sid
-
The unique string that we created to identify this Call resource.
- start_time
-
The start time of the call, given as UTC in RFC 2822 format. Empty if the call has not yet been dialed. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.
- status
-
One of
queued,ringing,in-progress,completed,busy,failed,no-answerorcanceled. - stir_verstat
-
The STIR/SHAKEN verification status of the call, for example
TN-Validation-Passed-A. Empty if the incoming call had no STIR/SHAKEN information. - subresource_uris
-
A list of subresources available to this call, identified by their URIs relative to
https://api.twilio.com. - to
-
The phone number, SIP address, Client identifier or SIM SID that received this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as
name@company.com. Client identifiers are formattedclient:name. SIM SIDs are formatted assim:sid. - to_formatted
-
The phone number, SIP address or Client identifier that received this call. Formatted for display. Non-North American phone numbers are in E.164 format (e.g., +442071838750).
- trunk_sid
-
The unique identifier of the trunk resource that was used for this call. The field is empty if the call was not made using a SIP trunk or if the call is not terminated.
- uri
-
The URI of this resource, relative to
https://api.twilio.com.
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.