Create streaming key
Updated
Creates a streaming key for Media Gateway ingress streaming.
https://api.agora.io/{region}/v1/projects/{appId}/rtls/ingress/streamkeysCreate a key before streaming to ensure that the media stream is pushed to the correct channel and under the correct host ID.
Important
Keep the created streaming key secure to prevent unauthorized streaming to the channel.
Path Parameters
regionstringRegion for the streaming key or stream. Supported values are na for North America, eu for Europe, ap for Asia except mainland China, and cn for mainland China.
Important
Make sure that:
- The
regionvalue is the same as for the input source stream. - The domain names for setting the
regionparameter and streaming are the same. - The
regionvalue is in lowercase.
appIdstringThe app ID provided by Agora to each developer. After creating a project in Agora Console, you can get an app ID. The app ID is a unique identifier for a project.
Header Parameters
X-Request-IDstringThe UUID (Universally Unique Identifier) of the request. After you pass in this field, the Agora server returns this field in the response header. It is recommended to assign X-Request-ID a value. If omitted, the Agora server automatically generates a UUID and returns it.
Request Body
application/json
settingsobjectImportant
To ensure a successful request, do not leave this field empty or set to null.
channelstringAgora channel name. The string length must be less than 64 bytes. You can leave this field empty and Agora uses a random integer UID to enter the channel in the GR-xxxx format. The channel and uid parameters cannot be empty or 0 at the same time.
uidstringHost user UID in the Agora channel. Numeric IDs can range from 1 to 4294967295. String IDs cannot exceed 255 bytes or be empty. If this field is empty or 0, Agora uses a random integer UID. The channel and uid parameters cannot be empty or 0 at the same time.
expiresAfterintegerValidity period of the streaming key in seconds from creation. If set to 0, the streaming key is always valid. Do not leave this field empty or set it to null.
templateIdstringAssociated flow configuration template ID. Omit this field if you have not created a configuration template. If omitted, the default configuration is used.
Response Body
The request succeeded and returned the created streaming key.
Response Headers
statusstringRequest status. success means the request succeeds.
dataobjectstreamKeystringThe streaming key.
channelstringAgora channel name associated with the streaming key.
uidstringUser UID associated with the streaming key.
expiresAfterintegerValidity period of the streaming key in seconds.
createdAtstringUnix timestamp, in seconds, when the streaming key was created.
Request examples
curl --request POST \ --url https://api.sd-rtn.com/region/v1/projects/yourActualAppId/rtls/ingress/streamkeys \ --header 'Accept: application/json' \ --header 'Authorization: Basic <Base64EncodedCredentials>' \ --header 'Content-Type: application/json' \ --header 'X-Request-ID: <UniqueRequestID>' \ --data '{ "settings": { "channel": "shx001", "uid": "1001", "expiresAfter": 0 }}'Response example
{ "status": "success", "data": { "streamKey": "2dfMTR****fys", "channel": "shx001", "uid": "1001", "expiresAfter": 0, "createdAt": "1686820170" }}