Platform API
List users
Use List users to page through user profiles registered with OpenIM. pagination.pageNumber starts at 1, and data.total reports the total number of matching users.
HTTP request
POST {API_ADDRESS}/user/get_usersRequest example
curl --request POST "${API_ADDRESS}/user/get_users" \
--header "Content-Type: application/json; charset=utf-8" \
--header "operationID: ${OPERATION_ID}" \
--header "token: ${ADMIN_TOKEN}" \
--data-raw '{
"pagination": {
"pageNumber": 1,
"showNumber": 100
}
}'Keep administrator tokens on trusted backend services only. Client applications should use user tokens issued by your backend.
Request body
{
"pagination": {
"pageNumber": 1,
"showNumber": 100
}
}| Parameter | Required | Type | Description |
|---|---|---|---|
| pagination | Yes | object | Pagination settings. |
| pagination.pageNumber | Yes | int | Page number, starting from 1. |
| pagination.showNumber | Yes | int | Number of records to return per page. |
| statuses Enterprise | No | int[] | Filter by account state. See UserStatus. |
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": "",
"data": {
"total": 47,
"users": [
{
"userID": "user_001",
"nickname": "Alice",
"faceURL": "https://cdn.example.com/avatar/u_001.png",
"ex": "",
"createTime": 0,
"appMangerLevel": 18,
"globalRecvMsgOpt": 0
},
{
"userID": "user_002",
"nickname": "Bob",
"faceURL": "",
"ex": "",
"createTime": 1688381391965,
"appMangerLevel": 18,
"globalRecvMsgOpt": 0
}
]
}
}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. |
| data | object | Endpoint-specific response data. |
| total | int | Total number of matching records. |
| data.users | array | User profiles for the current page. Each item follows UserInfo. |
Pagination
Start with page 1 and use pagination.showNumber as the page size. The total page count is Math.ceil(data.total / pagination.showNumber).
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
- Keep the page size within the limit configured by your OpenIM deployment.
- The
statusesfilter is available in OpenIM Enterprise.
Related pages
Was this page helpful?