你可以使用此接口创建会话。
你可以调用CreateConversation接口,指定你所属的AppId、会话成员 ID 和会话详细信息进行创建会话。
单聊无法重复创建。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
QPS 不得超过 50。
下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数。
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | String | 是 | CreateConversation | 接口名称。当前 API 的名称为 CreateConversation。 |
| Version | String | 是 | 2020-12-01 | 接口版本。当前 API 的版本为 2020-12-01。 |
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| AppId | Integer | 是 | 000000 | 应用的唯一标志 |
| InboxType | Integer | 否 | 0 | 信箱,用做逻辑隔离 默认值为 0 |
| ConversationCoreInfo | Object of ConversationCoreInfo | 是 | - | 会话详细信息 |
| OwnerUserId | Long | 是 | 10001 | 会话成员 UserId |
| OtherUserId | Long | 否 | 10002 | 另一个成员的 UserId, 创建单聊必填 |
| IdempotentId | String | 否 | "unique-key" | 幂等id,如果创建时指定了此字段,并且数据库中存在此 id 对应的会话,则不会重复创建,并且接口返回的Exist字段为true。 |
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| Name | String | 否 | conversation | 会话名称 |
| AvatarUrl | String | 否 | http://xxx.com | 会话头像 url |
| Description | String | 否 | Your_Description | 会话描述 |
| Notice | String | 否 | Your_Notice | 会话公告 |
| Ext | JSON Map | 否 | "unique-key" | 扩展字段 |
ConversationType | Integer | 是 |
| 会话类型
|
下表仅列出本接口特有的返回参数。更多信息请参见返回结构。
| 参数 | 类型 | 示例值 | 描述 |
|---|---|---|---|
| ConversationShortId | Long | 000001 | 会话id |
| Exist | Boolean | true | 会话是否存在 |
| ConversationInfo | Object of ConversationInfo | - | 会话详细信息 |
| 参数 | 类型 | 示例值 | 描述 |
|---|---|---|---|
| ConversationShortId | Long | 000001 | 会话 ID |
| AppId | Integer | 000000 | 应用的唯一标志 |
| InboxType | Integer | 0 | 信箱,用于逻辑隔离 |
| Name | String | Conversation | 群名 |
| AvatarUrl | String | http://xxx.com | 群头像 url |
| Description | String | Your_Description | 群描述 |
| OwnerUserId | Long | 100001 | 群主 UserId |
| CreatorUserId | Long | 100001 | 创群人 UserId |
| Notice | String | Your_Notice | 群公告 |
Status | Integer |
| 会话状态。
|
| Ext | JSON Map | {"key":"value"} | 会话的扩展字段。 |
| CreateTime | Long | 1666598278 | 群聊创建时间戳,单位为秒 |
| ModifyTime | Long | 1666598278 | 修改时间戳,单位为秒 |
ConversationType | Integer |
| 会话类型。
|
| MemberCount | Long | 2 | 会话成员数 |
| OnlineCount | Long | 2 | 直播群在线人数 |
| OtherUserId | Long | 10002 | 单聊另一个成员的 UserId |
POST https://rtc.volcengineapi.com?Action=CreateConversation&Version=2020-12-01
{
"AppId": 000000,
"InboxType": 0,
"ConversationCoreInfo": {
"Name": "Conversation",
"AvatarUrl": "http://xxx.xxx",
"Description": "Your_Description",
"Notice": "Your_Notice",
"Ext": {
"key": "value"
},
"ConversationType": 2
},
"OwnerUserId": 10001
}
json{
"ResponseMetadata": {
"RequestId": "Your_RequestId",
"Action": "CreateConversation",
"Version": "2020-12-01",
"Service": "rtc",
"Region": "cn-north-1"
},
"Result": {
"ConversationShortId": 000001,
"Exist": true,
"ConversationInfo": {
"ConversationShortId": 000001,
"AppId": 000000,
"InboxType": 0,
"Name": "Conversation",
"AvatarUrl": "http://xxx.xxx",
"Description": "Your_Description",
"OwnerUserId": 100001,
"CreatorUserId": 100001,
"Notice": "Your_Notice",
"Status": 0,
"Ext": {
"key": "value"
},
"CreateTime": 1666598278,
"ModifyTime": 1666598278,
"ConversationType": 1,
"MemberCount": 2,
"OnlineCount": 2,
"OtherUserId": 10002
}
}
}
json您可访问公共错误码,获取更多错误码信息。