Roles

Roles are assigned to each user created in CometChat. default role is assigned to the user by default if the role is not provided explicitly.

The following table lists the properties that the Role API supports.

Parameters

Type

Description

role

string

  • (mandatory)_ Specifies role's unique ID. Maximum length is 100 characters.
    Allowed characters: alpha-dash (a-z, 0-9 with -and _ ) without spaces

name

string

  • (mandatory)_ Specifies the role's name.
    Maximum length is 100 characters.

description

string

  • (optional)_ Specifies the description of the user.
    If left empty, no description is set for the role.
    Maximum length is 255 characters.

metadata

nested object

  • (optional)_ Specifies a JSON object to store up to 1.6K characters (JSON stringified metadata) for additional role information.

settings

array

  • (optional)_ Role settings that is used for restricting list users/send message API.
    Possible values for listUsers & sendMessagesTo are all and friendsOnly

settings.listUsers

string

  • (optional)_ Restricts users listing to either all OR friendsOnly for all users with this role.
    possible values: all, friendsOnly

settings.sendMessagesTo

string

Restricts sending message to either all OR friendsOnly for all users with this role.
possible values: all, friendsOnly