Skip to contentSkip to navigationSkip to topbar
On this page

Composition Hooks



Overview

overview page anchor

The Twilio Composition Hooks REST API lets you automate the creation of Compositions. A Composition Hook is a template that specifies how Room recordings should be composed. Using this API you will be able to:

  • Create and manage Composition Hooks.
  • Monitor the Compositions created by Hooks.

Composition Hooks work per-account (i.e. project). Hence, when a Room is completed, all enabled Composition Hooks in the account will be executed against that room recordings.

This API is located beneath the following base URL:

1
https://video.twilio.com
2


These are the URI schemes for the Composition Hooks REST API and the supported methods:

  • /v1/CompositionHooks
    • GET: Lists Composition Hook resources.
    • POST: Creates new Composition Hook resources.
  • /v1/CompositionHooks/{CompositionHookSid}
    • GET: Retrieves a Composition Hook instance.
    • POST: Updates a Composition Hook instance.
    • DELETE: Deletes a Composition Hook instance.

Composition Hook instance resource

composition-hook-instance-resource page anchor

The Composition Hook instance resource represents a template that specifies how Room recordings should be composed.

Resource URI

hk-uri page anchor
1
/v1/CompositionHooks/{CompositionHookSid}
2

Resource Properties

hk-properties page anchor

A Composition Hook Instance Resource has the following properties:

Property nameTypeRequiredDescriptionChild properties
account_sidSID<AC>Optional
Not PII

The SID of the Account that created the CompositionHook resource.

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

friendly_namestringOptional

The string that you assigned to describe the resource. Can be up to 100 characters long and must be unique within the account.


enabledbooleanOptional

Whether the CompositionHook is active. When true, the CompositionHook is triggered for every completed Group Room on the account. When false, the CompositionHook is never triggered.


date_updatedstring<date-time>Optional

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


sidSID<HK>Optional

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

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

audio_sourcesarray[string]Optional
PII MTL: 30 days

The array of track names to include in the compositions created by the composition hook. A composition triggered by the composition hook includes all audio sources specified in audio_sources except those specified in audio_sources_excluded. The track names in this property can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, student* includes tracks named student as well as studentTeam. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request


audio_sources_excludedarray[string]Optional

The array of track names to exclude from the compositions created by the composition hook. A composition triggered by the composition hook includes all audio sources specified in audio_sources except for those specified in audio_sources_excluded. The track names in this property can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, student* excludes student as well as studentTeam. This parameter can also be empty.


video_layoutobjectOptional

A JSON object that describes the video layout of the composition in terms of regions as specified in the HTTP POST request that created the CompositionHook resource. See POST Parameters for more information. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request


resolutionstringOptional

The dimensions of the video image in pixels expressed as columns (width) and rows (height). The string's format is {width}x{height}, such as 640x480.


trimbooleanOptional

Whether intervals with no media are clipped, as specified in the POST request that created the CompositionHook resource. Compositions with trim enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See Specifying Video Layouts for more info.


formatenum<string>Optional

The container format of the media files used by the compositions created by the composition hook. If mp4 or webm, audio_sources must have one or more tracks and/or a video_layout element must contain a valid video_sources list, otherwise an error occurs.

Possible values:
mp4webm

status_callbackstring<uri>Optional

The URL we call using the status_callback_method to send status information to your application.


status_callback_methodenum<http-method>Optional

The HTTP method we should use to call status_callback. Can be POST or GET and defaults to POST.

Possible values:
GETPOST

urlstring<uri>Optional

The absolute URL of the resource.

Returns the single Composition Hook instance identified by {CompositionHookSid}.

Updates the Composition Hook instance identified by {CompositionHookSid}. Be aware that partial updates are not supported. This means that when updating you must specify all the POST parameters, even for properties that don't change. Any optional parameter that is not explicitly specified will be reset (i.e. set to its default value)

The following parameters are supported:

Property nameTypeRequiredPIIDescription
SidSID<HK>required

The SID of the CompositionHook resource to update.

Pattern: ^HK[0-9a-fA-F]{32}$Min length: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestringrequired

A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account.


EnabledbooleanOptional

Whether the composition hook is active. When true, the composition hook will be triggered for every completed Group Room in the account. When false, the composition hook never triggers.


