Create a chat room

Update time: 2022/12/13 08: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

httpPOST  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:

ParameterTypeRequiredDescription
creator StringYes The accid of the creator, up to 32 characters
name StringYes The name of a chat room, up to 128 characters
announcement StringNoAnnouncement in a chat room, up to 4,096 characters
broadcasturl StringNo URL for live streaming, up to 1,024 characters
ext StringNo The extension field, up to 4,096 characters
queuelevel IntegerNo 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 StringNo Content moderation ID in JSON, {"textbid": "", "picbid": ""}. If unspecified, the original content moderation configuration is applied.
delayClosePolicy IntegerNo 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 LongNo The timer to close the chat room.
If you set delayClosePolicy=1 or 2 without a specific period of time, the default value (7*24*3600s) is applied

Response parameters

ParameterTypeDescription
code IntegerStatus code
roomid LongChat room ID
valid Booleanfalse: close a chat room, true: open a chat room
announcement StringAnnouncement in a chat room
name StringThe name of a chat room
broadcasturl StringURL for live streaming
ext StringExtension 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 BooleanWhether the chat room is all muted. Only administrators and creators can speak if a chat room is all muted. false: unmuted, true: muted
creator StringID of the creator
delayInfo StringTimer info
delayCloseEnable BooleanWhether a timer is enabled, true: enabled, false: disabled
delayClosePolicyIntegerMethod 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 IntegerCurrent status, 1: The task starts in the initial state, 2: waiting state, 3: task completion state, 4: task canceled< /td>
startTimeLong Timestamp of the start time

Example

cURL request

curlcurl -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

json"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

json"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 page helpful?
Yes
No
  • Request URL
  • Request parameters
  • Response parameters
  • Example
  • cURL request
  • Example success response
  • Example error response
  • Status codes