groups.create()

This method allows you to create a new private group with the specified members and the current user.

If you are creating a public forum, please use client.forums.create() instead.

Definition

client.groups.create(
options: ?Object
):Promise<Group,Error>

Parameters

ParameterTypeDescription
options?ObjectOptions (described below)

Options

ParameterTypeDescription
avatarFileFileAn avatar file object
description?stringThe group description
memberIdsArray<string|User>A list of user models or user IDs to add to the group once it is created
metadata?ObjectOptional metadata for the group
namestringThe group name
organizationIdstringThe organization in which the group should be created
replayHistory?boolIndicates whether replay history is desired (default: false for private groups)
senderId?stringID of the role or user who is creating the group (default: current user)

Returns

An error will be thrown if any of the arguments are invalid.

Otherwise, once the returned Promise is resolved, you will have access to the newly created Group.

Example

const group = await client.groups.create({
organizationId: 'some-org-id',
name: 'New group name',
memberIds: [
'some-user-id-1',
'some-user-id-2',
'some-user-id-3'
]
});
console.log(
'created new group:',
group.displayName,
'with members',
group.members
.map(function(user) {
return user.displayName;
})
.join(', ')
);