Acquire a builder token

Updated

Acquires a builder token for creating a Cloud Transcoding task.

POST
https://api.sd-rtn.com/v1/projects/{appId}/rtsc/cloud-transcoder/builderTokens

Before you create a Cloud Transcoding task, call the builderTokens endpoint to retrieve a builder token.

Path Parameters

appIdstring
Required

The App ID of your project from Agora Console.

Header Parameters

Content-Typestring
Required

The request content type. Use application/json.

X-Request-IDstring

UUID (Universally Unique Identifier), used to identify this request.

If the request fails, print out the value in the log to troubleshoot the problem. If the response status code of the request is not 2XX, then the response header may not contain this field.

Request Body

application/json

instanceIdstring
Required

The instanceId you specified in the request.

servicesobject
Required
cloudTranscoderobject
Required

Response

  • If the returned status code is 200, the request was successful. The response body contains the result of the request.

  • If the returned status code is not 200, the request failed.

Response Body

The request succeeded and returned a builder token.

Response Headers

X-Request-IDstring

The unique request ID. If the request fails, use this value in the log to troubleshoot the problem.

createTsnumber

Unix timestamp (seconds) when the builderToken was generated

instanceIdstring

The user-specified instance ID.

tokenNamestring

The value of the builderToken. Use this value when calling other methods for this instance.

Reference

Note the following guidelines when using a builderToken:

  • After calling this endpoint successfully, you receive a builderToken in the response body. You can use a builderToken for a single Cloud Transcoding task.
  • The validity period of a builderToken for creating Cloud Transcoding is 5 minutes. To ensure successful Cloud Transcoding, best practice is to initiate the corresponding Create request within 2 seconds after each Acquire response is received.
  • Making batch Create requests after batch builderToken requests may cause the request to fail.

Output destination constraints

  • A single transcoding task cannot push to both a CDN address and an RTC channel simultaneously. To push to both destinations, create two separate tasks.
  • If the audio or video configurations differ between the two destinations, create two separate tasks.
  • To push to multiple CDN addresses, include all destination addresses within a single outputs object.
  • Each transcoding task can push to only one RTC channel. To push to two different RTC channels, create two separate tasks.

Authorization

This endpoint requires authentication.

basicAuth

Request examples

curl --request post \        --url https://api.sd-rtn.com/v1/projects/:appId/rtsc/cloud-transcoder/builderTokens \        --header 'Authorization: Basic <credentials>' \        --header 'Content-Type: <string>' \        --data '      {        "instanceId": "abc13328",        "services": {          "cloudTranscoder": {            "serviceType": "cloudTranscoderV2",            "config": {              "transcoder": {                "idleTimeout": 300,                "audioInputs": [                  {                    "rtc": {                      "rtcChannel": "test01",                      "rtcUid": 123,                      "rtcToken": "<your_rtc_token>"                    }                  },                  {                    "rtc": {                      "rtcChannel": "test01",                      "rtcUid": 456,                      "rtcToken": "<your_rtc_token>"                    }                  }                ],                "canvas": {                  "width": 960,                  "height": 480,                  "color": 0,                  "backgroundImage": "https://web-cdn.agora.io/website-files/images/new-home-2-banne-online-karaoke-bg.jpg",                  "fillMode": "FIT"                },                "waterMarks": [                  {                    "imageUrl": "https://web-cdn.agora.io/website-files/images/advantage-interactive-live-streaming.png",                    "region": {                      "x": 0,                      "y": 0,                      "width": 100,                      "height": 100,                      "zOrder": 50                    }                  }                ],                "videoInputs": [                  {                    "rtc": {                      "rtcChannel": "test01",                      "rtcUid": 123,                      "rtcToken": "<your_rtc_token>"                    },                    "placeholderImageUrl": "https://web-cdn.agora.io/website-files/images/new-home-2-banner-realtime-bg.jpg",                    "region": {                      "x": 0,                      "y": 0,                      "width": 320,                      "height": 360,                      "zOrder": 2                    }                  },                  {                    "rtc": {                      "rtcChannel": "test01",                      "rtcUid": 456,                      "rtcToken": "<your_rtc_token>"                    },                    "region": {                      "x": 320,                      "y": 0,                      "width": 320,                      "height": 320,                      "zOrder": 2                    }                  }                ],                "outputs": [                  {                    "rtc": {                      "rtcChannel": "test02",                      "rtcUid": 1000,                      "rtcToken": "<your_rtc_token>"                    },                    "audioOption": {                      "profileType": "AUDIO_PROFILE_MUSIC_STANDARD"                    },                    "videoOption": {                      "fps": 30,                      "codec": "H264",                      "bitrate": 800,                      "width": 960,                      "height": 48                    }                  }                ]              }            }          }        }      }'

Response example

{  "createTs": 1661324606,  "instanceId": "abc13328",  "tokenName": "xUwUbQf9ZxxxxxtLslGnDg0lk8RYaUE0***"}