Skip to contentSkip to navigationSkip to topbar
On this page

Programmable Video Rest API: Recordings



Overview

overview page anchor

Twilio Video's Rooms and Recording APIs allow you to record the audio and video shared in a Programmable Video Room. To turn on Recording in a Room, set the RecordParticipantsOnConnect property to true when creating the Room. Check the Rooms REST API documentation for additional information.

All Recording resources are located beneath the following Base URL.

1
https://video.twilio.com
2
(warning)

If you choose to record voice or video 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 in the "Legal Considerations with Recording Voice and Video Communications" Help Center article(link takes you to an external page).

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.



Recording instance resource

recording-instance-resource page anchor

Recordings captured by Programmable Video products are single-track, single-media and stored in a single file format.

Recordings are represented through a REST API with the following URI scheme:

/v1/Recordings/{RecordingSid}

Resource properties

resource-properties page anchor

A Recording has the following properties:

Property nameTypeRequiredDescriptionChild properties
account_sidSID<AC>Optional
Not PII

The SID of the Account that created the Recording resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

statusenum<string>Optional

The status of the recording. Can be: processing, completed, or deleted. processing indicates the recording is still being captured; completed indicates the recording has been captured and is now available for download. deleted means the recording media has been deleted from the system, but its metadata is still available.

Possible values:
processingcompleteddeletedfailed

date_createdstring<date-time>Optional

The date and time in GMT when the resource was created specified in ISO 8601(link takes you to an external page) format.


sidSID<RT>Optional

The unique string that we created to identify the Recording resource.

Pattern: ^RT[0-9a-fA-F]{32}$Min length: 34Max length: 34

source_sidSIDOptional

The SID of the recording source. For a Room Recording, this value is a track_sid.

Pattern: ^[a-zA-Z]{2}[0-9a-fA-F]{32}$Min length: 34Max length: 34

sizeinteger<int64>Optional

The size of the recorded track, in bytes.


urlstring<uri>Optional

The absolute URL of the resource.


typeenum<string>Optional

The recording's media type. Can be: audio or video.

Possible values:
audiovideodata

durationintegerOptional

The duration of the recording in seconds rounded to the nearest second. Sub-second tracks have a Duration property of 1 second


container_formatenum<string>Optional

The file format for the recording. Can be: mka or mkv. Video Room recordings are captured in Matroska container format(link takes you to an external page), mka is for audio files and mkv for video files.

Possible values:
mkamkv

codecenum<string>Optional

The codec used to encode the track. Can be: VP8, H264, OPUS, and PCMU.

Possible values:
VP8H264OPUSPCMU

grouping_sidsobjectOptional

A list of SIDs related to the recording. Includes the room_sid and participant_sid.


track_namestringOptional
PII MTL: 30 days

The name that was given to the source track of the recording. If no name is given, the source_sid is used.


offsetinteger<int64>Optional

The time in milliseconds elapsed between an arbitrary point in time, common to all group rooms, and the moment when the source room of this track started. This information provides a synchronization mechanism for recordings belonging to the same room.


media_external_locationstring<uri>Optional

The URL of the media file associated with the recording when stored externally. See External S3 Recordings for more details.


status_callbackstring<uri>Optional

The URL called using the status_callback_method to send status information on every recording event.


status_callback_methodenum<http-method>Optional

The HTTP method used to call status_callback. Can be: POST or GET, defaults to POST.

Possible values:
GETPOST

linksobject<uri-map>Optional

The URLs of related resources.

Note: The duration of media tracks is rounded to the nearest second. Thus, sub-second duration tracks have a Duration property of 1 second.

Returns a single Recording Instance resource identified by a RecordingSid.

Example: Retrieve a Recording

get-by-sid page anchor
Retrieve a RecordingLink to code sample: Retrieve a Recording
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchRecording() {
11
const recording = await client.video.v1
12
.recordings("RTXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.fetch();
14
15
console.log(recording.accountSid);
16
}
17
18
fetchRecording();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"status": "processing",
4
"date_created": "2015-07-30T20:00:00Z",
5
"date_updated": "2015-07-30T21:00:00Z",
6
"date_deleted": "2015-07-30T22:00:00Z",
7
"sid": "RTXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
8
"source_sid": "MTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
9
"size": 0,
10
"url": "https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
11
"type": "audio",
12
"duration": 0,
13
"container_format": "mka",
14
"codec": "OPUS",
15
"track_name": "A name",
16
"offset": 10,
17
"status_callback": "https://mycallbackurl.com",
18
"status_callback_method": "POST",
19
"grouping_sids": {
20
"room_sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
21
},
22
"media_external_location": "https://my-super-duper-bucket.s3.amazonaws.com/my/path/",
23
"encryption_key": "public_key",
24
"links": {
25
"media": "https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media"
26
}
27
}

