Instant Messaging
Create a chat room
Update time: 2022/12/13 16:25:31
Chat rooms apply a multi-layer architecture design that can handle large-scale workloads with an unlimited number of participants. Chat rooms are suitable for live streaming activities in entertainment and education.
- The chat room is a paid extension capability that is available after you upgrade from IM Basic to IM Pro.
- You can create a chat room only by calling the corresponding Server API.
Create a chat room
Request URL
POST https://api.netease.im/nimserver/chatroom/create.action HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=utf-8
Request parameters
-
For the setting of Headers in POST requests, see API Calling.
-
The settings of the body in a POST request:
Parameter | Type | Required | Description |
---|---|---|---|
creator | String | Yes | The accid of the creator, up to 32 characters |
name | String | Yes | The name of a chat room, up to 128 characters |
announcement | String | No | Announcement in a chat room, up to 4,096 characters |
broadcasturl | String | No | URL for live streaming, up to 1,024 characters |
ext | String | No | The extension field, up to 4,096 characters |
queuelevel | Integer | No | Queue management permission. 0: All participants have the permission to change a queue, 1: Only hosts and administrators have the permission to change a queue. The default value is 0. |
bid | String | No | Content moderation ID in JSON, {"textbid": "", "picbid": ""}. If unspecified, the original content moderation configuration is applied. |
delayClosePolicy | Integer | No |
Timer option. 0: no timer, 1: set a timer to close the chat room regardless of whether participants exist in the chat room, 2: set a timer to close the chat room when no participants exist in the chat room |
delaySeconds | Long | No |
The timer to close the chat room. |
Response parameters
Parameter | Type | Description | |
---|---|---|---|
code | Integer | Status code | |
roomid | Long | Chat room ID | |
valid | Boolean | false: close a chat room, true: open a chat room | |
announcement | String | Announcement in a chat room | |
name | String | The name of a chat room | |
broadcasturl | String | URL for live streaming | |
ext | String | Extension field | |
queuelevel | Integer | Queue management permission. 0: All participants have the permission to change a queue, 1: Only hosts and administrators have the permission to change a queue | |
muted | Boolean | Whether the chat room is all muted. Only administrators and creators can speak if a chat room is all muted. false: unmuted, true: muted | |
creator | String | ID of the creator | |
delayInfo | String | Timer info | |
delayCloseEnable | Boolean | Whether a timer is enabled, true: enabled, false: disabled | |
delayClosePolicy | Integer | Method to close a chat room. 0: no timer, 1: close a chat room when the timer ends, 2: close a chat room if no participants exist in the chat room | |
delaySeconds | Long | Timer period. The maximum period (7*24*3600s) | |
status | Integer | Current status, 1: The task starts in the initial state, 2: waiting state, 3: task completion state, 4: task canceled< /td> | |
startTime | Long | Timestamp of the start time |
Example
cURL request
curl -X POST -i 'https://api.netease.im/nimserver/chatroom/create.action' -H "Nonce: 12345" -H "CheckSum: eaaf8dc8d6e748f8661445efa62cefa8ce3ccf73" -H "AppKey: 2bd025c577313e81b2bdb2d2dcefcadb" -H "CurTime: 1666595100" -d 'creator=test100&name=test1-chatroom&delayClosePolicy=1&delaySeconds=180&announcement=&broadcasturl=xxxxxx'
Example success response
"Content-Type": "application/json; charset=utf-8"
{
"code": 200,
"chatroom": {
"valid": true,
"ext": "",
"creator": "test100",
"name": "test1-chatroom",
"muted": false,
"announcement": null,
"broadcasturl": "xxxxxx",
"roomid": 1600849145,
"queuelevel": 0,
"delayInfo": {
"delaySeconds": 180,
"delayCloseEnable": true,
"startTime": 1666595100158,
"delayClosePolicy": 1,
"status": 2
}
}
}
Example error response
"Content-Type": "application/json; charset=utf-8"
{
"code": 414,
"desc": "owner not registered"
}
Status codes
The following status codes are related to responses of this API. For more status codes, see Status codes.
Status code | Description | Recommendation |
---|---|---|
200 | Success | - |
414 | Parameter error | Check the format and restrictions of arguments based on the error message |
403 | Forbidden operation | The chat room name failed to pass the moderation or the chat room permission is not granted |
419 | The number of chat rooms exceeds the upper limit | - |
13009 | The timer for closing a chat room is disabled | It is recommended to enable the timer |
Was this topic helpful?
Yes
No