Sample - Twilio API
POST/2010-04-01/Accounts/{AccountSid}/Calls/{Sid}.json

Update or terminate a call

Updates a call by redirecting it to new TwiML instructions or terminating it. Provide a call identifier and use either Url or Twiml for call instructions, or set Status to canceled or completed to terminate the call.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

2 parameters · 9 body fields
AccountSidstringrequired
The 34-character SID of the Account that created the Call resource, matching the `AC` prefix and 32 hexadecimal characters.
Sidstringrequired
The 34-character SID of the Call resource to update, matching the `CA` prefix and 32 hexadecimal characters.

Optional call update instructions for redirecting, monitoring, or terminating the call.

Urlstringoptional
The 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).
Methodstringoptional
The HTTP method we should use when calling the `url`. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored.
Allowed:GETPOST
Statusstringoptional
Terminate the call by setting this value to `canceled` or `completed`.
Allowed:canceledcompleted
FallbackUrlstringoptional
The 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.
FallbackMethodstringoptional
The 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.
Allowed:GETPOST
StatusCallbackstringoptional
The 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).
StatusCallbackMethodstringoptional
The HTTP method we should use when requesting 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.
Allowed:GETPOST
Twimlstringoptional
TwiML instructions for the call Twilio will use without fetching Twiml from url. Twiml and url parameters are mutually exclusive
TimeLimitintegeroptional
The maximum duration of the call in seconds. Constraints depend on account and configuration.

1 status code
200Returns the updated call resource, including its current status, routing configuration, timestamps, duration, and price when available.
sidstringoptional
The unique string that we created to identify this Call resource.
date_createdstringoptional
The date and time in UTC that this resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
date_updatedstringoptional
The date and time in UTC that this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
parent_call_sidstringoptional
The SID that identifies the call that created this leg.
account_sidstringoptional
The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this Call resource.
tostringoptional
The 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@company.com`. Client identifiers are formatted `client:name`. SIM SIDs are formatted as `sim:sid`.
to_formattedstringoptional
The 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).
fromstringoptional
The 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@company.com`. Client identifiers are formatted `client:name`. SIM SIDs are formatted as `sim:sid`.
from_formattedstringoptional
The 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).
phone_number_sidstringoptional
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.
statusstringoptional
The 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.
Allowed:queuedringingin-progresscompletedbusyfailedno-answercanceled
start_timestringoptional
The 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.
end_timestringoptional
The 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.
durationstringoptional
The length of the call in seconds. This value is empty for busy, failed, unanswered, or ongoing calls.
pricestringoptional
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_unitstringoptional
The 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.
directionstringoptional
A 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.
answered_bystringoptional
Either `human` or `machine` if this call was initiated with answering machine detection. Empty otherwise.
api_versionstringoptional
The API version used to create the call.
forwarded_fromstringoptional
The forwarding phone number if this call was an incoming call forwarded from another number (depends on carrier supporting forwarding). Otherwise, empty.
group_sidstringoptional
The Group SID associated with this call. If no Group is associated with the call, the field is empty.
caller_namestringoptional
The caller's name if this call was an incoming call to a phone number with caller ID Lookup enabled. Otherwise, empty.
queue_timestringoptional
The wait time in milliseconds before the call is placed.
trunk_sidstringoptional
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.
uristringoptional
The URI of this resource, relative to `https://api.twilio.com`.
subresource_urisobjectoptional
A list of subresources available to this call, identified by their URIs relative to `https://api.twilio.com`.

Error handling

AccountSid and Sid must be valid Account and Call SIDs matching their documented prefixes and 34-character formats. Method, FallbackMethod, and StatusCallbackMethod must use an allowed value, and Status must be canceled or completed when terminating the call; Twiml and Url are mutually exclusive.