Browse SDKs · WASM
SDKsWASM

Create a group

Create a group with an initial owner, administrators, and members.

Copy

createGroup() accepts a group profile together with initial members, administrators, and owner settings.

Parameters

ParameterTypeRequiredDescription
memberUserIDsstring[]YesInitial member user IDs.
adminUserIDsstring[]NoInitial administrator user IDs.
ownerUserIDstringNoGroup owner user ID. Defaults to the current user when omitted.
groupInfoPartial<GroupItem>YesInitial group profile.
groupInfo.groupNamestringNoGroup name. Provide it when creating a group that will be displayed.
groupInfo.groupTypeGroupTypeNoGroup type. Use GroupType.WorkingGroup for a normal group chat.
groupInfo.faceURLstringNoGroup avatar URL.

Members, administrators, and the owner must not overlap. Deduplicate the lists and check their intersections before calling the SDK.

import { GroupType } from '@openim/wasm-client-sdk';

const { data: group } = await openimsdk.createGroup({
  memberUserIDs: ['user-003', 'user-004'],
  adminUserIDs: ['user-002'],
  ownerUserID: currentUserID,
  groupInfo: {
    groupName: 'Project discussion',
    groupType: GroupType.WorkingGroup,
    faceURL: 'https://example.com/group.png',
  },
});

Return result

After the Promise succeeds, data is the new group's GroupItem. Use groupID, groupName, and faceURL immediately to open the group profile or group chat page. See Get joined groups by page for complete fields.

Merge joined-group list increments through OnJoinedGroupAdded; see Group overview for the complete listener.