你可以使用此接口创建会话。
你可以调用CreateConversation接口,指定你所属的AppId、会话成员 ID 和会话详细信息进行创建会话。
单聊无法重复创建。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
QPS 不得超过 50。
使用 POST 方式发起请求。
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | String | 是 | CreateConversation | 接口名称,本接口取值:CreateConversation |
| Version | String | 是 | 2020-12-01 | 接口版本,本接口取值:2020-12-01 |
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| AppId | Int | 是 | 000000 | 应用的唯一标志 |
| OwnerUserId | Int | 是 | 10001 | 会话成员 UserId |
| OtherUserId | Int | 否 | 10002 | 另一个成员的 UserId, 创建单聊必填 |
| InboxType | Int | 否 | 0 | 信箱,用做逻辑隔离。默认值为 0 |
| IdempotentId | String | 否 | "unique-key" | 幂等id,如果创建时指定了此字段,并且数据库中存在此 id 对应的会话,则不会重复创建,并且接口返回的Exist字段为true。 |
| ConversationCoreInfo | ConversationCoreInfo | 是 | 会话详细信息 |
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Name | String | 否 | conversation | 会话名称 |
| AvatarUrl | String | 否 | http://xxx.com | 会话头像 url |
| Description | String | 否 | Your_Description | 会话描述 |
| Notice | String | 否 | Your_Notice | 会话公告 |
| Ext | map-key(string)-value(string) | 否 | "unique-key" | 扩展字段 |
| ConversationType | Int | 是 | 1 | 会话类型
|
https://rtc.volcengineapi.com?Action=CreateConversation&Version=2020-12-01
postscript{
"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返回结果参看 BaseResponse。
其中 Result 的结构如下:
| 参数名 | 类型 | 描述 |
|---|---|---|
| ConversationShortId | Int | 会话id |
| Exist | Bool | 会话是否存在 |
| ConversationInfo | ConversationInfo | 会话详细信息 |
{
"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