Batch register users
Overview
You can call this operation to batch register ZEGOCLOUD Instant Messaging (ZIM) accounts for users in the backend, so that they can log in to ZIM and receive historical messages. This operation is applicable to education scenarios.
QPS limit: 20 calls per second
Operation prototype
- Request method: POST
- Request URL:
https://zim-api.zego.im/?Action=UserRegister
- Protocol: HTTPS
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 Public request parameters section of the Accessing Server APIs topic.
Parameter | Type | Required | Description |
---|---|---|---|
UserInfo | Array of Object | Yes | The user information. Up to 100 users can be registered at a time. |
└UserId | String | Yes | The user ID, which cannot exceed 32 bytes in length. |
└UserName | String | No | The username, which cannot exceed 64 bytes in length. |
└UserAvatar | String | No | The URL of the user avatar, which cannot exceed 500 bytes in length. |
The UserID
, UserName
, and UserAvatar
parameters can contain only digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', ', ', '|', '~'.
Sample request
-
Request URL:
Untitledhttps://zim-api.zego.im/?Action=UserRegister &<Common request parameters>
1 -
Request body:
Untitled{ "UserInfo":[ { "UserId": "aaa", "UserName": "userNamea", "UserAvatar": "http" }, { "UserId": "bbb", "UserName": "userNameb", "UserAvatar": "http" } ] }
1
Response parameters
Parameter | Type | Description |
---|---|---|
Code | Number | The return code. Note When you request to batch register users, take note of the following items:
|
Message | String | The description of the request result. |
RequestId | String | The request ID. |
ErrorList | Array of Object | The list of failed results.
|
└UserID | String | The user ID that fails to be registered. |
└SubCode | Number | The code returned when the request fails. |
└SubMessage | String | The error message. |
Sample response
{
"Code":0, // If one or more user IDs are successfully registered, 0 is returned. For more information, see ErrorList.
"Message":"success",
"RequestId":"343649807833778782",
"ErrorList": [
{
"UserId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"SubCode": 660000012,
"SubMessage":"user length limit"
}
]
}
Return codes
The following table describes only the return codes related to the business logic of the operation. For the complete list of return codes, see Return codes.
Return Code | Description | Possible Reason | Solution |
---|---|---|---|
660000001 | A common service error occurred. | A server error occurred. | Try again, or contact ZEGOCLOUD technical support. |
660000002 | Invalid parameter. | The input parameter is invalid or not specified. | Check the input parameter. |
660000012 | The length of the UserID parameter exceeds the limit. | The UserID parameter cannot exceed 32 bytes in length. | Make sure that the UserID parameter does not exceed 32 bytes in length. |
660700001 | Too many requests are sent. | More than 20 requests are sent per second. | Try again later. |
660700002 | The user already exists. | The ID of the user specified in the request has already been registered. | Make sure that the user ID has not been registered before. |
660700006 | The length of the UserName parameter exceeds the limit. | The UserName parameter cannot exceed 64 bytes in length. | Make sure that the UserName parameter does not exceed 64 bytes in length. |
660700007 | The length of the UserAvatar parameter exceeds the limit. | The UserAvatar parameter cannot exceed 500 bytes in length. | Make sure that the UserAvatar parameter does not exceed 500 bytes in length. |