Create a user group

POST https://chat.fhir.org/api/v1/user_groups/create

Create a new user group.

Usage examples

#!/usr/bin/env python3

import zulip

# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")

request = {
    "name": "leadership",
    "description": "The leadership team.",
    "members": user_ids,
}
result = client.create_user_group(request)
print(result)

curl -sSX POST https://chat.fhir.org/api/v1/user_groups/create \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY \
    --data-urlencode name=marketing \
    --data-urlencode 'description=The marketing team.' \
    --data-urlencode 'members=[1, 2, 3, 4]' \
    --data-urlencode 'subgroups=[11]' \
    --data-urlencode can_add_members_group=11 \
    --data-urlencode can_join_group=11 \
    --data-urlencode can_leave_group=15 \
    --data-urlencode can_manage_group=11 \
    --data-urlencode can_mention_group=11

Parameters

name string required

Example: "marketing"

The name of the user group.


description string required

Example: "The marketing team."

The description of the user group.


members (integer)[] required

Example: [1, 2, 3, 4]

An array containing the user IDs of the initial members for the new user group.


subgroups (integer)[] optional

Example: [11]

An array containing the IDs of the initial subgroups for the new user group.

User can add subgroups to the new group irrespective of other permissions for the new group.

Changes: New in Zulip 10.0 (feature level 311).


can_add_members_group integer | object optional

Example: 11

A group-setting value defining the set of users who have permission to add members to this user group.

Changes: New in Zulip 10.0 (feature level 305). Previously, this permission was controlled by the can_manage_group setting.

This parameter must be one of the following:

  1. The ID of the user group with this permission.

  2. An object with the following fields:

    • direct_members: (integer)[]

      The list of IDs of individual users in the collection of users with this permission.

      Changes: Prior to Zulip 10.0 (feature level 303), this list would include deactivated users who had the permission before being deactivated.

    • direct_subgroups: (integer)[]

      The list of IDs of the groups in the collection of users with this permission.


can_join_group integer | object optional

Example: 11

A group-setting value defining the set of users who have permission to join this user group.

Changes: New in Zulip 10.0 (feature level 301).

This parameter must be one of the following:

  1. The ID of the user group with this permission.

  2. An object with the following fields:

    • direct_members: (integer)[]

      The list of IDs of individual users in the collection of users with this permission.

      Changes: Prior to Zulip 10.0 (feature level 303), this list would include deactivated users who had the permission before being deactivated.

    • direct_subgroups: (integer)[]

      The list of IDs of the groups in the collection of users with this permission.


can_leave_group integer | object optional

Example: 15

A group-setting value defining the set of users who have permission to leave this user group.

Changes: New in Zulip 10.0 (feature level 308).

This parameter must be one of the following:

  1. The ID of the user group with this permission.

  2. An object with the following fields:

    • direct_members: (integer)[]

      The list of IDs of individual users in the collection of users with this permission.

      Changes: Prior to Zulip 10.0 (feature level 303), this list would include deactivated users who had the permission before being deactivated.

    • direct_subgroups: (integer)[]

      The list of IDs of the groups in the collection of users with this permission.


can_manage_group integer | object optional

Example: 11

A group-setting value defining the set of users who have permission to manage this user group.

This setting cannot be set to "role:internet" and "role:everyone" system groups.

Changes: New in Zulip 10.0 (feature level 283).

This parameter must be one of the following:

  1. The ID of the user group with this permission.

  2. An object with the following fields:

    • direct_members: (integer)[]

      The list of IDs of individual users in the collection of users with this permission.

      Changes: Prior to Zulip 10.0 (feature level 303), this list would include deactivated users who had the permission before being deactivated.

    • direct_subgroups: (integer)[]

      The list of IDs of the groups in the collection of users with this permission.


can_mention_group integer | object optional

Example: 11

A group-setting value defining the set of users who have permission to mention this user group.

This setting cannot be set to "role:internet" and "role:owners" system groups.

Before Zulip 9.0 (feature level 258), this parameter could only be the integer form of a group-setting value.

Before Zulip 8.0 (feature level 198), this parameter was named can_mention_group_id.

New in Zulip 8.0 (feature level 191). Previously, groups could be mentioned only if they were not system groups.

This parameter must be one of the following:

  1. The ID of the user group with this permission.

  2. An object with the following fields:

    • direct_members: (integer)[]

      The list of IDs of individual users in the collection of users with this permission.

      Changes: Prior to Zulip 10.0 (feature level 303), this list would include deactivated users who had the permission before being deactivated.

    • direct_subgroups: (integer)[]

      The list of IDs of the groups in the collection of users with this permission.


Response

Return values

  • group_id: integer

    The unique ID of the created user group.

Example response(s)

Changes: As of Zulip 7.0 (feature level 167), if any parameters sent in the request are not supported by this endpoint, a successful JSON response will include an ignored_parameters_unsupported array.

A typical successful JSON response may look like:

{
    "group_id": 123,
    "msg": "",
    "result": "success"
}

An example JSON error response for when the one of the users does not exist:

{
    "code": "BAD_REQUEST",
    "msg": "Invalid user ID: 500",
    "result": "error"
}