你可以使用此接口向群聊中批量添加群成员。
你可以调用BatchAddConversationParticipant接口,指定你所属的AppId、会话 ID,群成员信息和操作人 UserId 为指定群批量添加群成员。
你无法为单聊添加会话成员。
群聊添加成员上限与你在控制台的设置一致。
若待添加成员已在群聊中,调用此接口会覆盖原有数据,但并不推荐使用该接口进行成员信息更新。
服务端并不会对添加群成员的执行者做预先校验,如判断其是否在群中、是否有权限等。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
QPS 不得超过 50。
使用 POST 方式发起请求。
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | String | 是 | BatchAddConversationParticipant | 接口名称,本接口取值:BatchAddConversationParticipant |
| Version | String | 是 | 2020-12-01 | 接口版本,本接口取值:2020-12-01 |
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| AppId | Int | 是 | 000000 | 应用的唯一标志 |
| ConversationShortId | Int | 是 | 000001 | 会话 ID |
| ParticipantInfos | Array of ParticipantInfo | 是 | / | 群成员信息 |
| Operator | Int | 是 | 000010 | 执行加群操作人的 UserId |
| Barrier | Bool | 否 | false | 是否开启屏障。如设置屏障,新加入用户无法看到历史会话消息。
false。 |
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| ParticipantUserId | Int | 是 | 10001 | 添加成员所属 UserId,UserId 必须大于 0。 |
| Level | Int | 否 | 1 | 成员等级 |
| NickName | String | 否 | Your_NickName | 成员昵称 |
| Role | Int | 否 | 0 | 成员身份,枚举值为 {0,1,2}。
0,值不合法时自动调整为默认值。 |
| Ext | map-key(string)-value(string) | 否 | "key":"value" | 成员扩展字段 |
| ReadIndex | Int | 否 | 0 | 成员已读位置点 |
https://rtc.volcengineapi.com?Action=BatchAddConversationParticipant&Version=2020-12-01
{ "AppId":000000, "ConversationShortId":000001, "Operator":10001, "ParticipantInfos":[ { "ParticipantUserId":10001, "Level":1, "NickName":"Your_NickName", "Role":1, "Ext":{ "key":"value" }, "ReadIndex":0 }, { "ParticipantUserId":10002, "Level":20, "NickName":"NickName2", "Role":0, "Ext":{ "key":"value" }, "ReadIndex":0 } ] }
返回结果参看 BaseResponse。
其中 Result 的结构如下:
| 参数名 | 类型 | 描述 |
|---|---|---|
| FailedUserIds | Array of Int | 成功时为空,失败时返回失败用户 ID |
{ "ResponseMetadata": { "RequestId": "Your_RequestId", "Action": "BatchModifyConversationParticipant", "Version": "2020-12-01", "Service": "rtc", "Region": "cn-north-1" }, "Result": { "FailedUserIds": [] } }