Server APIs v2

Kick a user out of a room

Update Time:2021-10-25 17:41

1 Description

Kicks one or more specified users out of a room, which will also stop the users from publishing streams to or playing streams from the room.

On the client side, the ZEGO Express SDK will trigger the following callback to notify the kicked-out user of the event:

Platform ZEGO Express SDK callback
iOS/macOS onRoomStateUpdate
Android onRoomStateUpdate
Windows onRoomStateUpdate
Web roomStateUpdate

Also, the ZEGO Express SDK will trigger the following callback to notify other users in the same room of the event:

Platform ZEGO Express SDK callback
iOS/macOS onRoomUserUpdate
Android onRoomUserUpdate
Windows onRoomUserUpdate
Web roomUserUpdate

2 Request method and endpoint

  • Request method: GET
  • Request endpoint: https://rtc-api.zego.im/?Action=KickoutUser
  • Transmission protocol: HTTPS
  • Rate limit (Rooms with the same AppID): 50 requests/second

3 Request parameters

Listed below are the parameters specific to this request and part of the public request parameters. For the complete list of public request parameters, see Server APIs public request parameters.

Parameter Type Required Description
RoomId String Yes Room ID.
UserId[] Array of String Yes User IDs of the users to be kicked out. The maximum number of User IDs allowed is 5.
Example: UserId[]=a&UserId[]=b
CustomReason String No Reason of the kick-out.

4 Request example

https://rtc-api.zego.im/?Action=KickoutUser
&RoomId=123
&UserId[]=a&UserId[]=b
&CustomReason=%E8%B8%A2%E5%87%BA%E7%94%A8%E6%88%B7-%E5%8E%9F%E5%9B%A0
&<Public Request Parameters>

5 Response parameters

Parameter Type Description
Code Number Return code.
Message String Description of the request execution result.
RequestId String Request ID.

6 Response example

{
    "Code":0,
    "Message":"success",
    "RequestId":"343649807833778782"
}

7 Return codes

Listed below are the return codes related to this API. For the complete list of return codes, see Return codes.

Return code Description
50001 Room does not exist.
  • When there are no users in a room, the room will be automatically destroyed by the SDK.
  • When there is only one user in a room and the user exits or is kicked out of the room, the room will be automatically destroyed by the SDK.
  • When a room's heartbeat request times out by 100 seconds, the room will be destroyed by the SDK.
50002 User ID does not exist.
50003 Failed to get online user count.
50004 Failed to get user information.
50011 The number of recipients of the custom message has exceeded the limit.
50012 The length of the custom message has exceeded the limit.
50013 Failed to send custom message.