Skip to main content

POST create a stream

POST /stream creates a stream object. The configuration on this parent stream object is inherited by all future child session objects.

The only parameter you are required to set is the name of your stream, but we also highly recommend that you define the profiles parameter with 720p, 480p and 360p renditions.

If you do not define transcoding rendition profiles when creating the stream, no transcoding will happen. Your playback video will have the attributes of the source stream only, will not take advantage of adaptive bitrate streaming and will likely buffer.

Create a stream

Request

curl -X POST 'https://livepeer.studio/api/stream' \
-H 'content-type: application/json' \
-H 'authorization: Bearer {api_key}' \
-d '{
"name": "test_stream",
"profiles": [
{
"name": "720p",
"bitrate": 2000000,
"fps": 30,
"width": 1280,
"height": 720
},
{
"name": "480p",
"bitrate": 1000000,
"fps": 30,
"width": 854,
"height": 480
},
{
"name": "360p",
"bitrate": 500000,
"fps": 30,
"width": 640,
"height": 360
}
]
}'

Response

{
"name":"test_stream",
"profiles":[
{"name":"720p","bitrate":2000000,"fps":30,"width":1280,"height":720},
{"name":"480p","bitrate":1000000,"fps":30,"width":854,"height":480}],
{"name":"360p","bitrate":500000,"fps":30,"width":640,"height":360}],
"id":"ijkl61f3-95bd-4971-a7b1-4dcb5d39e78a",
"createdAt":1596081229373,
"streamKey":"abcd-uimq-jtgy-x98v",
"playbackId":"efghb2mxupongp5k",
{other asset object keys}
}

Create a stream with a playback policy

Add an access control playback policy to a stream.

A playbackPolicy type can be either:

  • public - No access control is applied to the stream
  • jwt - A JWT is required to playback the stream

If you set your stream or asset's playback policy to JWT, you will need to sign a token with a signing key and put it in the playback URL to be able to playback your stream.

Request

curl -X POST 'https://livepeer.studio/api/stream' \
-H 'content-type: application/json' \
-H 'authorization: Bearer {api_key}' \
-d '{
"name": "test_stream",
"playbackPolicy": {
"type":"jwt"
}
}'

Response

{
"name":"test_stream",
"id":"ijkl61f3-95bd-4971-a7b1-4dcb5d39e78a",
"createdAt":1596081229373,
"streamKey":"abcd-uimq-jtgy-x98v",
"playbackId":"efghb2mxupongp5k",
"playbackPolicy": {
"type": "jwt"
},
{other asset object keys}
}