Recordings

For more information, see the Recordings REST Resource documentation.

Listing Your Recordings

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

String ACCOUNT_SID = 'AXXXXXXXXXXXXXXXXX';
String AUTH_TOKEN = 'YYYYYYYYYYYYYYYYYY';
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

for (TwilioRecording rec : client.getAccount().getRecordings().getPageData()) {
    System.debug(rec.getDuration());
}

You can filter recordings by the Call by passing the sid as CallSid, or you can filter by DateCreated.

The following will only show recordings made on January 1, 2012.

String ACCOUNT_SID = 'AXXXXXXXXXXXXXXXXX';
String AUTH_TOKEN = 'YYYYYYYYYYYYYYYYYY';
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

Map<String,String> filters = new Map<String,String> {
            'DateCreated' => TwilioParser.formatFilterDatetime(2012,1,1)
    };
for (TwilioRecording rec : client.getAccount().getRecordings(filters).getPageData()) {
    System.debug(rec.getDuration());
}

Deleting Recordings

The TwilioRecordingList resource allows you to delete unnecessary recordings.

String ACCOUNT_SID = 'AXXXXXXXXXXXXXXXXX';
String AUTH_TOKEN = 'YYYYYYYYYYYYYYYYYY';
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

client.getAccount().getRecordings().deleteResource("RC123");

Audio Formats

Each TwilioRecording can return the the URI to the recorded audio in WAV or MP3 format.

String ACCOUNT_SID = 'AXXXXXXXXXXXXXXXXX';
String AUTH_TOKEN = 'YYYYYYYYYYYYYYYYYY';
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

TwilioRecording rec = client.getRecording("RC123");
System.debug(rec.getWavUri());
System.debug(rec.getMp3Uri());