In-app Chat
  • iOS : Objective-C
  • Android
  • Web
  • Flutter
  • React Native
  • Unity3D
  • Windows
  • macOS
  • Introduction
    • Overview
    • Basic concepts
  • Sample app
  • Getting started
  • Client SDKs
    • SDK downloads
    • Release notes
    • Upgrade guide
  • Guides
    • Authentication
    • Manage users
    • Room
    • Group
    • Messaging
    • Call invitation (signaling)
    • Manage sessions
  • Offline push notifications
  • Error codes
  • Client APIs
  • Server APIs
  • Documentation
  • In-app Chat
  • Server APIs
  • User related
  • Batch register users

Batch register users

Last updated:2024-03-15 11:34

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:

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

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

Response parameters

Parameter Type Description
Code
Number
The return code.
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.
Message
String
The description of the request result.
RequestId
String
The request ID.
ErrorList
Array 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.
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.
Page Directory