VideoLayoutobjectOptional

A JSON object that describes the video layout of the composition hook in terms of regions. See Specifying Video Layouts for more info.


AudioSourcesarray[string]Optional

An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in audio_sources except those specified in audio_sources_excluded. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, student* includes tracks named student as well as studentTeam.


AudioSourcesExcludedarray[string]Optional

An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in audio_sources except for those specified in audio_sources_excluded. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, student* excludes student as well as studentTeam. This parameter can also be empty.


TrimbooleanOptional

Whether to clip the intervals where there is no active media in the compositions triggered by the composition hook. The default is true. Compositions with trim enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See Specifying Video Layouts for more info.


Formatenum<string>Optional

The container format of the media files used by the compositions created by the composition hook. Can be: mp4 or webm and the default is webm. If mp4 or webm, audio_sources must have one or more tracks and/or a video_layout element must contain a valid video_sources list, otherwise an error occurs.

Possible values:
mp4webm

ResolutionstringOptional

A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to 640x480. The string's format is {width}x{height} where:

  • 16 <= {width} <= 1280
  • 16 <= {height} <= 1280
  • {width} * {height} <= 921,600

Typical values are:

  • HD = 1280x720
  • PAL = 1024x576
  • VGA = 640x480
  • CIF = 320x240

Note that the resolution imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See Specifying Video Layouts for more info.


StatusCallbackstring<uri>Optional

The URL we should call using the status_callback_method to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.


StatusCallbackMethodenum<http-method>Optional

The HTTP method we should use to call status_callback. Can be: POST or GET and the default is POST.

Possible values:
GETPOST

The return value is a 200 OK if the request is accepted and executed successfully. Otherwise, a 4xx is returned with detailed information about the problem.

Deletes the Composition Hook instance identified by {CompositionHookSid}.

The return value is a 204 NO CONTENT if the request is accepted and executed successfully. In this case, deletion is immediate.

Otherwise, a 4xx is returned with detailed information about the problem.


Composition Hooks list resource

compositions-hooks-list-resource page anchor
1
/v1/CompositionHooks
2

Creates a new Composition Hook and registers it so that Twilio can fire it whenever a Room is completed.

The return value is a 201 CREATED if the request is accepted and executed successfully. Otherwise, a 4xx is returned with detailed information about the problem.

Supported POST parameters

http-post-parameters page anchor

The following table shows all the parameters that can be specified when creating a new Composition Hook.

Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestringrequired

A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account.


EnabledbooleanOptional

Whether the composition hook is active. When true, the composition hook will be triggered for every completed Group Room in the account. When false, the composition hook will never be triggered.


VideoLayoutobjectOptional

An object that describes the video layout of the composition hook in terms of regions. See Specifying Video Layouts for more info.


AudioSourcesarray[string]Optional

An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in audio_sources except those specified in audio_sources_excluded. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, student* includes tracks named student as well as studentTeam.


AudioSourcesExcludedarray[string]Optional

An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in audio_sources except for those specified in audio_sources_excluded. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, student* excludes student as well as studentTeam. This parameter can also be empty.


ResolutionstringOptional

A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to 640x480. The string's format is {width}x{height} where:

  • 16 <= {width} <= 1280
  • 16 <= {height} <= 1280
  • {width} * {height} <= 921,600

Typical values are:

  • HD = 1280x720
  • PAL = 1024x576
  • VGA = 640x480
  • CIF = 320x240

Note that the resolution imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See Specifying Video Layouts for more info.


Formatenum<string>Optional

The container format of the media files used by the compositions created by the composition hook. Can be: mp4 or webm and the default is webm. If mp4 or webm, audio_sources must have one or more tracks and/or a video_layout element must contain a valid video_sources list, otherwise an error occurs.

Possible values:
mp4webm

StatusCallbackstring<uri>Optional

The URL we should call using the status_callback_method to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.


StatusCallbackMethodenum<http-method>Optional

The HTTP method we should use to call status_callback. Can be: POST or GET and the default is POST.

Possible values:
GETPOST

TrimbooleanOptional

Whether to clip the intervals where there is no active media in the Compositions triggered by the composition hook. The default is true. Compositions with trim enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See Specifying Video Layouts for more info.

