A Call is an object that represents a connection between a telephone and Twilio.
Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections
Path parameters
-
The SID of the Account that will create the resource.
Minimum length is
34, maximum length is34. Format should match the following pattern:^AC[0-9a-fA-F]{32}$.
Body
-
The phone number, SIP address, or client identifier to call.
-
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 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.Values are
GETorPOST. -
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. -
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.Values are
GETorPOST. -
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). -
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. -
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.Values are
GETorPOST. -
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. -
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. -
Whether to record the call. Can be
trueto record the phone call, orfalseto not. The default isfalse. Therecording_urlis sent to thestatus_callbackURL. -
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. -
The URL that we call when the recording is available to be accessed.
-
The HTTP method we should use when calling the
recording_status_callbackURL. Can be:GETorPOSTand the default isPOST.Values are
GETorPOST. -
The username used to authenticate the caller making a SIP call.
-
The password required to authenticate the user account specified in
sip_auth_username. -
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. -
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. -
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. -
Whether to trim any leading and trailing silence from the recording. Can be:
trim-silenceordo-not-trimand the default istrim-silence. -
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. -
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.
-
The number of milliseconds of silence after speech activity at which point the speech activity is considered complete. Possible Values: 500-5000. Default: 1200.
-
The number of milliseconds of initial silence after which an
unknownAnsweredBy result will be returned. Possible Values: 2000-10000. Default: 5000. -
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. -
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. -
The HTTP method we should use when calling the
async_amd_status_callbackURL. Can be:GETorPOSTand the default isPOST.Values are
GETorPOST. -
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)Minimum length is
34, maximum length is34. Format should match the following pattern:^BY[0-9a-fA-F]{32}$. -
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)
-
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.
-
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. -
The maximum duration of the call in seconds. Constraints depend on account and configuration.
-
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. -
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. -
The SID of the Application resource that will handle the call, if the call will be handled by an application.
Minimum length is
34, maximum length is34. Format should match the following pattern:^AP[0-9a-fA-F]{32}$.
curl \
--request POST 'https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls.json' \
--user "username:password" \
--header "Content-Type: application/x-www-form-urlencoded" \
--data 'To=%2B123456789&Url=https%3A%2F%2Fexample.com&Byoc=BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&From=%2B987654321&Trim=do-not-trim&Method=GET&Record=true&Timeout=1&AsyncAmd=true&CallerId=Caller&CallToken=call-token-string&IfMachine=if_machine&TimeLimit=3600&CallReason=Reason+for+the+call+%28Beta%29&SendDigits=send_digits&Transcribe=true&FallbackUrl=https%3A%2F%2Fexample.com&ApplicationSid=APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&FallbackMethod=GET&RecordingTrack=both&StatusCallback=https%3A%2F%2Fexample.com&MachineDetection=enable&StatusCallbackMethod=GET&AsyncAmdStatusCallback=http%3A%2F%2Fstatuscallback.com&MachineDetectionEngine=Lumenvox&MachineDetectionTimeout=15&TranscriptionConfiguration=JVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AsyncAmdStatusCallbackMethod=POST&MachineDetectionWordsSilence=50&MachineDetectionMaxNumOfWords=5&MachineDetectionMaxWordLength=5000&MachineDetectionMinWordLength=100&MachineDetectionSilenceTimeout=3000&MachineDetectionSpeechThreshold=3000&MachineDetectionSilenceThreshold=256&MachineDetectionSpeechEndThreshold=3000'
{"To" => "+123456789", "Url" => "https://example.com", "Byoc" => "BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "From" => "+987654321", "Trim" => "do-not-trim", "Method" => "GET", "Record" => "true", "Timeout" => 1, "AsyncAmd" => "true", "CallerId" => "Caller", "CallToken" => "call-token-string", "IfMachine" => "if_machine", "TimeLimit" => 3600, "CallReason" => "Reason for the call (Beta)", "SendDigits" => "send_digits", "Transcribe" => "true", "FallbackUrl" => "https://example.com", "ApplicationSid" => "APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "FallbackMethod" => "GET", "RecordingTrack" => "both", "StatusCallback" => "https://example.com", "MachineDetection" => "enable", "StatusCallbackMethod" => "GET", "AsyncAmdStatusCallback" => "http://statuscallback.com", "MachineDetectionEngine" => "Lumenvox", "MachineDetectionTimeout" => 15, "TranscriptionConfiguration" => "JVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "AsyncAmdStatusCallbackMethod" => "POST", "MachineDetectionWordsSilence" => 50, "MachineDetectionMaxNumOfWords" => 5, "MachineDetectionMaxWordLength" => 5000, "MachineDetectionMinWordLength" => 100, "MachineDetectionSilenceTimeout" => 3000, "MachineDetectionSpeechThreshold" => 3000, "MachineDetectionSilenceThreshold" => 256, "MachineDetectionSpeechEndThreshold" => 3000}
{"To" => "+123456789", "Url" => "", "From" => "+987654321", "Trim" => "do-not-trim", "Twiml" => "<Response><Say>Enjoy</Say></Response>", "Method" => "", "Record" => "true", "Timeout" => 1, "CallerId" => "Caller", "CallToken" => "call-token-string", "IfMachine" => "if_machine", "TimeLimit" => 3600, "CallReason" => "Reason for the call (Beta)", "SendDigits" => "send_digits", "Transcribe" => "true", "FallbackUrl" => "https://example.com", "ApplicationSid" => "APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "FallbackMethod" => "GET", "StatusCallback" => "https://example.com", "MachineDetection" => "enable", "StatusCallbackMethod" => "GET", "MachineDetectionTimeout" => 15, "TranscriptionConfiguration" => "JVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "MachineDetectionSilenceTimeout" => 3000, "MachineDetectionSpeechThreshold" => 3000, "MachineDetectionSpeechEndThreshold" => 3000}
{
"to": "+14158675309",
"sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
"from": "+14158675308",
"price": "-0.03000",
"status": "completed",
"duration": "15",
"end_time": "Tue, 31 Aug 2010 20:36:44 +0000",
"direction": "inbound",
"group_sid": null,
"trunk_sid": null,
"annotation": null,
"price_unit": "USD",
"queue_time": "1000",
"start_time": "Tue, 31 Aug 2010 20:36:29 +0000",
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"answered_by": null,
"api_version": "2010-04-01",
"caller_name": null,
"date_created": "Tue, 31 Aug 2010 20:36:28 +0000",
"date_updated": "Tue, 31 Aug 2010 20:36:44 +0000",
"to_formatted": "(415) 867-5309",
"forwarded_from": "+141586753093",
"from_formatted": "(415) 867-5308",
"parent_call_sid": null,
"phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"subresource_uris": {
"events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json",
"siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json",
"streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json",
"payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json",
"recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json",
"notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json",
"transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json",
"user_defined_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessages.json",
"user_defined_message_subscriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessageSubscriptions.json"
}
}
{
"to": "+14158675309",
"sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
"from": "+14158675308",
"price": "-0.03000",
"status": "completed",
"duration": "15",
"end_time": "Tue, 31 Aug 2010 20:36:44 +0000",
"direction": "inbound",
"group_sid": null,
"trunk_sid": null,
"annotation": null,
"price_unit": "USD",
"queue_time": "1000",
"start_time": "Tue, 31 Aug 2010 20:36:29 +0000",
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"answered_by": null,
"api_version": "2010-04-01",
"caller_name": null,
"date_created": "Tue, 31 Aug 2010 20:36:28 +0000",
"date_updated": "Tue, 31 Aug 2010 20:36:44 +0000",
"to_formatted": "(415) 867-5309",
"forwarded_from": "+141586753093",
"from_formatted": "(415) 867-5308",
"parent_call_sid": null,
"phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"subresource_uris": {
"events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json",
"siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json",
"streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json",
"payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json",
"recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json",
"notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json",
"transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json",
"user_defined_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessages.json",
"user_defined_message_subscriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessageSubscriptions.json"
}
}