Skip to content

Twilio: Create a new outgoing call to phones, SIP-enabled endpoints or Twilio Client connections

Twilio call.createCall: arguments, response, policy and SDK examples.

← Call operations · Get started

Operation twilio.createcall

Provider route: POST /2010-04-01/Accounts/{AccountSid}/Calls.json. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/twilio with npm, or alter-sdk-twilio with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { TwilioIntegration } from "@alter-ai/twilio";
async function execute(input: Parameters<TwilioIntegration["call"]["createCall"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new TwilioIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.call.createCall(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_twilio import TwilioIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = TwilioIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.call.create_call(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.AccountSidstringRequired within parentMaximum length: 34
Minimum length: 34
Pattern: ^AC[0-9a-fA-F]{32}$
bodyobjectRequired within parent
body.ApplicationSidstringOptionalThe SID of the Application resource that will handle the call, if the call will be handled by an application.
Maximum length: 34
Minimum length: 34
Pattern: ^AP[0-9a-fA-F]{32}$
body.AsyncAmdstringOptionalSelect whether to perform answering machine detection in the background. Default, blocks the execution of the call until Answering Machine Detection is completed. Can be: `true` or `false`.
body.AsyncAmdStatusCallbackstringOptionalThe URL that we should call using the `async_amd_status_callback_method` to notify customer application whether the call was answered by human, machine or fax.
Format: uri
body.AsyncAmdStatusCallbackMethodstringOptionalThe HTTP method we should use when calling the `async_amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`.
One of: GET, POST
Format: http-method
body.ByocstringOptionalThe SID of a BYOC (Bring Your Own Carrier) trunk to route this call with. Note that `byoc` is only meaningful when `to` is a phone number; it will otherwise be ignored. (Beta)
Maximum length: 34
Minimum length: 34
Pattern: ^BY[0-9a-fA-F]{32}$
body.CallReasonstringOptionalThe 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)
body.CallTokenstringOptionalA 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.
body.CallerIdstringOptionalThe phone number, SIP address, or Client identifier that made this call. Phone numbers are in [E.164 format](https://wwnw.twilio.com/docs/glossary/what-e164) (e.g., +16175551212). SIP addresses are formatted as `name@example.com`.
body.ClientNotificationUrlstringOptionalThe URL that we should use to deliver `push call notification`.
Format: uri
body.FallbackMethodstringOptionalThe HTTP method that we should use to request the `fallback_url`. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored.
One of: GET, POST
Format: http-method
body.FallbackUrlstringOptionalThe URL that we call using the `fallback_method` if an error occurs when requesting or executing the TwiML at `url`. If an `application_sid` parameter is present, this parameter is ignored.
Format: uri
body.FromstringRequired within parentThe 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](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `From` must also be a phone number.
Format: endpoint
body.MachineDetectionstringOptionalWhether to detect if a human, answering machine, or fax has picked up the call. Can be: `Enable` or `DetectMessageEnd`. Use `Enable` if you would like us to return `AnsweredBy` as soon as the called party is identified. Use `DetectMessageEnd`, if you would like to leave a message on an answering machine. If `send_digits` is provided, this parameter is ignored. For more information, see [Answering Machine Detection](https://www.twilio.com/docs/voice/answering-machine-detection).
body.MachineDetectionSilenceTimeoutintegerOptionalThe number of milliseconds of initial silence after which an `unknown` AnsweredBy result will be returned. Possible Values: 2000-10000. Default: 5000.
body.MachineDetectionSpeechEndThresholdintegerOptionalThe number of milliseconds of silence after speech activity at which point the speech activity is considered complete. Possible Values: 500-5000. Default: 1200.
body.MachineDetectionSpeechThresholdintegerOptionalThe 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.
body.MachineDetectionTimeoutintegerOptionalThe number of seconds that we should attempt to detect an answering machine before timing out and sending a voice request with `AnsweredBy` of `unknown`. The default timeout is 30 seconds.
body.MethodstringOptionalThe HTTP method we should use when calling the `url` parameter’s value. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored.
One of: GET, POST
Format: http-method
body.PassportsstringOptionalThe 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
body.RecordbooleanOptionalWhether to record the call. Can be `true` to record the phone call, or `false` to not. The default is `false`. The `recording_url` is sent to the `status_callback` URL.
body.RecordingChannelsstringOptionalThe number of channels in the final recording. Can be: `mono` or `dual`. The default is `mono`. `mono` records both legs of the call in a single channel of the recording file. `dual` records 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.
body.RecordingConfigurationIdstringOptionalThe identifier of the configuration to be used when creating and processing the recording
body.RecordingStatusCallbackstringOptionalThe URL that we call when the recording is available to be accessed.
body.RecordingStatusCallbackEventarrayOptionalThe recording status events that will trigger calls to the URL specified in `recording_status_callback`. Can be: `in-progress`, `completed` and `absent`. Defaults to `completed`. Separate multiple values with a space.
body.RecordingStatusCallbackEvent[]stringEach item
body.RecordingStatusCallbackMethodstringOptionalThe HTTP method we should use when calling the `recording_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`.
One of: GET, POST
Format: http-method
body.RecordingTrackstringOptionalThe audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is generated from Twilio. `both` records the audio that is received and generated by Twilio.
body.SendDigitsstringOptionalThe 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 to `W1234#`. Be sure to URL-encode this string because the ’`#`’ character has special meaning in a URL. If both `SendDigits` and `MachineDetection` parameters are provided, then `MachineDetection` will be ignored.
body.SipAuthPasswordstringOptionalThe password required to authenticate the user account specified in `sip_auth_username`.
body.SipAuthUsernamestringOptionalThe username used to authenticate the caller making a SIP call.
body.StatusCallbackstringOptionalThe URL we should call using the `status_callback_method` to send status information to your application. If no `status_callback_event` is specified, we will send the `completed` status. If an `application_sid` parameter is present, this parameter is ignored. URLs must contain a valid hostname (underscores are not permitted).
Format: uri
body.StatusCallbackEventarrayOptionalThe call progress events that we will send to the `status_callback` URL. Can be: `initiated`, `ringing`, `answered`, and `completed`. If no event is specified, we send the `completed` status. If you want to receive multiple events, specify each one in a separate `status_callback_event` parameter. See the code sample for [monitoring call progress](https://www.twilio.com/docs/voice/api/call-resource?code-sample=code-create-a-call-resource-and-specify-a-statuscallbackevent&amp;code-sdk-version=json). If an `application_sid` is present, this parameter is ignored.
body.StatusCallbackEvent[]stringEach item
body.StatusCallbackMethodstringOptionalThe HTTP method we should use when calling the `status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored.
One of: GET, POST
Format: http-method
body.TimeLimitintegerOptionalThe maximum duration of the call in seconds. Constraints depend on account and configuration.
body.TimeoutintegerOptionalThe integer number of seconds that we should allow the phone to ring before assuming there is no answer. The default is `60` seconds and the maximum is `600` seconds. 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 as `15` seconds, to hang up before reaching an answering machine or voicemail.
body.TostringRequired within parentThe phone number, SIP address, or client identifier to call.
Format: endpoint
body.TrimstringOptionalWhether to trim any leading and trailing silence from the recording. Can be: `trim-silence` or `do-not-trim` and the default is `trim-silence`.
body.TwimlstringOptionalTwiML instructions for the call Twilio will use without fetching Twiml from url parameter. If both `twiml` and `url` are provided then `twiml` parameter will be ignored. Max 4000 characters.
Format: twiml
body.UrlstringOptionalThe absolute URL that returns the TwiML instructions for the call. We will call this URL using the `method` when the call connects. For more information, see the [Url Parameter](https://www.twilio.com/docs/voice/make-calls#specify-a-url-parameter) section in [Making Calls](https://www.twilio.com/docs/voice/make-calls).
Format: uri

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Initiates a call redirect or terminates a call — response body

Referenced models: Initiates a call redirect or terminates a call — response body

Initiates a call redirect or terminates a call — response body
FieldTypePresenceDescription and constraints
$objectRoot
account_sidJSONOptional
account_sid (anyOf 1)stringAlternativeThe SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this Call resource.
Maximum length: 34
Minimum length: 34
Pattern: ^AC[0-9a-fA-F]{32}$
account_sid (anyOf 2)nullAlternative
answered_byJSONOptional
answered_by (anyOf 1)stringAlternativeEither `human` or `machine` if this call was initiated with answering machine detection. Empty otherwise.
answered_by (anyOf 2)nullAlternative
api_versionJSONOptional
api_version (anyOf 1)stringAlternativeThe API version used to create the call.
api_version (anyOf 2)nullAlternative
caller_nameJSONOptional
caller_name (anyOf 1)stringAlternativeThe caller's name if this call was an incoming call to a phone number with caller ID Lookup enabled. Otherwise, empty.
caller_name (anyOf 2)nullAlternative
date_createdJSONOptional
date_created (anyOf 1)stringAlternativeThe date and time in UTC that this resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
Format: date-time-rfc-2822
date_created (anyOf 2)nullAlternative
date_updatedJSONOptional
date_updated (anyOf 1)stringAlternativeThe date and time in UTC that this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
Format: date-time-rfc-2822
date_updated (anyOf 2)nullAlternative
directionJSONOptional
direction (anyOf 1)stringAlternativeA string describing the direction of the call. Can be: `inbound` for inbound calls, `outbound-api` for calls initiated via the REST API or `outbound-dial` for calls initiated by a `<Dial>` verb. Using [Elastic SIP Trunking](https://www.twilio.com/docs/sip-trunking), the values can be [`trunking-terminating`](https://www.twilio.com/docs/sip-trunking#termination) for outgoing calls from your communications infrastructure to the PSTN or [`trunking-originating`](https://www.twilio.com/docs/sip-trunking#origination) for incoming calls to your communications infrastructure from the PSTN.
direction (anyOf 2)nullAlternative
durationJSONOptional
duration (anyOf 1)stringAlternativeThe length of the call in seconds. This value is empty for busy, failed, unanswered, or ongoing calls.
duration (anyOf 2)nullAlternative
end_timeJSONOptional
end_time (anyOf 1)stringAlternativeThe time the call ended, given as UTC in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. Empty if the call did not complete successfully.
Format: date-time-rfc-2822
end_time (anyOf 2)nullAlternative
forwarded_fromJSONOptional
forwarded_from (anyOf 1)stringAlternativeThe forwarding phone number if this call was an incoming call forwarded from another number (depends on carrier supporting forwarding). Otherwise, empty.
forwarded_from (anyOf 2)nullAlternative
fromJSONOptional
from (anyOf 1)stringAlternativeThe phone number, SIP address, Client identifier or SIM SID that made this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as `name@example.com`. Client identifiers are formatted `client:name`. SIM SIDs are formatted as `sim:sid`.
from (anyOf 2)nullAlternative
from_formattedJSONOptional
from_formatted (anyOf 1)stringAlternativeThe calling phone number, SIP address, or Client identifier formatted for display. Non-North American phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +442071838750).
from_formatted (anyOf 2)nullAlternative
group_sidJSONOptional
group_sid (anyOf 1)stringAlternativeThe Group SID associated with this call. If no Group is associated with the call, the field is empty.
Maximum length: 34
Minimum length: 34
Pattern: ^GP[0-9a-fA-F]{32}$
group_sid (anyOf 2)nullAlternative
parent_call_sidJSONOptional
parent_call_sid (anyOf 1)stringAlternativeThe SID that identifies the call that created this leg.
Maximum length: 34
Minimum length: 34
Pattern: ^CA[0-9a-fA-F]{32}$
parent_call_sid (anyOf 2)nullAlternative
phone_number_sidJSONOptional
phone_number_sid (anyOf 1)stringAlternativeIf 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.
Maximum length: 34
Minimum length: 34
Pattern: ^PN[0-9a-fA-F]{32}$
phone_number_sid (anyOf 2)nullAlternative
priceJSONOptional
price (anyOf 1)stringAlternativeThe 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 (anyOf 2)nullAlternative
price_unitJSONOptional
price_unit (anyOf 1)stringAlternativeThe currency in which `Price` is measured, in [ISO 4127](https://www.iso.org/iso/home/standards/currency_codes.htm) format (e.g., `USD`, `EUR`, `JPY`). Always capitalized for calls.
Format: currency
price_unit (anyOf 2)nullAlternative
queue_timeJSONOptional
queue_time (anyOf 1)stringAlternativeThe wait time in milliseconds before the call is placed.
queue_time (anyOf 2)nullAlternative
sidJSONOptional
sid (anyOf 1)stringAlternativeThe unique string that we created to identify this Call resource.
Maximum length: 34
Minimum length: 34
Pattern: ^CA[0-9a-fA-F]{32}$
sid (anyOf 2)nullAlternative
start_timeJSONOptional
start_time (anyOf 1)stringAlternativeThe start time of the call, given as UTC in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. Empty if the call has not yet been dialed.
Format: date-time-rfc-2822
start_time (anyOf 2)nullAlternative
statusstringOptionalThe status of this call. Can be: `queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy` or `no-answer`. See [Call Status Values](https://www.twilio.com/docs/voice/api/call-resource#call-status-values) below for more information.
Known values: queued, ringing, in-progress, completed, busy, failed, no-answer, canceled
stir_verstatJSONOptional
stir_verstat (anyOf 1)stringAlternativeThe STIR/SHAKEN verification status of the call, for example `TN-Validation-Passed-A`. Empty if the incoming call had no STIR/SHAKEN information.
stir_verstat (anyOf 2)nullAlternative
subresource_urisJSONOptional
subresource_uris (anyOf 1)objectAlternativeA list of subresources available to this call, identified by their URIs relative to `https://api.twilio.com`.
Format: uri-map
subresource_uris (anyOf 2)nullAlternative
toJSONOptional
to (anyOf 1)stringAlternativeThe phone number, SIP address, Client identifier or SIM SID that received this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as `name@example.com`. Client identifiers are formatted `client:name`. SIM SIDs are formatted as `sim:sid`.
to (anyOf 2)nullAlternative
to_formattedJSONOptional
to_formatted (anyOf 1)stringAlternativeThe phone number, SIP address or Client identifier that received this call. Formatted for display. Non-North American phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +442071838750).
to_formatted (anyOf 2)nullAlternative
trunk_sidJSONOptional
trunk_sid (anyOf 1)stringAlternativeThe 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.
Maximum length: 34
Minimum length: 34
Pattern: ^TK[0-9a-fA-F]{32}$
trunk_sid (anyOf 2)nullAlternative
uriJSONOptional
uri (anyOf 1)stringAlternativeThe URI of this resource, relative to `https://api.twilio.com`.
uri (anyOf 2)nullAlternative

SDK function policy ID: twilio.createcall. Catalog operation: CreateCall. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand how our website, product, and documentation are used.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

Advertising

Shares visits and sign-ups with Meta, Reddit, and X so we can measure which of our ads work.

You can change these choices at any time from Cookie settings.