A Composition Hook VideoLayout describes the video layout of compositions created by that Hook. Details on how to specify such a VideoLayout can be found in the Specifying Video Layouts section on Twilio's Compositions REST API documentation. The only aspect you may take into consideration is that, when working with Composition Hooks, you don't have information about the specific SIDs of tracks, recordings, and participants. Hence, you must specify layouts basing on track names and set such names appropriately in your real-time Rooms.

Retrieves the list Composition Hook Records belonging to the corresponding AccountSid with paging data.

Supported GET parameters
hks-get-parameters page anchor

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

Property nameTypeRequiredPIIDescription
EnabledbooleanOptional

Read only CompositionHook resources with an enabled value that matches this parameter.


DateCreatedAfterstring<date-time>Optional

Read only CompositionHook resources created on or after this ISO 8601(link takes you to an external page) datetime with time zone.


DateCreatedBeforestring<date-time>Optional

Read only CompositionHook resources created before this ISO 8601(link takes you to an external page) datetime with time zone.


FriendlyNamestringOptional

Read only CompositionHook resources with friendly names that match this string. The match is not case sensitive and can include asterisk * characters as wildcard match.


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.

Not Supported


Programming with Composition Hooks is quite similar to programming with Compositions. Hence, in addition to the examples here below, you may also find useful our Recording Compositions documentation

Creating an audio mixing Composition Hook

example-audio-mixing-hk page anchor

In this example, we want to compose only the audio tracks of all completed Rooms. Considering that:

  • Your application credentials are (SKXXXX:your_api_key_secret)
  • You want to mix all audio tracks

The desired Composition Hook can be created with the following code:

Create a Composition Hook mixing all room audio tracksLink to code sample: Create a Composition Hook mixing all room audio tracks
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
5
// Find your credentials at twilio.com/console
6
// To set up environmental variables, see http://twil.io/secure
7
const API_KEY_SID = process.env.TWILIO_API_KEY;
8
const API_KEY_SECRET = process.env.TWILIO_API_KEY_SECRET;
9
const ACCOUNT_SID = process.env.TWILIO_ACCOUNT_SID;
10
11
const Twilio = require('twilio');
12
13
const client = new Twilio(API_KEY_SID, API_KEY_SECRET, {accountSid: ACCOUNT_SID});
14
15
client.video.compositionHooks.
16
create({
17
friendlyName: 'MixingAllRoomAudiosHook',
18
audioSources: '*',
19
statusCallback: 'http://my.server.org/callbacks',
20
format: 'mp4'
21
})
22
.then(compositionHook =>{
23
console.log('Created Composition Hook with SID=' + compositionHook.sid);
24
});

Output

1
{
2
"account_sid": "ACXXXX",
3
"sid": "HKXXXX",
4
"friendly_name": "MixingAllRoomAudiosHook",
5
"enabled": true,
6
"date_created": "2018-12-19T16:22:13Z",
7
"date_updated": null,
8
"audio_sources": [
9
"*"
10
],
11
"audio_sources_excluded": [],
12
"video_layout": {},
13
"format": "mp4",
14
"trim": true,
15
"url": "https://video.twilio.com/v1/CompositionHooks/HKXXXX",
16
"resolution": "640x480",
17
"status_callback_method": "POST",
18
"status_callback": "http://my.server.org/callbacks"
19
}

Creating a simple video mixing Composition Hook

example-grid-mixing-hk page anchor

In this example, we create a Composition Hook for composing all tracks of a Room using a grid layout for video.

Considering that:

  • Your application credentials are (SKXXXX:your_api_key_secret)
  • You want to use mp4 as target format
  • You want to use VGA resolution (640x480)

You can create the desired Composition Hook using the following:

