Recordings

For more information, see the Recordings REST Resource documentation.

Audio Formats

Each Recording has a few special methods. To get the url for the wav format of this recording, use Recording.wav(). For the mp3 format, use Recording.mp3(). To make requests for either of these formats use the same method with a ‘!’ appended. These methods both take a block to be executed as soon as the response returns.

Listing Your Recordings

The following code will print out the duration for each Recording.

require 'twilio-ruby'

# To find these visit https://www.twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"

@client = Twilio::REST::Client.new account_sid, auth_token

@client.recordings.list().each do |recording|
  puts recording.duration
end

You can filter recordings by CallSid by passing the Sid as call. Filter recordings using DateCreated< and DateCreated> dates.

The following will only show recordings made before January 1, 2011.

require 'twilio-ruby'

# To find these visit https://www.twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"

@client = Twilio::REST::Client.new account_sid, auth_token
@client.recordings.list('DateCreated<' => '2011-01-01').each do |recording|
  puts recording.duration
end

Deleting Recordings

The Recordings resource allows you to delete unnecessary recordings.

require 'twilio-ruby'

# To find these visit https://www.twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"

@client = Twilio::REST::Client.new account_sid, auth_token
@client.recordings.get("RC123").delete()