SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Recording a Phone Call with Twilio

There are multiple ways to record phone calls made and received on your Twilio project:

Record a Two-way Call using the <Dial> TwiML Verb

Use this method if you want to record both sides of a two-way Twilio voice call. To record these calls, use the <Dial> TwiML verb's record attribute:

  • Use the record-from-answer or record-from-ringing record values for mono recordings.
  • Use record-from-answer-dual or record-from-ringing-dual record values for dual-channel recordings, with the parent and child calls in different stereo tracks.

Here's an example of what this might look like in your TwiML response:

<Response>
<Dial record="record-from-ringing-dual"
recordingStatusCallback="https://myapp.com/recording-events"
recordingStatusCallbackEvent="in-progress completed absent">
<Number>+15558675310</Number>
</Dial>
</Response>

In this example, we have included the recordingStatusCallback and recordingStatusCallbackEvent attributes. These tell Twilio to make an HTTP request to your included callback webhook url with all of the recording file's details when recording begins, and then again when it is posted and available for access or if no recording is created. For more information, see our documentation on the <Dial> verb in TwiML.

Record an Outbound Call using Record=”true” in a REST API Request

Use this method if you want to record an outbound call initiated via an API request. To record these calls, add the Record parameter to your request:

  • Use Record=true for mono recordings.
  • Use Record=true and add RecordingChannels=dual for dual-channel recordings, with the parent and child calls in different stereo tracks.

Here’s an example cURL script:

curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls.json \
--data-urlencode "To=+13105555555" \
--data-urlencode "From=+12125551234" \
--data-urlencode "Url=https://demo.twilio.com/welcome/voice/"
--data-urlencode "Record=True" \
--data-urlencode "RecordingChannels=dual" \
--data-urlencode "RecordingStatusCallback=https://myapp.com/recording-events" \
--data-urlencode "RecordingStatusCallbackEvent=in-progress completed absent" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token

This example place an outbound call from the sender (212) 555-1234 (+12125551234) to the phone number (310) 555-5555 (+13105555555), and then execute the TwiML script at https://demo.twilio.com/welcome/voice/. The call will be recorded in a dual-channel file, and Twilio will make an HTTP request to your included RecordingStatusCallback URL with all of the recording file's details once recording begins, and then again when it is posted and available for access or if no recording is created. To make this script work for you, make the following updates, and then paste it into a terminal window:

  • Line 1 update with your Account SID
  • Line 2 update with a valid destination
  • Line 3 update with a valid caller number
  • Line 4 update with a valid TwiML URL or App SID url
  • Line 7 update with a valid application site for Recording status callbacks (optional)
  • Line 9 update with your Account SID and Auth Token

For more information, including code samples using our Helper Library SDKs, see Make Outbound Phone Calls (Twilio Docs).

Record an Inbound Call via the Recording Controls API

Inbound call recording can now be initiated via a request to the Recording Controls API. For more details, please see our article Recording Incoming Twilio Voice Calls.

Record calls on your Elastic SIP trunk

Your Elastic SIP trunk can be configured to record all inbound and outbound calls that go over the trunk. Here are the steps to configure recording on your Trunk:

  1. Access the Elastic SIP Trunks page in Console.
  2. Click the desired trunk to configure.
  3. From the "General Settings" page, select the desired Call Recording option, and then click Save.
    sipRecord_01_500px.png
    • Disabled: Recording is disabled on this trunk.
    • Enabled - Record from ringing: Recording begins when the ringing starts.
    • Enabled - Record from answer: Recording begins when a call is answered.
    • Enabled - Dual Record from ringing: Recording begins when the ringing starts, and both tracks are be visualized separately.
    • Enabled - Dual Record from answer: Recording begins when the call is answered, and both tracks are be visualized separately.

Record a Conference

Use this method if you want to record the entirety of your conference call. This type of recording will start only when a conference is bridged, and when participants are able to talk to each other. To record these calls, use the <Conference> TwiML noun's record attribute, and the record-from-start value.

Here's an example of what this might look like in your TwiML response:

<Response>
<Dial>
<Conference record="record-from-start"
recordingStatusCallback="https://myapp.com/recording-events"
recordingStatusCallbackEvent="in-progress completed absent">
myConference
</Conference>
</Dial>
</Response>

In this example, we have included the recordingStatusCallback and recordingStatusCallbackEvent attributes. These tell Twilio to make an HTTP request to your included callback webhook url with all of the recording file's details when recording begins, and then again when it is posted and available for access or if no recording is created. For more information, see our documentation on the <Conference> noun in TwiML.

If you’d like to start your recording as soon as the <Dial> starts, we recommend using the <Dial> or Outbound API recording options outlined above instead. Note that it is possible to specify record on <Dial> as well as on <Conference>, which would incur two recording charges, and return two separate recordings.

Recordings are stored at Twilio in dual-channel. The dual-channel media file associated with the recording resource of a conference contains the audio of the first Participant that joined the Conference in the first channel, and all other audio from the call mixed in the second channel. For more information, please see Fetch a Recording media file (Twilio Docs).

Record a One-way Call using the <Record> TwiML Verb

You can record a one-way (one party) call by using the <Record> verb in your TwiML file. This command is used to record one person talking, like in the case of a voicemail inbox, or for a phone poll or automated survey.

Here's an example of what this might look like in your TwiML response:

<Response>
<Say>Please leave a voicemail message</Say>
<Record
action="https://myapp.com/recording-confirm.php"
maxLength="30"
finishOnKey="*"
recordingStatusCallback="https://myapp.com/recording-events"
recordingStatusCallbackEvent="in-progress completed absent"/>
<Say>I did not receive a recording</Say>
</Response>

In this example, we have included the recordingStatusCallback and recordingStatusCallbackEvent attributes. These tell Twilio to make an HTTP request to your included callback webhook url with all of the recording file's details when recording begins, and then again when it is posted and available for access or if no recording is created.

Notice: Make sure to specify an action url on the <Record>. Failure to do so will result in looping. The action url can return an empty response, or a <Say> or <Play> command like a message advising the caller that their recording has been captured. For more information, see our documentation on the <Record> verb.

Pause, Resume, and Stop an in-progress recording

In-progress recordings can now be paused, resumed, and ended via a request to the Recording Controls API. For more details, please see our article Getting Started with Call Recording Controls.

How to view, download, and delete your recordings

Call recordings are accessible via the Recordings Log section of the Console, and the REST API. You can see a list of your recordings, download them, and delete them from either of these resources. Recording files are kept in Twilio’s cloud storage until you delete them.

For more information, please see our article Downloading and Deleting Twilio Call Recordings.

Legal implications of call recording

If you choose to record calls, you need to comply with certain laws and regulations, including those regarding obtaining consent to record (such as California’s Invasion of Privacy Act and similar laws in other jurisdictions). Additional information on the legal implications of call recording can be found here.

Notice: Twilio recommends that you consult with your legal counsel to make sure that you are complying with all applicable laws in connection with communications you record or store using Twilio.

Related Topics

Have more questions? Submit a request
Powered by Zendesk