Create a Composition Hook composing rooms in a gridLink to code sample: Create a Composition Hook composing rooms in a grid
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
5
// Find your credentials at twilio.com/console
6
// To set up environmental variables, see http://twil.io/secure
7
const API_KEY_SID = process.env.TWILIO_API_KEY;
8
const API_KEY_SECRET = process.env.TWILIO_API_KEY_SECRET;
9
const ACCOUNT_SID = process.env.TWILIO_ACCOUNT_SID;
10
11
const Twilio = require('twilio');
12
13
const client = new Twilio(API_KEY_SID, API_KEY_SECRET, {accountSid: ACCOUNT_SID});
14
15
client.video.compositionHooks.
16
create({
17
friendlyName: 'MyFirstCompositionHook',
18
audioSources: '*',
19
videoLayout: {
20
grid : {
21
video_sources: ['*']
22
}
23
},
24
statusCallback: 'http://my.server.org/callbacks',
25
format: 'mp4'
26
})
27
.then(compositionHook =>{
28
console.log('Created Composition Hook with SID=' + compositionHook.sid);
29
});

Output

1
{
2
"account_sid": "ACXXXX",
3
"sid": "HKXXXX",
4
"friendly_name": "MyFirstCompositionHook",
5
"enabled": true,
6
"date_created": "2018-12-19T16:04:11Z",
7
"date_updated": null,
8
"audio_sources": [
9
"*"
10
],
11
"audio_sources_excluded": [],
12
"video_layout": {
13
"grid": {
14
"z_pos": 0,
15
"reuse": "show_oldest",
16
"x_pos": 0,
17
"max_columns": null,
18
"cells_excluded": [],
19
"video_sources_excluded": [],
20
"height": null,
21
"width": null,
22
"max_rows": null,
23
"y_pos": 0,
24
"video_sources": [
25
"*"
26
]
27
}
28
},
29
"format": "mp4",
30
"trim": true,
31
"resolution": "640x480",
32
"url": "https://video.twilio.com/v1/CompositionHooks/HKXXXX",
33
"status_callback_method": "POST",
34
"status_callback": "http://my.server.org/callbacks"
35
}

Creating a video mixing Composition Hook with complex layout

example-complex-layout-hk page anchor

In this example, we create a Composition Hook that fires a composition with PiP (Picture-in-Picture) layout for every completed Room. Observe that, at Hook creation time we don't know any track or recording SIDs. Due to this, we must rely on track names. Here we assume that such names comply with the following:

  • A presenter must share a webcam track named presenter-cam as well as a screenshare track named screen. The presenter audio track, in turn, has the name presenter-audio.
  • In addition to the presenter, the room may have a special participant whose audio track we want to include in the composition. When that participant is present, her audio track has the name listener-audio.

Assuming that:

  • Your application credentials are (SKXXXX:your_api_key_secret)
  • You want to use mp4 as target format
  • You want to use HD resolution (1280x720)

The desired Composition Hook may be created as follows:

Create a Composition Hook with complex video layoutLink to code sample: Create a Composition Hook with complex video layout
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
5
// Find your credentials at twilio.com/console
6
// To set up environmental variables, see http://twil.io/secure
7
const API_KEY_SID = process.env.TWILIO_API_KEY;
8
const API_KEY_SECRET = process.env.TWILIO_API_KEY_SECRET;
9
const ACCOUNT_SID = process.env.TWILIO_ACCOUNT_SID;
10
11
const Twilio = require('twilio');
12
13
const client = new Twilio(API_KEY_SID, API_KEY_SECRET, {accountSid: ACCOUNT_SID});
14
15
client.video.compositionHooks.
16
create({
17
friendlyName: 'MyHookWithComplexVideoLayout',
18
audioSources: ['listener-audio', 'presenter-audio'],
19
videoLayout: {
20
main: {
21
z_pos: 1,
22
video_sources: ['screen']
23
},
24
pip: {
25
z_pos: 2,
26
x_pos: 1000,
27
y_pos: 30,
28
width: 240,
29
height: 180,
30
video_sources: ['presenter-cam']
31
}
32
},
33
statusCallback: 'http://my.server.org/callbacks',
34
resolution: '1280x720',
35
format: 'mp4'
36
})
37
.then(compositionHook =>{
38
console.log('Created Composition Hook with SID=' + compositionHook.sid);
39
});

Output

