Platform API
Create a user
Use Create a user from your backend to register one or more users with OpenIM. The management REST API uses an administrator token, while client SDK login uses a user token issued by your backend. Never expose administrator credentials to a client.
HTTP request
POST {API_ADDRESS}/user/user_registerRequest example
curl --request POST "${API_ADDRESS}/user/user_register" \
--header "Content-Type: application/json; charset=utf-8" \
--header "operationID: ${OPERATION_ID}" \
--header "token: ${ADMIN_TOKEN}" \
--data-raw '{
"users": [
{
"userID": "11111112",
"nickname": "yourNickname",
"faceURL": "yourFaceURL"
}
]
}'Keep administrator tokens on trusted backend services only. Client applications should use user tokens issued by your backend.
Request body
{
"users": [
{
"userID": "11111112",
"nickname": "yourNickname",
"faceURL": "yourFaceURL"
}
]
}| Parameter | Required | Type | Description |
|---|---|---|---|
| users | Yes | array | Users to register. Each item follows the UserInfo representation. |
| users.userID | Yes | string | OpenIM user ID. |
| users.nickname | Yes | string | User nickname. |
| users.faceURL | Yes | string | Avatar or icon URL. |
Response
OpenIM usually returns 200 OK when the request reaches the service. Use errCode in the JSON response to determine business success; errCode === 0 means the operation succeeded.
{
"errCode": 0,
"errMsg": "",
"errDlt": ""
}Response fields
| Field | Type | Description |
|---|---|---|
| errCode | int | Business error code. 0 means success. |
| errMsg | string | Short error message. |
| errDlt | string | Detailed error information for troubleshooting. |
Error response
When a request fails, OpenIM returns the same error envelope. See Error codes for the full handling model.
{
"errCode": 1004,
"errMsg": "RecordNotFoundError",
"errDlt": ": [1004]RecordNotFoundError"
}| Scenario | Possible cause | Recommended action |
|---|---|---|
| Authentication failed | token is missing, expired, or not an administrator token. | Issue a new administrator token and keep it on the backend. |
| Traceability is weak | operationID is missing or reused across many requests. | Generate a unique operationID for every request and log it with the response. |
| Validation failed | The request body has an invalid type, missing field, or unsupported enum value. | Compare the payload with the request table and retry after correcting the fields. |
Permissions and limits
- Call this endpoint from a trusted backend service with an administrator token.
- User IDs are application-defined identifiers and must be unique within the OpenIM deployment.
- A successful response means the users have been registered. Issue user tokens separately when clients need to log in.
Related pages
Was this page helpful?