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
Parameter | Type | Description |
---|---|---|
options | ?Object | Options (described below) |
Options
Parameter | Type | Description |
---|---|---|
avatarFile | File | An avatar file object |
description | ?string | The group description |
memberIds | Array<string |User> | A list of user models or user IDs to add to the group once it is created |
metadata | ?Object | Optional metadata for the group |
name | string | The group name |
organizationId | string | The organization in which the group should be created |
replayHistory | ?bool | Indicates whether replay history is desired (default: false for private groups) |
senderId | ?string | ID 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(', '));