HTTP GET to the /Media subresource

get-media-subresource page anchor

Retrieves the media file associated to a given Recording Instance resource identified by a RecordingSid.

When you make a request to this URL, Twilio will generate a temporary URL for accessing this binary data, and issue an HTTP 302 redirect response to your request. The Recording will be returned in the format as described in the metadata, with the Content-Type header set according to the codec used to record the media.

CodecContent-Type value
PCMUaudio/x-matroska
H264video/x-matroska

The URL returned will be available by default for 600 seconds, but this can be configured to a value between 1 and 3600 seconds via the Ttl request param. If the recording is not yet available, a 404 is returned. If the recording is not available (for example, if its status is processing or deleted, or if the track was muted for the duration of the recording), an HTTP 404 response is returned.

The HTTP GET request accepts the following parameters

NameDescription
ContentDispositionOptional. Sets the Content-Disposition header of the redirect_to URL. Possible values are attachment or inline. Default value attachment%3B%20filename%3D%22RTxxx.mk{a|v} (not PII)
TtlOptional. Duration in seconds for which the redirect_to URL can be used to retrieve the media file. The default Ttl is 600 seconds. The minimum supported Ttl value is 1 second and the maximum supported value is 3600 seconds. (not PII)

The Content-Disposition(link takes you to an external page) header can be set in this request. By default, the value of this header is attachment%3B%20filename%3D%22RTxxx.mk{a|v}.

NOTE: You can play these recordings in media players that support the Matroska file format(link takes you to an external page), like the VLC(link takes you to an external page) player. You can also use other programs like Chrome, ffplay or ffplayer to play these recordings. However, these files are optimized for compactness and they are not player-friendly. Hence, you may experience different types of problems when playing these files. For generating player-friendly media files, compose your Recordings using Twilio's Recordings Composition API.

Example: Retrieve a Recording's Media

get-media-by-sid page anchor
1
// NOTE: This example uses the next generation Twilio helper library - for more
2
// information on how to download and install this version, visit
3
// https://www.twilio.com/docs/libraries/node
4
const Twilio = require("twilio");
5
6
// To set up environmental variables, see http://twil.io/secure
7
const apiKeySid = process.env.TWILIO_API_KEY;
8
const apiKeySecret = process.env.TWILIO_API_KEY_SECRET;
9
const accountSid = process.env.TWILIO_ACCOUNT_SID;
10
const client = new Twilio(apiKeySid, apiKeySecret, { accountSid: accountSid });
11
12
const recordingSid = "RTXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
13
const uri = `https://video.twilio.com/v1/Recordings/${recordingSid}/Media`;
14
client.request({ method: "GET", uri: uri }).then(response => {
15
const mediaLocation = response.data.redirect_to;
16
request.get(mediaLocation, (err, res, media) => {
17
console.log(media);
18
});
19
});

Output

1
{
2
"redirect_to": "https://com-twilio-us1-video-recording.s3.amazonaws.com/RTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
3
}

Not supported.

Deletes the recording media file.

The metadata for the Recording is preserved for a period of 30 days, and its Status is set to deleted. After this period, the metadata will not be available. By default, Recordings with deleted status are not returned when retrieving the Recordings list. To retrieve deleted Recordings, use the Status=deleted filter.

Note that the 30-day period starts after the Status is set to deleted. After this period expires, the metadata will not be available.

Example: Delete a Recording

