In-app Chat
SDK Error Codes
On this page

Community Member Management

2026-06-24

Feature Overview

ZIM SDK provides comprehensive Community member management capabilities, supporting the following features:

  • Invite users to join a Community
  • Remove Community members
  • Update member roles
  • Transfer Community ownership
  • Query Community member list
  • Query specified member information
  • Set member mute status
  • Listen for member state and information changes

Prerequisites

  • Please refer to Implement basic message sending and receiving to complete ZIM SDK acquisition, initialization, and user login.
  • Please refer to Authenticate with Token to implement user authentication and login.
  • Community features require ZIM SDK 3.0.0 or later.
  • Community is a premium feature. Please contact ZEGOCLOUD Technical Support for activation before use.
  • The Token generation method for Community features is the same as for other ZIM features, with no additional permission declarations required.

Invite Users to Join a Community

Call the inviteUsersIntoCommunity API to batch invite users to join a Community. The invitation does not require the other party's consent; invited users directly become Community members. Invited users must already be registered in the system. A single API call can invite up to 100 users to join a Community.

Failed user information will be returned through errorUserList.

const userIDs = ['user_1', 'user_2'];

zim.inviteUsersIntoCommunity(userIDs, communityID)
    .then((result: ZIMCommunityUsersInvitedResult) => {
        // result.errorUserList lists users for whom the invitation failed
    })
    .catch((err: ZIMError) => {
        // Operation failed
    });
Error CodeDescriptionRecommended Action
6001004Community does not existConfirm if the communityID is correct
6001005User is not in the CommunityOnly occurs in specific scenarios; confirm user status
6001007Community permission errorConfirm whether the current user has invitation permission

Remove Community Members

Call the kickCommunityMembers API to batch remove specified members from the Community. A single API call can remove up to 100 users from the Community.

Warning

Only the Community owner and admins can call this API.

const userIDs = ['user_1', 'user_2'];

zim.kickCommunityMembers(userIDs, communityID)
    .then((result: ZIMCommunityMembersKickedResult) => {
        // result.errorUserList lists users for whom the operation failed
    })
    .catch((err: ZIMError) => {
        // Operation failed
    });

Update Community Member Role

Call the updateCommunityMemberRole API to modify a specified member's role in the Community, such as setting a regular member as an admin.

Warning

Only the Community owner can call this API. Community roles: 1 for Community owner, 2 for Community admin, 3 for Community regular member.

// memberRole: 2 = Admin, 3 = Regular member (see enum definition for details)
zim.updateCommunityMemberRole(2, 'target_user_id', communityID)
    .then((result: ZIMCommunityMemberRoleUpdatedResult) => {
        // Role updated successfully
    })
    .catch((err: ZIMError) => {
        // Operation failed
    });

Transfer Community Ownership

Call the transferCommunityOwner API to transfer the ownership of the current Community to another member within the Community. After the transfer, the original owner will become a regular member.

Warning

Only the Community owner can call this API.

zim.transferCommunityOwner('new_owner_user_id', communityID)
    .then((result: ZIMCommunityOwnerTransferredResult) => {
        // Transferred successfully
    })
    .catch((err: ZIMError) => {
        // Transfer failed
    });

Query Community Member List

Call the queryCommunityMemberList API to retrieve the member list of a specified Community in pages.

Pagination rules are the same as querying the Community list: for the first query, set config.nextFlag to 0, then pass the returned nextFlag to the next request until nextFlag returns 0.

const config: ZIMCommunityMemberListQueryConfig = { nextFlag: 0 };

zim.queryCommunityMemberList(communityID, 100, config)
    .then((result: ZIMCommunityMemberListQueriedResult) => {
        const { memberList, nextFlag } = result;
        // When nextFlag != 0, continue paginated fetching
    })
    .catch((err: ZIMError) => {
        // Query failed
    });

Query Specified Member Information

Call the queryCommunityMembers API to batch query specified users' member information in the Community, including role, mute status, etc.

const userIDs = ['user_1', 'user_2'];

zim.queryCommunityMembers(userIDs, communityID)
    .then((result: ZIMCommunityMembersQueriedResult) => {
        // result.memberList contains the queried member information
    })
    .catch((err: ZIMError) => {
        // Query failed
    });

Mute Members

Call the muteCommunityMembers API to batch set the mute status of specified members in specified Channels within the Community. Mute configuration is passed through ZIMCommunityMemberMuteConfig.

Configuration FieldDescription
channelIDSpecifies the Channel ID where the mute takes effect. Leave blank to apply to all Channels.
durationMute duration (seconds), range 1-2592001 (approximately 30 days), or -1 for permanent mute.
Warning

Only the Community owner and admins can call this API.

const userIDs = ['user_1', 'user_2'];
const config: ZIMCommunityMemberMuteConfig = {
    duration: 3600,
    channelID: 'channel_001',
};

zim.muteCommunityMembers(true, userIDs, communityID, config)
    .then((result: ZIMCommunityMembersMutedResult) => {
        // Mute set successfully
    })
    .catch((err: ZIMError) => {
        // Operation failed
    });

Listen for Member Changes

Member State Changes

When members join or leave a Community, the SDK will trigger the communityMemberStateChanged callback. Use updateInfo.getState() to determine whether a member has entered (ENTERED) or exited (EXITED).

zim.on('communityMemberStateChanged', (zim, result) => {
    for (const updateInfo of result.updateInfoList) {
        if (updateInfo.state === ZIMCommunityMemberChangeState.Entered) {
            // Member joined the Community
        } else if (updateInfo.state === ZIMCommunityMemberChangeState.Exited) {
            // Member left the Community
        }
    }
});

Member Information Updates

When a Community member's nickname, role, mute status, or other information changes, the SDK will trigger the communityMemberInfoUpdated callback.

zim.on('communityMemberInfoUpdated', (zim, result) => {
    for (const updateInfo of result.updateInfoList) {
        const memberInfo = updateInfo.memberInfo;
        // memberInfo.memberRole: member role
        // memberInfo.muteInfo: mute information
    }
});
2026-06-24

Previous

Community management

Next

Channel management