1
{
2
"account_sid": "ACXXXX",
3
"sid": "HKXXXX",
4
"friendly_name": "MyHookWithComplexVideoLayout",
5
"enabled": true,
6
"date_created": "2018-12-19T16:44:10Z",
7
"date_updated": null,
8
"audio_sources": [
9
"listener-audio",
10
"presenter-audio"
11
],
12
"audio_sources_excluded": [],
13
"trim": true,
14
"video_layout": {
15
"pip": {
16
"z_pos": 2,
17
"reuse": "show_oldest",
18
"x_pos": 1000,
19
"max_columns": null,
20
"cells_excluded": [],
21
"video_sources_excluded": [],
22
"height": 180,
23
"width": 240,
24
"max_rows": null,
25
"y_pos": 30,
26
"video_sources": [
27
"presenter-cam"
28
]
29
},
30
"main": {
31
"z_pos": 1,
32
"reuse": "show_oldest",
33
"x_pos": 0,
34
"max_columns": null,
35
"cells_excluded": [],
36
"video_sources_excluded": [],
37
"height": null,
38
"width": null,
39
"max_rows": null,
40
"y_pos": 0,
41
"video_sources": [
42
"screen"
43
]
44
}
45
},
46
"resolution": "1280x720",
47
"format": "mp4",
48
"url": "https://video.twilio.com/v1/CompositionHooks/HKXXXX",
49
"status_callback_method": "POST",
50
"status_callback": "http://my.server.org/callbacks"
51
}

Getting a Composition Hook

example-get-hk page anchor

For executing this example you need:

  • Your application credentials (SKXXXX:your_api_key_secret)
  • The Composition Hook Sid (HKXXXX)
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
5
const apiKeySid = 'SKXXXX';
6
const apiKeySecret = 'your_api_key_secret';
7
// To set up environmental variables, see http://twil.io/secure
8
const accountSid = process.env.TWILIO_ACCOUNT_SID;
9
const Twilio = require('twilio');
10
11
const client = new Twilio(apiKeySid, apiKeySecret, {accountSid: accountSid});
12
13
compositionHook = client.video.compositionHooks('HKXXXX')
14
.fetch()
15
.then(compositionHook =>{
16
console.log('Read Composition Hook with SID=' + compositionHook.sid);
17
});

Output

1
{
2
"account_sid": "ACXXXX",
3
"sid": "HKXXXX",
4
"friendly_name": "MixingAllRoomAudiosHook",
5
"enabled": true,
6
"date_created": "2018-12-19T16:22:13Z",
7
"date_updated": null,
8
"audio_sources": [
9
"*"
10
],
11
"audio_sources_excluded": [],
12
"video_layout": {},
13
"format": "mp4",
14
"trim": true,
15
"url": "https://video.twilio.com/v1/CompositionHooks/HKXXXX",
16
"resolution": "640x480",
17
"status_callback_method": "POST",
18
"status_callback": "http://my.server.org/callbacks"
19
}

Listing all enabled Composition Hooks

example-list-hks page anchor

For executing this example you need:

  • Your application credentials (SKXXXX:your_api_key_secret)
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
5
const apiKeySid = 'SKXXXX';
6
const apiKeySecret = 'your_api_key_secret';
7
// To set up environmental variables, see http://twil.io/secure
8
const accountSid = process.env.TWILIO_ACCOUNT_SID;
9
const Twilio = require('twilio');
10
11
const client = new Twilio(apiKeySid, apiKeySecret, {accountSid: accountSid});
12
13
client.video.compositionHooks.
14
list({
15
enabled: true
16
})
17
.then(hooks =>{
18
console.log("Found " + hooks.length + " Composition Hooks.");
19
hooks.forEach(function(hook){
20
console.log('Read hook with SID=' + hook.sid);
21
});
22
});

Output