delete-recording page anchor
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function deleteRecording() {
11
await client.video.v1
12
.recordings("RTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.remove();
14
}
15
16
deleteRecording();
(information)

Info

To delete a large set of Video Recordings, you can use the bulk deletion capabilities available in the Twilio Console(link takes you to an external page).


Recordings List Resource

recordings-list-resource page anchor

Recordings list is available at the following URI:

1
/v1/Recordings
2

Returns a list of all Track Recordings with paging data.

HTTP GET: List filters

get-list-filters page anchor

The following GET query string parameters allow you to limit the list returned. Note, parameters are case-sensitive.

Property nameTypeRequiredPIIDescription
Statusenum<string>Optional

Read only the recordings that have this status. Can be: processing, completed, or deleted.

Possible values:
processingcompleteddeletedfailed

SourceSidSIDOptional

Read only the recordings that have this source_sid.

Pattern: ^[a-zA-Z]{2}[0-9a-fA-F]{32}$Min length: 34Max length: 34

GroupingSidarray[SID]Optional

Read only recordings with this grouping_sid, which may include a participant_sid and/or a room_sid.


DateCreatedAfterstring<date-time>Optional

Read only recordings that started on or after this ISO 8601(link takes you to an external page) date-time with time zone.


DateCreatedBeforestring<date-time>Optional

Read only recordings that started before this ISO 8601(link takes you to an external page) date-time with time zone, given as YYYY-MM-DDThh:mm:ss+|-hh:mm or YYYY-MM-DDThh:mm:ssZ.


MediaTypeenum<string>Optional

Read only recordings that have this media type. Can be either audio or video.

Possible values:
audiovideodata

PageSizeintegerOptional

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum: 1Maximum: 1000

PageintegerOptional

The page index. This value is simply for client state.

Minimum: 0

PageTokenstringOptional

The page token. This is provided by the API.

Example: Get all Recordings from a given Room

filter-by-room-sid page anchor
(information)

Info

This endpoint does not retrieve deleted recordings by default. To retrieve deleted recordings, use the status filter in your request.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listRecording() {
11
const recordings = await client.video.v1.recordings.list({
12
groupingSid: ["RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"],
13
limit: 20,
14
});
15
16
recordings.forEach((r) => console.log(r.accountSid));
17
}
18
19
listRecording();

Output

1
{
2
"recordings": [],
3
"meta": {
4
"page": 0,
5
"page_size": 50,
6
"first_page_url": "https://video.twilio.com/v1/Recordings?Status=completed&SourceSid=source_sid&MediaType=audio&GroupingSid=RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0",
7
"previous_page_url": null,
8
"url": "https://video.twilio.com/v1/Recordings?Status=completed&SourceSid=source_sid&MediaType=audio&GroupingSid=RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0",
9
"next_page_url": null,
10
"key": "recordings"
11
}
12
}

Example: Get all Recordings for a given Participant

filter-by-participant-sid page anchor
(information)

Info

This endpoint does not retrieve deleted recordings by default. To retrieve deleted recordings, use the status filter in your request.

Get all Recordings for a given ParticipantLink to code sample: Get all Recordings for a given Participant
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listRecording() {
11
const recordings = await client.video.v1.recordings.list({
12
groupingSid: ["PARTICIPANT_SID"],
13
limit: 20,
14
});
15
16
recordings.forEach((r) => console.log(r.accountSid));
17
}
18
19
listRecording();

Output

1
{
2
"recordings": [],
3
"meta": {
4
"page": 0,
5
"page_size": 50,
6
"first_page_url": "https://video.twilio.com/v1/Recordings?Status=completed&SourceSid=source_sid&MediaType=audio&GroupingSid=RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0",
7
"previous_page_url": null,
8
"url": "https://video.twilio.com/v1/Recordings?Status=completed&SourceSid=source_sid&MediaType=audio&GroupingSid=RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0",
9
"next_page_url": null,
10
"key": "recordings"
11
}
12
}

Example: Get the list of deleted Recordings

filter-by-status page anchor
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listRecording() {
11
const recordings = await client.video.v1.recordings.list({
12
status: "deleted",
13
limit: 20,
14
});
15
16
recordings.forEach((r) => console.log(r.accountSid));
17
}
18
19
listRecording();

Output

1
{
2
"recordings": [],
3
"meta": {
4
"page": 0,
5
"page_size": 50,
6
"first_page_url": "https://video.twilio.com/v1/Recordings?Status=completed&SourceSid=source_sid&MediaType=audio&GroupingSid=RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0",
7
"previous_page_url": null,
8
"url": "https://video.twilio.com/v1/Recordings?Status=completed&SourceSid=source_sid&MediaType=audio&GroupingSid=RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0",
9
"next_page_url": null,
10
"key": "recordings"
11
}
12
}

Not supported.

Not supported.


Using the Rooms API to find Recordings

rooms-recordings page anchor

You can also retrieve the list of recordings for a specific room using the Rooms API endpoint.

Example: Get all recordings from a given Room using the Rooms API

rooms-filter-by-room-sid page anchor
(information)

Info

This endpoint does not retrieve deleted recordings by default. To retrieve deleted recordings, use the status filter in your request.

Get all Recordings from a given Room using the Rooms APILink to code sample: Get all Recordings from a given Room using the Rooms API
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listRoomRecording() {
11
const recordings = await client.video.v1
12
.rooms("RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.recordings.list({ limit: 20 });
14
15
recordings.forEach((r) => console.log(r.accountSid));
16
}
17
18
listRoomRecording();

Output

1
{
2
"recordings": [],
3
"meta": {
4
"page": 0,
5
"page_size": 50,
6
"first_page_url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings?PageSize=50&Page=0",
7
"previous_page_url": null,
8
"url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings?PageSize=50&Page=0",
9
"next_page_url": null,
10
"key": "recordings"
11
}
12
}

Example: Retrieve a Recording using the Rooms API

rooms-get-instance page anchor
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchRoomRecording() {
11
const recording = await client.video.v1
12
.rooms("RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.recordings("RTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
14
.fetch();
15
16
console.log(recording.accountSid);
17
}
18
19
fetchRoomRecording();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"status": "processing",
4
"date_created": "2015-07-30T20:00:00Z",
5
"date_updated": "2015-07-30T21:00:00Z",
6
"date_deleted": "2015-07-30T22:00:00Z",
7
"sid": "RTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
8
"source_sid": "MTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
9
"size": 0,
10
"type": "audio",
11
"duration": 0,
12
"container_format": "mka",
13
"codec": "OPUS",
14
"track_name": "A name",
15
"offset": 10,
16
"grouping_sids": {
17
"room_sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
18
},
19
"media_external_location": "https://my-super-duper-bucket.s3.amazonaws.com/my/path/",
20
"encryption_key": "public_key",
21
"room_sid": "RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
22
"url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
23
"links": {
24
"media": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media"
25
}
26
}

Example: Retrieve a Recording's Media using the Rooms API

rooms-get-media-subresource page anchor
Retrieve the actual recording Media using the Rooms APILink to code sample: Retrieve the actual recording Media using the Rooms API
1
// NOTE: This example uses the next generation Twilio helper library - for more
2
// information on how to download and install this version, visit
3
// https://www.twilio.com/docs/libraries/node
4
const Twilio = require("twilio");
5
6
// To set up environmental variables, see http://twil.io/secure
7
const apiKeySid = process.env.TWILIO_API_KEY;
8
const apiKeySecret = process.env.TWILIO_API_KEY_SECRET;
9
const accountSid = process.env.TWILIO_ACCOUNT_SID;
10
const client = new Twilio(apiKeySid, apiKeySecret, { accountSid: accountSid });
11
12
const roomSid = "RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
13
const recordingSid = "RTXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
14
const uri =
15
"https://video.twilio.com/v1/" +
16
`Rooms/${roomSid}/` +
17
`Recordings/${recordingSid}` +
18
"/Media";
19
client.request({ method: "GET", uri: uri }).then((response) => {
20
const mediaLocation = response.data.redirect_to;
21
request.get(mediaLocation, (err, res, media) => {
22
console.log(media);
23
});
24
});

Output

1
{
2
"redirect_to": "https://com.twilio.us1.video.recording.s3.amazonaws.com/RTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
3
}

Size estimation of a track Recording

recording-size-estimation page anchor

The size of a video Recording (.mkv) will vary based on resolution, bit rate and duration. The following table shows files size for a single participant with video captured at common resolutions and bitrates:

Capture Size1 Hr8 Hrs24 Hrs
720 @ 1,500 kbps0.7 GB5.4 GB16.2 GB
480 @ 700 kbps0.3 GB2.5 GB7.6 GB
180 @ 200 kbps0.1 GB0.7 GB2.2 GB
(warning)

Warning

The above table is for heuristic estimation and reference only. There are a lot of other factors influence the actual video file size such as compression ratio, variable bitrate, color depth.

The size of an audio Recording (.mka) will vary based on bit rate and duration. The following table shows files size for a single participant with audio captured at common bit rates:

Capture Size1 Hr8 Hrs24 Hrs
16 kbps7.2 MB57.6 MB172.8 MB
32 kbps14.4 MB115.2 MB345.6 MB
40 kbps18 MB144 MB432 MB
(warning)

Warning

Note that the file size reported by our REST API may vary slightly from that shown due to file allocation methods and/or possible differences in the amount of header information.


Known limitations

known-issues page anchor
  • Recording files are generated with a format optimized for reliability and compactness. This format is not player friendly. Hence, many media players may not render Recordings media files appropriately. For generating player-friendly media files, compose your Recordings using Twilio's Recordings Composition API.
  • Participants on the browser Firefox Mobile could find Recording gaps due to a Firefox bug when sending temporization. Twilio recommends Video participants to use other mobile browsers.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.