创建房间
更新时间: 2025/11/11 15:59:05
本文介绍如何调用服务端接口创建房间。与客户端创建房间的接口相比,使用服务端接口可以方便您在业务系统中保存房间信息、更好地管理和跟踪房间信息。通过使用该服务端接口,可以提高业务效率。
创建的房间默认最高可以容纳 500 位用户同时在线。如果您需要提高房间内在线用户人数限制,请联系您的网易云信客户经理或 提交工单 联系网易云信技术支持工程师,最高限制为 2000 人。
请求信息
请求 URI
POST https://{endpoint}/neroom/v4/rooms
- {endpoint} 为 NERoom 接入地址的域名,默认为
roomkit.yunxinapi.com。如果您的应用主要服务于海外用户,请将域名设置为海外数据中心域名(roomkit-sg.yunxinapi.com)。 - Content-Type:application/json
请求头参数
请求 Header 的设置请参考 请求结构。
请求体参数
| 参数名称 | 类型 | 是否必选 | 示例 | 说明 |
|---|---|---|---|---|
| template_id | Long | 是 | 23 | 模板 ID,模板 ID 获取方法请参考 如何获取模板 ID。 |
| room_uuid | String | 否 | NE****10 | 房间 ID,最大长度 64 个字符,传空值,则随机生成一个房间 ID。支持以下字符类型:
|
| room_name | String | 是 | Example | 房间名,最大长度为 64 个字符。支持以下字符类型:
|
| password | String | 否 | Example123456 | 房间密码,最大长度为 64 个字符。支持以下字符类型:
|
| host_user_uuid | String | 是 | user01 | 房主的 userUuid(已注册的 userUuid) |
| type | Integer | 否 | 1 | 房间类型。 |
| - config | Object | 否 | - | 配置待创建的 NERoom 房间开启哪些功能,不配置则使用模板中的配置 |
| whiteboard | Boolean | 否 | true | 设置该房间是否包含白板功能。 |
| chatroom | Boolean | 否 | true | 设置该房间是否包含聊天室功能。 |
| rtc | Boolean | 否 | true | 设置该房间是否包含音视频功能。 |
| sip | Boolean | 否 | true | 设置该房间是否开启 sip。 |
| record | Boolean | 否 | true | 设置该房间是否开启录制。 |
| - live | Object | 否 | - | 该房间直播组件配置,不配置则根据模板配置来决定是开启还是关闭 |
| enable | Boolean | 是 | true | 设置该房间是否包含直播功能。 |
| push_url | String | 否 | rtmp://sample.live.net/live/b54*** | 推流地址。最大长度支持 512 字节。 |
| pull_hls_url | String | 可选,但必须至少选择其中一种拉流地址 | http://sample.live.net/live/34a***/playlist.m3u8 | hls 拉流地址。最大长度支持 512 字节。 |
| pull_rtmp_url | String | rtmp://sample.live.net/live/451*** | rtmp 拉流地址。最大长度支持 512 字节。 | |
| pull_http_url | String | http://sample.live.net/live/b5r***.flv?sample.live.net | http 拉流地址。最大长度支持 512 字节。 | |
| pull_rts_url | String | rtmp://sample.live.net/live/a27*** | rts 拉流地址。最大长度支持 512 字节。 | |
| - seat | Object | 否 | - | 设置是否开启麦位管理,不配置则根据模板配置来决定是开启还是关闭 |
| enable | Boolean | 是 | true | 设置该房间是否使用麦位组件。 |
| seat_count | Integer | 是 | 8 | 麦位的数量。默认为 8。最多 20 个麦位。 |
| apply_mode | Integer | 否 | 0 | 麦位申请审批模式。
|
| invite_mode | Integer | 否 | 0 | 麦位邀请确认模式。
|
| ext | String | 否 | custom | 您自定义的扩展信息,最大长度为 2048 个字符。 |
请求体示例
Java
{
"template_id": 40,
"room_uuid": "8978634332",
"room_name": "Example",
"host_user_uuid":"user01",
"type":2,
"room_profile":1,
"password": "Example123456",
"config":
{
"whiteboard": true,
"chatroom": true,
"rtc": true,
"sip": true,
"record": true,
"live":
{
"enable": true,
"push_url": "***",
"pull_hls_url": "***",
"pull_rtmp_url": "**",
"pull_http_url": "***",
"pull_rts_url": "***"
},
"seat":
{
"enable": true,
"seat_count": 8,
"apply_mode": 1,
"invite_mode": 0
}
}
}
响应信息
响应体参数
| 参数名称 | 类型 | 示例 | 说明 |
|---|---|---|---|
| code | int | 0 | 状态码,0 表示成功,具体请参考 错误码。 |
| msg | String | Success | 业务结果描述,Success 表示成功。 |
| ts | Long | 1648021056815 | NERoom 服务器处理该请求的完成时间。该时间为 Unix 时间戳,即从 1970 年 1 月 1 日 0 点 0 分 0 秒开始到现在的秒数。 |
| request_id | String | 7c4b6d9c3e9d42*****cc6e3a4d995 | 请求的唯一标识。 |
| cost | String | 48ms | 处理该请求所消耗的时间。 |
| - data | Object | - | 创建房间的结果 |
| room_archive_id | String | 4***251 | 归档到历史记录中的房间 ID,全局唯一,最大长度 36 个字符。 |
| - room_resource_info | Object | - | 房间的资源配置信息。 |
| chat_room_id | Number | 4***251 | 归档到历史记录中的聊天室房间 ID,全局唯一。 |
| - live_config | Object | - | 该房间直播组件配置。 |
| push_url | String | rtmp://sample.live.net/live/b54*** | 推流地址。最大长度支持 512 字节。 |
| pull_hls_url | String | http://sample.live.net/live/34a***/playlist.m3u8 | hls 拉流地址。最大长度支持 512 字节。 |
| pull_rtmp_url | String | rtmp://sample.live.net/live/451*** | rtmp 拉流地址。最大长度支持 512 字节。 |
| pull_http_url | String | http://sample.live.net/live/b5r***.flv?sample.live.net | http 拉流地址。最大长度支持 512 字节。 |
响应体示例
JSON{
"code": 0,
"msg": "Success",
"ts": 1619068087795,
"request_id": "6e507107d1f4447ea731f651dc6d2432",
"cost": "66ms",
"data": {
"room_archive_id": "4***251",
"room_resource_info": {
"chat_room_id": 4***251,
"live_config": {
"push_url": "rtmp://sample.live.net/live/b54***",
"pull_hls_url": "http://sample.live.net/live/34a***/playlist.m3u8",
"pull_rtmp_url": "rtmp://sample.live.net/live/451***",
"pull_http_url": "http://sample.live.net/live/b5r***.flv?sample.live.net"
}
}
}
}
错误码
| 错误码 | 错误信息 | 说明 | 处理建议 |
|---|---|---|---|
| 0 | Success | 请求成功 | 无需处理 |
| 400 | Invalid parameter. | 参数错误 | 检查接口传参 |
| 409 | Target already exists. | 房间号已经存在 | 更换 room_uuid |
| 1005 | Config does not exist. | 模板不存在 | 检查模板 ID |
相关接口
| 接口 | 描述 |
|---|---|
| 关闭房间 | 关闭房间 |
此文档是否对你有帮助?




