logo
Voice Call
Server API
Stream Mixing and Transcoding APIs
On this page

AddStream

GET

https://rtc-api.zego.im/

Use this interface to add a stream to a specified Room. This is commonly used in "watch together" scenarios, such as adding a CDN live stream to a specified Room, allowing users in the Room to obtain the stream ID and enabling server-side control over the live content in the specified Room.

Warning
  • When adding a stream to a specified Room, ensure that the Room exists. This interface cannot create a Room. If you want to automatically create the corresponding Room when adding a stream, please contact ZEGOCLOUD technical support to enable the related feature.
  • This interface is generally used together with Delete Room Stream, for example, when the business needs to stop broadcasting a stream to a Room.

This interface is only used to trigger notifications related to stream addition in the Room and does not perform actual stream publishing operations. Developers need to call the startPublishingStream interface from their client (or other stream publishing methods) to publish the stream, so that the added stream can be played by the startPlayingStream interface.

Clients receive notifications of stream addition in the Room using ZEGO Express SDK callback interfaces:

ZegoExpress SDKLiveRoom SDK
iOS/macOSonRoomStreamUpdateonStreamUpdated
AndroidonRoomStreamUpdateonStreamUpdated
WindowsonRoomStreamUpdateOnStreamUpdated
WebroomStreamUpdateonStreamUpdated
Call Rate Limit
All Rooms under the same AppID: 10 times/second (test environment: 1 time/second)
Warning
  • It is not recommended to use the same UserId as actual users in the Room to avoid conflicts with the client SDK's stream addition behavior. You can use a specific name to identify server-side behavior, for example: userId = "Server-Administrator".
  • If you use the same UserId as actual users in the Room (not recommended), please note the following:
    • The client with the corresponding operator's UserId will not receive the stream addition callback triggered by this server-side interface.
    • If the actual user's UserId in the Room has not published the stream, the stream deletion logic for the corresponding StreamId will be triggered.
    • If the actual user's UserId in the Room leaves the Room, the stream deletion logic for the corresponding StreamId will be triggered.

Request

Query Parameters

    Action stringrequired

    Possible values: [AddStream]

    Interface prototype parameters

    https://rtc-api.zego.im?Action=AddStream

    AppId uint32required

    💡Public parameter. Application ID, assigned by ZEGOCLOUD. Get it from the ZEGOCLOUD Admin Console.

    SignatureNonce stringrequired

    💡Common parameter. A 16-character hexadecimal random string (hex-encoded 8-byte random number). For the generation algorithm, refer to the signature example.

    Timestamp int64required

    💡Common parameter. Current Unix timestamp in seconds. For the generation algorithm, refer to the signature example. A maximum deviation of 10 minutes is allowed.

    Signature stringrequired

    💡Common parameter. Signature used to verify the legitimacy of the request. Please refer to the signature mechanism to generate it.

    SignatureVersion stringrequired

    Possible values: [2.0]

    Default value: 2.0

    💡Public parameter. Signature version number.

    RoomId stringrequired

    Room ID.

    UserId stringrequired

    User ID.

    UserName string

    Username.

    StreamId stringrequired

    Possible values: <= 256 characters

    Stream ID, not exceeding 256 bytes.

    StreamTitle string

    Possible values: <= 127 characters

    Stream title, not exceeding 127 bytes. When used, URL encoding (UrlEncode) must be performed on its content.

    ExtraInfo string

    Possible values: <= 1024 characters

    Stream additional information, not exceeding 1024 bytes.

    CensorFlag int32

    Possible values: [0, 1]

    Default value: 0

    Moderation flag. Whether the current stream is allowed for moderation when moderating the Room stream list: 0 means allowed, 1 means not allowed.

    📌 Important Note

    • When set to not allowed for moderation, the moderation service provider will not pull this stream for moderation.

    • When using stream injection to implement cross-room PK business scenarios, it is recommended to set this field to "not allowed" to avoid the same stream being repeatedly moderated in multiple Rooms.

Responses

Operation successful
Schema
    Code int32

    Return code. The following only lists some return codes related to the interface business logic. For complete return codes, please refer to Global Return Codes.

    Return CodeDescriptionSuggested Action
    123Failed to set stream information.Please retry, or contact ZEGOCLOUD technical support for assistance.
    1012Multiple users operating on the same stream.Please check the logic.
    Message string

    Description of the operation result.

    RequestId string

    Request ID.

Previous

DescribeUserList

Next

DeleteStream

On this page

Back to top