1
{
2
"composition_hooks": [
3
{
4
"trim": true,
5
"video_layout": {
6
"pip": {
7
"z_pos": 2,
8
"reuse": "show_oldest",
9
"x_pos": 1000,
10
"max_columns": null,
11
"cells_excluded": [],
12
"video_sources_excluded": [],
13
"height": 180,
14
"width": 240,
15
"max_rows": null,
16
"y_pos": 30,
17
"video_sources": [
18
"presenter-cam"
19
]
20
},
21
"main": {
22
"z_pos": 1,
23
"reuse": "show_oldest",
24
"x_pos": 0,
25
"max_columns": null,
26
"cells_excluded": [],
27
"video_sources_excluded": [],
28
"height": null,
29
"width": null,
30
"max_rows": null,
31
"y_pos": 0,
32
"video_sources": [
33
"screen"
34
]
35
}
36
},
37
"audio_sources_excluded": [],
38
"format": "mp4",
39
"date_updated": null,
40
"friendly_name": "MyHookWithComplexVideoLayout",
41
"enabled": true,
42
"account_sid": "ACXXXX",
43
"url": "https://video.twilio.com/v1/CompositionHooks/HKXXXX",
44
"audio_sources": [
45
"listener-audio",
46
"listener-video"
47
],
48
"sid": "HKXXXX",
49
"date_created": "2018-12-19T16:44:10Z",
50
"resolution": "1280x720",
51
"status_callback_method": "POST",
52
"status_callback": "http://my.server.org/callbacks"
53
},
54
{
55
"trim": true,
56
"video_layout": {},
57
"audio_sources_excluded": [],
58
"format": "mp4",
59
"date_updated": null,
60
"friendly_name": "MixingAllRoomAudiosHook",
61
"enabled": true,
62
"account_sid": "ACXXXX",
63
"url": "https://video.twilio.com/v1/CompositionHooks/HKXXXX",
64
"audio_sources": [
65
"*"
66
],
67
"sid": "HKXXXX",
68
"date_created": "2018-12-19T16:22:13Z",
69
"resolution": "640x480",
70
"status_callback_method": "POST",
71
"status_callback": "http://my.server.org/callbacks"
72
},
73
{
74
"trim": true,
75
"video_layout": {
76
"grid": {
77
"z_pos": 0,
78
"reuse": "show_oldest",
79
"x_pos": 0,
80
"max_columns": null,
81
"cells_excluded": [],
82
"video_sources_excluded": [],
83
"height": null,
84
"width": null,
85
"max_rows": null,
86
"y_pos": 0,
87
"video_sources": [
88
"*"
89
]
90
}
91
},
92
"audio_sources_excluded": [],
93
"format": "mp4",
94
"date_updated": null,
95
"friendly_name": "MyFirstCompositionHook2",
96
"enabled": true,
97
"account_sid": "ACXXXX",
98
"url": "https://video.twilio.com/v1/CompositionHooks/HKXXXX",
99
"audio_sources": [
100
"*"
101
],
102
"sid": "HKXXXX",
103
"date_created": "2018-12-19T16:15:25Z",
104
"resolution": "640x480",
105
"status_callback_method": "POST",
106
"status_callback": "http://my.server.org/callbacks"
107
},
108
{
109
"trim": true,
110
"video_layout": {
111
"grid": {
112
"z_pos": 0,
113
"reuse": "show_oldest",
114
"x_pos": 0,
115
"max_columns": null,
116
"cells_excluded": [],
117
"video_sources_excluded": [],
118
"height": null,
119
"width": null,
120
"max_rows": null,
121
"y_pos": 0,
122
"video_sources": [
123
"*"
124
]
125
}
126
},
127
"audio_sources_excluded": [],
128
"format": "mp4",
129
"date_updated": null,
130
"friendly_name": "MyFirstCompositionHook",
131
"enabled": true,
132
"account_sid": "ACXXXX",
133
"url": "https://video.twilio.com/v1/CompositionHooks/HKXXXX",
134
"audio_sources": [
135
"*"
136
],
137
"sid": "HKXXXX",
138
"date_created": "2018-12-19T16:04:11Z",
139
"resolution": "640x480",
140
"status_callback_method": "POST",
141
"status_callback": "http://my.server.org/callbacks"
142
},
143
{
144
"trim": true,
145
"video_layout": {
146
"grid": {
147
"z_pos": 0,
148
"reuse": "show_oldest",
149
"x_pos": 0,
150
"max_columns": null,
151
"cells_excluded": [],
152
"video_sources_excluded": [],
153
"height": null,
154
"width": null,
155
"max_rows": null,
156
"y_pos": 0,
157
"video_sources": [
158
"*"
159
]
160
}
161
},
162
"audio_sources_excluded": [],
163
"format": "mp4",
164
"date_updated": "2018-12-19T15:52:08Z",
165
"friendly_name": "llf-composition-hook-test",
166
"enabled": false,
167
"account_sid": "ACXXXX",
168
"url": "https://video.twilio.com/v1/CompositionHooks/HKXXXX",
169
"audio_sources": [
170
"*"
171
],
172
"sid": "HKXXXX",
173
"date_created": "2018-12-19T15:09:41Z",
174
"resolution": "640x480",
175
"status_callback_method": "POST",
176
"status_callback": null
177
}
178
],
179
"meta": {
180
"page": 0,
181
"page_size": 50,
182
"first_page_url": "https://video.twilio.com/v1/CompositionHooks?PageSize=50&Page=0",
183
"previous_page_url": null,
184
"url": "https://video.twilio.com/v1/CompositionHooks?PageSize=50&Page=0",
185
"next_page_url": null,
186
"key": "composition_hooks"
187
}
188
}

