Create a room
Description
Developers can call this interface to create a room, and support setting custom room attributes when creating a room. A room can set up to 20 room attributes. If you need to increase the upper limit of the number of room attributes, please contact ZEGOCLOUD Technical Support.
Request method and endpoint
- Request method: POST
- Request URL:
https://zim-api.zego.im/?Action=CreateRoom
- Transmission protocol: HTTPS
- QPS limit: 20 requests/second
Request parameters
The following table describes only the operation-specific request parameters and some common request parameters. For the complete list of common request parameters, see the Common request parameters section of the Accessing Server APIs topic.
Parameter | Type | Required | Description |
---|---|---|---|
FromUserId | String | Yes | The operator, which needs to be in the registered state. This user will not be automatically added to the room. Only numbers, English characters, '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', ' ', ', ', '|', '~' are supported. |
RoomId | String | Yes | Room ID. Only numbers, English characters, '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', ' ', ', ', '|', '~' are supported. |
RoomName | String | No | Room name. The maximum length is 64 bytes. |
DestroyDelayTime | Number | No | The room delay destruction time when the number of room users is 0, in seconds. The maximum room delay destruction time is 10800 seconds by default. |
Attributes | Array of CreateRoomAttribute | No | The attribute information to be added. |
CreateRoomAttribute structure:
Parameter | Type | Required | Description |
---|---|---|---|
Key | String | Yes | Room attribute key. |
Value | String | Yes | Room attribute value. |
AutoDelete | Number | No | Whether to automatically delete when the user exits the room, 0: not automatically delete, 1: automatically delete. When creating a room, FromUserId will not be added to the room, only when it enters the room first and then exits the room, the deletion operation will be triggered. |
Request example
- Request URL:
https://zim-api.zego.im/?Action=CreateRoom
&<Common request parameters>
- Request body:
{
"FromUserId": "User1",
"RoomId": "Room1",
"RoomName":"RoomName1",
"DestroyDelayTime":3600,
"Attributes": [
{
"Key":"k1",
"Value":"v1",
"AutoDelete": 0
},
{
"Key":"k2",
"Value":"v2",
"AutoDelete": 1
}
]
}
Response parameters
The response parameters are as follows:
Parameter | Type | Required | Description |
---|---|---|---|
Code | int32 | Yes | Return status code (0 means success). |
Message | string | Yes | Return status information. |
RequestId | string | Yes | Request unique identifier. |
Response example
{
"Code": 0,
"Message": "success",
"RequestId": "req-123456789",
}
Return codes
The following return codes are only listed for interface business logic. For the complete list of return codes, see Global return codes.
Return code | Description | Solution |
---|---|---|
660000002 | Parameter error. | Please check the parameters. |
660300005 | Frequency limit. | Please try again later. |
660300014 | Room already exists. | Check if the room has been created. |
660300015 | Room number exceeds the upper limit. | Check if the room number exceeds the upper limit, or contact technical support to expand. |