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">
<Number>+15558675310</Number>
</Dial>
</Response>

In this example, we have included the recordingStatusCallback attribute. This tells Twilio to make an HTTP request to your included webhook url with all of the recording file's details once it is posted and available for access. 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" \
-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. 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, see our documentation on placing an outgoing call with the REST API.

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. Login to your account at www.twilio.com/console.
  2. Click Elastic SIP Trunking.
  3. Click Trunks, and then select the desired trunk to configure.
  4. From the "General" tab, select the desired Call Recording option, and then click Save.
    • Do not Record
    • Record from Ringing
    • Record from Answer

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">
myConference
</Conference>
</Dial>
</Response>

In this example, we have included the recordingStatusCallback attribute. This tells Twilio to make an HTTP request to your included webhook url with all of the recording file's details once it is posted and available for access. 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.

Notice: The record-from-start parameter for <Conference> mixes all conference participants into a single audio file. We do not support separate recording tracks for each participant via the <Conference> noun at this time. Users require tracks for each participant can instead use the record-from-answer parameter on the <Dial> verb.

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">
/>
<Say>I did not receive a recording</Say>
</Response>

In this example, we have included the recordingStatusCallback attribute. This tells Twilio to make an HTTP request to your included webhook url with all of the recording file's details once it is posted and available for access.

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 your recordings

You can view all your recordings in the Recordings Log section of the Console. You can also fetch recordings from your project via a GET request to the “Recordings” resource.

Related Topics

Have more questions? Submit a request
Powered by Zendesk