# Manage chat room members (/en/realtime-media/im/build/build-groups-rooms-and-threads/chat-room/manage-chatroom-members/web)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

Chat rooms enable real-time messaging among multiple users.

    This page shows how to use the Chat SDK to manage the members of a chat room in your app.

    ## Understand the tech [#understand-the-tech-6]

    The Chat SDK allows you to implement the following features:

    * Remove a member from a chat room
    * Retrieve the member list of a chat room
    * Manage the blocklist of a chat room
    * Manage the mute list of a chat room
    * Mute and unmute all the chat room members
    * Manage the chat room allow list
    * Manage the owner and admins of a chat room

    ## Prerequisites [#prerequisites-6]

    Before proceeding, ensure that you meet the following requirements:

    * You have initialized the Chat SDK. For details, see [SDK quickstart](../../../get-started-sdk).
    * You understand the call frequency limit of the Chat APIs supported by different pricing plans as described in [Limitations](../../limitations).
    * You understand the number of chat rooms supported by different pricing plans as described in [Pricing Plan Details](../../../reference/pricing-plan-details).

    ## Implementation [#implementation-6]

    This section introduces how to call the APIs provided by the Chat SDK to implement the features listed above.

    ### Retrieve the chat room member list [#retrieve-the-chat-room-member-list-4]

    Since SDK v1.4.0, call `getChatRoomMembers` to retrieve the chat room member list with pagination. Each entry includes the member's user ID, role, and the time they joined the chat room. The server does not sort the members, so the returned list is not guaranteed to be ordered. The `listChatRoomMembers` method is deprecated.

    ```javascript
    // cursor: the position to start from. Pass an empty string for the first page; for subsequent pages, pass res.data.cursor from the previous result.
    // limit: the number of members to retrieve per page. The default is 50; the upper limit depends on the server.
    chatClient
      .getChatRoomMembers({ cursor: "", limit: 50, chatRoomId: "chatRoomId" })
      .then((res) => {
        console.log(res);
      });
    ```

    ### Manage the chat room blocklist [#manage-the-chat-room-blocklist-5]

    The chat room owner and admins can add and remove the specified members from the chat room blocklist. Once a chat room member is added to the blocklist, this member cannot send or receive chat room messages, nor can they join the chat room again.

    ```javascript
    // The chat room owner or admin can call blockChatRoomMembers to add the specified members to the chat room blocklist.
    const options = {
      chatRoomId: "chatRoomId",
      usernames: ["user1", "user2"], // The array of usernames
    };
    chatClient.blockChatRoomMembers(options).then((res) => console.log(res));

    // The chat room owner or admin can call unblockChatRoomMembers to remove the specified users from the blocklist.
    const options = {
      chatRoomId: "chatRoomId",
      usernames: ["user1", "user2"], // The array of usernames
    };

    chatClient.unblockChatRoomMembers(options).then((res) => console.log(res));

    // The chat room owner or admin can call getChatRoomBlocklist to retrieve the blocklist of the current chat room.
    const options = {
      chatRoomId: "chatRoomId",
    };
    chatClient.getChatRoomBlocklist(options);
    ```

    ### Manage the chat room mute list [#manage-the-chat-room-mute-list-6]

    The chat room owner and admins can add and remove the specified members from the chat room mute list. Once a chat room member is added to the mute list, this member can no longer send chat room messages, not even after being added to the chat room allow list.

    ```javascript
    // The chat room owner or admin can call muteChatRoomMember to add the specified user to the chat room blocklist.
    // The muted member and all other chat room admins or owner receive the muteMember callback.
    const options = {
      chatRoomId: "chatRoomId", // The ID of the chat room
      username: "username", // The username of the muted user
      muteDuration: -1, // muteDuration: The mute duration. If you pass `-1`, members are muted permanently.
    };
    chatClient.muteChatRoomMember(options).then((res) => console.log(res));

    // The chat room owner or admin can call unmuteChatRoomMember to remove the specified user from the chat room mute list.
    // The unmuted member and all the other chat room admins or owner receive the unmuteMember callback.
    const options = {
      chatRoomId: "chatRoomId",
      username: "username",
    };
    chatClient.unmuteChatRoomMember(options).then((res) => console.log(res));

    // The chat room owner or admin can call getChatRoomMuteList to retrieve the mute list of the current chat room.
    const options = {
      chatRoomId: "chatRoomId",
    };
    chatClient.getChatRoomMuteList(options).then((res) => console.log(res));
    ```

    ### Mute and unmute all chat room members [#mute-and-unmute-all-chat-room-members-1]

    The chat room owner and admins can mute or unmute all chat room members. All members in the group can receive the `muteAllMembers` event.

    Once all members are muted, only those in the chat room allow list can send messages in the chat room.

    Unlike muting a chat room member, this kind of mute does not expire automatically after a certain period and you need to call the `enableSendChatRoomMsg` method to unmute all members in the chat room.

    ```javascript
    // The chat room owner or admin can call disableSendChatRoomMsg to mute all the chat room members.
    // Once all the members are muted, these members receive the muteAllMembers callback.
    const options = {
      chatRoomId: "chatRoomId",
    };
    chatClient.disableSendChatRoomMsg(options).then((res) => console.log(res));

    // The chat room owner or admin can call enableSendChatRoomMsg to unmute all the chat room members.
    // Once all the members are unmuted, these members receive the unmuteAllMembers callback.
    const options = {
      chatRoomId: "chatRoomId",
    };
    chatClient.enableSendChatRoomMsg(options).then((res) => {
      console.log(res);
    });
    ```

    ### Manage the chat room allow list [#manage-the-chat-room-allow-list-6]

    The chat room owner and admins are added to the chat room allow list by default.

    Members in the chat room allow list can send chat room messages even when the chat room owner or an admin has muted all the chat room members. However, if a member is already in the chat room mute list, this member still cannot send messages in the chat room even after being added to the chat room allow list.

    ```javascript
    // The chat room owner or admin can call addUsersToChatRoomAllowlist to add the specified member to the chat room allow list.
    const options = {
      chatRoomId: "chatRoomId",
      users: ["user1", "user2"], // The array of usernames
    };
    chatClient.addUsersToChatRoomAllowlist(options);

    // The chat room owner or admin can call removeChatRoomAllowlistMember to remove the specified member from the chat room allow list.
    const options = {
      chatRoomId: "chatRoomId",
      userName: "user",
    };
    chatClient.removeChatRoomAllowlistMember(options);

    // Chat room members can call isInChatRoomAllowlist to check whether they are in the chat room allow list.
    const options = {
      chatRoomId: "chatRoomId",
      userName: "user",
    };
    chatClient.isInChatRoomAllowlist(options);

    // The chat room owner or admin can call getChatRoomAllowlist to retrieve the allow list of the current chat room.
    const options = {
      chatRoomId: "chatRoomId",
    };
    chatClient.getChatRoomAllowlist(options).then((res) => console.log(res));
    ```

    ### Manage the chat room admins [#manage-the-chat-room-admins]

    The chat room owner can add admins. Once added to the chat room admin list, the newly added admin and the other chat room admins receive the `setAdmin` callback.

    The chat room owner can remove admins. Once removed from the chat room admin list, the removed admin and the other chat room admins receive the `removeAdmin` callback.

    ```javascript
    // The chat room owner can call setChatRoomAdmin to add admins.
    const options = {
      chatRoomId: "chatRoomId",
      username: "user1",
    };
    chatClient.setChatRoomAdmin(options).then((res) => console.log(res));

    // The chat room owner can call removeChatRoomAdmin to remove admins.
    const options = {
      chatRoomId: "chatRoomId",
      username: "user1",
    };
    chatClient.removeChatRoomAdmin(options).then((res) => console.log(res));
    ```

    ### Listen for chat room events [#listen-for-chat-room-events-6]

    For details, see [Chat Room Events](manage-chatrooms#listen-for-chat-room-events).

    
  
