logo
In-app Chat
Powered Byspreading
On this page

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.

ParameterTypeRequiredDescription
UserInfoArray of ObjectYesThe user information. Up to 100 users can be registered at a time.
└UserIdStringYesThe user ID, which cannot exceed 32 bytes in length.
└UserNameStringNoThe username, which cannot exceed 64 bytes in length.
└UserAvatarStringNoThe URL of the user avatar, which cannot exceed 500 bytes in length.
Note

The UserID, UserName, and UserAvatar parameters can contain only digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', ', ', '|', '~'.

Sample request

  • Request URL:

    Untitled
    https://zim-api.zego.im/?Action=UserRegister
    &<Common request parameters>
    
    1
    Copied!
  • Request body:

    Untitled
    {
        "UserInfo":[
      	{
        	"UserId": "aaa",
            "UserName": "userNamea",
        	"UserAvatar": "http"
      	},
      	{
        	"UserId": "bbb",
            "UserName": "userNameb",
        	"UserAvatar": "http"
      	}
        ]
    }
    
    1
    Copied!

Response parameters

ParameterTypeDescription
CodeNumberThe return code.
Note
When you request to batch register users, take note of the following items:
  • If one or more user IDs are successfully registered, 0 is returned. For more information, see ErrorList.
  • If all user IDs fail to be registered, a corresponding code is returned. For more information, see Return codes.
MessageStringThe description of the request result.
RequestIdStringThe request ID.
ErrorListArray of Object

The list of failed results.

  • If Code is 0:

    • If ErrorList is empty, all user IDs are successfully registered.
    • If ErrorList is not empty, some user IDs fail to be registered. In this case, see SubCode.
  • If Code is not 0:

    • If ErrorList is empty, one or more parameters are invalid, the QPS limit is exceeded, or a system error occurs.
    • If ErrorList is not empty, all user IDs fail to be registered, indicating that all of them have been registered.
└UserIDStringThe user ID that fails to be registered.
└SubCodeNumberThe code returned when the request fails.
└SubMessageStringThe error message.

Sample response

Untitled
{
    "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"
       }
     ] 
}
1
Copied!

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 CodeDescriptionPossible ReasonSolution
660000001A common service error occurred.A server error occurred.Try again, or contact ZEGOCLOUD technical support.
660000002Invalid parameter.The input parameter is invalid or not specified.Check the input parameter.
660000012The 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.
660700001Too many requests are sent.More than 20 requests are sent per second.Try again later.
660700002The 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.
660700006The 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.
660700007The 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.

Previous

Query user information

Next

Modify user information