Updating a Composition Hook

example-update-hk page anchor

A very important aspect that you must remember is that we do not support partial updates. This means that you must provide all POST parameters on every update operation. In other words, any optional parameter you don't provide will be reset (i.e. set to its default value) with the update.

Just for illustration, the following example updates the above-created Grid Composition Hook to disable it. Observe that we need to provide again all the properties that were set during the create operation.

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
5
// Find your credentials at twilio.com/console
6
// To set up environmental variables, see http://twil.io/secure
7
const API_KEY_SID = process.env.TWILIO_API_KEY;
8
const API_KEY_SECRET = process.env.TWILIO_API_KEY_SECRET;
9
const ACCOUNT_SID = process.env.TWILIO_ACCOUNT_SID;
10
11
const Twilio = require('twilio');
12
13
const client = new Twilio(API_KEY_SID, API_KEY_SECRET, {accountSid: ACCOUNT_SID});
14
15
client.video.compositionHooks('HKXXXX')
16
update({
17
friendlyName: 'MyFirstCompositionHook',
18
enabled: false,
19
audioSources: '*',
20
videoLayout: {
21
grid : {
22
video_sources: ['*']
23
}
24
},
25
statusCallback: 'http://my.server.org/callbacks',
26
format: 'mp4'
27
})
28
.then(compositionHook =>{
29
console.log('Updated Composition Hook with SID=' + compositionHook.sid);
30
});

Output

1
{
2
"account_sid": "ACXXXX",
3
"sid": "HKXXXX",
4
"friendly_name": "MyFirstCompositionHook",
5
"enabled": false,
6
"date_created": "2018-12-19T16:04:11Z",
7
"date_updated": "2018-12-19T16:55:21Z",
8
"audio_sources": [
9
"*"
10
],
11
"audio_sources_excluded": [],
12
"video_layout": {
13
"grid": {
14
"z_pos": 0,
15
"reuse": "show_oldest",
16
"x_pos": 0,
17
"max_columns": null,
18
"cells_excluded": [],
19
"video_sources_excluded": [],
20
"height": null,
21
"width": null,
22
"max_rows": null,
23
"y_pos": 0,
24
"video_sources": [
25
"*"
26
]
27
}
28
},
29
"format": "mp4",
30
"trim": true,
31
"resolution": "640x480",
32
"url": "https://video.twilio.com/v1/CompositionHooks/HKXXXX",
33
"status_callback_method": "POST",
34
"status_callback": "http://my.server.org/callbacks"
35
}

Deleting a Composition Hook

example-delete-hk page anchor

For executing this example you need:

  • Your application credentials (SKXXXX:your_api_key_secret)
  • The Composition Hook Sid (HKXXXX)
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
5
const apiKeySid = 'SKXXXX';
6
const apiKeySecret = 'your_api_key_secret';
7
// To set up environmental variables, see http://twil.io/secure
8
const accountSid = process.env.TWILIO_ACCOUNT_SID;
9
const Twilio = require('twilio');
10
11
const client = new Twilio(apiKeySid, apiKeySecret, {accountSid: accountSid});
12
13
client.video.compositionHooks('HKXXXX').
14
remove()
15
.then(response =>{
16
console.log('Composition Hook removed');
17
});

Output

A successful request returns an HTTP status code 204 and an empty body

Known Problems and Limitations

known-problems-and-limitations page anchor

There are no known problems.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.