logo
In-app Chat
Powered Byspreading
On this page

Add group members


Overview

You can call this operation to batch add up to 100 users to a specified group chat. If you need a higher limit, contact ZEGOCLOUD technical support.

After users are added, all group members, including newly added ones, receive the notification in the following ZIM SDK callbacks.

iOSAndroidmacOSWindows
groupMemberStateChangedonGroupMemberStateChangedgroupMemberStateChangedonGroupMemberStateChanged
WebFlutterUnity3DReact Native
groupMemberStateChangedonGroupMemberStateChangedOnGroupMemberStateChangedgroupMemberStateChanged

Operation prototype

  • Request method: POST
  • Request URL: https://zim-api.zego.im/?Action=InviteUsersIntoGroup
  • Protocol: HTTPS
  • QPS limit: 1 call per second, applicable to group chats only. If you need a higher limit, contact ZEGOCLOUD technical support.

Request parameters

The following table describes only the operation-specific request parameters and some common request parameters. For the complete list of common request parameters, see the Public request parameters section of the Accessing Server APIs topic.

Parameter TypeRequiredDescription
FromUserIdStringYesOperator user ID. Users need to have registered for the ZIM service.
GroupIdStringYesGroup ID.
UserIdsArray of StringYes

List of user IDs to join the group. By default, a maximum of 100 user IDs are supported.

Note
  • If the array includes an element the same as the FromUserId, the element will be deleted.
  • This parameter has the same effect as GroupMemberInfos, just choose one of the two.
  • This parameter is only valid when GroupMemberInfos length is 0.
GroupMemberInfosArray of ObjectYesList of user information that joins the group. By default, it supports a maximum of 100 user information.
└UserIdStringYesThe ID of the user joining the group.
Note
If the value is the same as the FromUserId, it will be deleted.
└EnterGroupTimeNumberNo

Group entry timestamp (millisecond level).

  • 0 or not passed: use the current timestamp.
  • Other: cannot be greater than the current time.
└IsInviteNumberNo

The user's group joining mode.

  • 0: (Default) Invite users to directly add them to the group without their consent.
  • 1: After receiving the invitation, the user needs to agree to join the group.
Note

The FromUserId, GroupId, and UserIds parameters can contain only digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', ', ', '|', '~'.

Sample request

  • Request URL
Untitled
https://zim-api.zego.im/?Action=InviteUsersIntoGroup
&<Common request parameters>
1
Copied!
  • Request body
Untitled
{
    "FromUserId": "zego_user",
    "GroupId": "groupA",
    "UserIds": [
        "usera",
        "userb"
    ]
}
1
Copied!

Response parameters

ParameterTypeDescription
CodeNumberThe return code.
MessageStringThe description of the operation result.
RequestIdStringThe request ID.
ErrorListArray of Object

The list of failed results.

  • If Code is 0:

    • If ErrorList is empty, all specified users are successfully added.
    • If ErrorList is not empty, some specified users fail to be added. In this case, see SubCode.
  • If Code is not 0:

    • If ErrorList is empty, one or more parameters are invalid, the QPS limit is exceeded, or a system error occurs.
    • If ErrorList is not empty, all specified users fail to be added.
└UserIdStringThe ID of the user who fails to be added.
└SubCodeNumberThe code returned when the request fails.

Sample response

Untitled
{
    "FromUserId": "zego_user",
    "GroupId": "groupA",
    "GroupMemberInfos": [
        {
            "UserId": "user_a",
            "EnterGroupTime": 123
        },
        {
            "UserId": "user_b",
            "EnterGroupTime": 0
        }
    ]
}
1
Copied!

Return codes

The following table describes only the return codes related to the business logic of the operation. For the complete list of return codes, see Return codes.

Return CodeDescriptionSolution
660000002Invalid parameter.Check the input parameter.
660300006The QPS limit is exceeded.Please try again later, or check the QPS limit.
660500002The operator is not registered.Register the operator.
660600001The group chat does not exist.Check whether the value of the GroupID parameter is valid.
660000011Too many users are included in the list.Check the number of users.

Previous

Transfer the group ownership

Next

Set nicknames of group members