Get Users List

Prev Next
Get
/api/v1/users.list

Retrieves workspace users and the information the caller is allowed to view. Filter by username, email, or custom field values to locate a user and obtain their userId for the users.info endpoint.

The response only contains the default user fields. To read customFields, set includeCustomFields to true. Other fields, such as utcOffset, nickname, bio, and statusText, are not returned by this endpoint. Use the users.info endpoint instead.

When the Premium User status hiding feature is enabled, users who have hidden their status from the caller appear as offline, and their detailed status fields are omitted.

Permissions required:

  • view-d-room: View direct messages.
  • view-full-other-user-info: View complete user details, such as account creation and last login. Also required to use the customFields and includeCustomFields parameters.
  • view-outside-room: View users outside the caller's rooms when Apply_permission_view-outside-room is enabled under Settings > General > REST API.

Changelog

Version Description
9.0.0 Removed the query and fields parameters. Requests that include them return a 400 error. Added the username, customFields, and includeCustomFields query parameters.
8.8.0 Added status visibility filtering
8.4.0 Added email query parameter for filtering
0.49.0 Count and offset query parameters supported.
0.35.0 Added
Header parameters
X-Auth-Token
stringRequired

The authenticated user token.

ExampleRScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f
X-User-Id
stringRequired

The authenticated user ID.

ExamplerbAXPnMktTFbNpwtJ
Query parameters
offset
integer

Number of items to "skip" in the query, i.e. requests return count items, skipping the first offset items. Refer to the official documentation to learn more.

Example50
count
integer

How many items to return. Refer to the official documentation to learn more.

Example50
sort
string

Sort the users in ascending (1) or descending (-1) order. The value must be entered as a JSON string. The options are as follows: * status: Sort by users' status. For example, sort={"status":1} (this maps to the active status). * createdAt: Sort by the time of user creation. For example, sort={"createdAt":-1} * name: Sort by user name. For example, sort={"name":1}

email
string | null

Filter users by email address. Minimum length: 1 character.

Min length1
Exampleuser@example.com
username
string | null

Filter users whose username contains this value. The match is not case-sensitive and checks the username only, not the display name. Regular expression characters are matched literally. Minimum length: 1 character. An empty value returns a 400 error.

Min length1
Examplejohn
customFields

Filter users by exact custom field values, in the format customFields[<key>]=<value>. For example, customFields[department]=Sales. The value match is case-sensitive. When you send more than one key, a user must match all of them. The filter works without includeCustomFields. Sending the parameter as a JSON string, such as customFields={"department":"Sales"}, returns a 400 error. Requires the view-full-other-user-info permission.

object
property*
string additionalProperties
Example{ "department": "Sales" }
includeCustomFields
boolean

Whether to include each user's full customFields object in the response. Users without custom fields are returned without the customFields key. The value must be true or false; other values return a 400 error. Requires the view-full-other-user-info permission. Defaults to false.

Exampletrue
Responses
200

OK

Success Example
{
  "users": [
    {
      "_id": "DGsmi2J4WjizYn7jc",
      "username": "uniqueusername",
      "emails": [
        {
          "address": "email@user.tld",
          "verified": false
        }
      ],
      "type": "user",
      "status": "offline",
      "active": true,
      "roles": [
        "bot",
        "user"
      ],
      "name": "name",
      "nameInsensitive": "name"
    },
    {
      "_id": "uZ5JvvioeHK8Coyqe",
      "active": true,
      "type": "user",
      "status": "offline",
      "roles": [
        "user"
      ],
      "lastLogin": "2023-05-16T20:50:33.579Z",
      "username": "user-0",
      "nameInsensitive": ""
    },
    {
      "_id": "aspKK7FHe7iQgzexX",
      "active": true,
      "type": "user",
      "status": "offline",
      "roles": [
        "user"
      ],
      "lastLogin": "2023-05-12T10:44:46.703Z",
      "username": "user-00",
      "name": "User 00",
      "emails": [
        {
          "address": "user00@mail.cm",
          "verified": false
        }
      ],
      "nameInsensitive": "user 00"
    }
  ],
  "count": 3,
  "offset": 0,
  "total": 3,
  "success": true
}
Expand All
object
users
Array of object
object
_id
string
username
string
emails
Array of object
object
address
string
verified
boolean
type
string
status
string
active
boolean
roles
Array of string
string
name
string
lastLogin
string

Returned only for users who have logged in.

nameInsensitive
string
avatarETag
string
customFields
object

Returned only when includeCustomFields is true and the user has custom fields.

count
integer
offset
integer
total
integer
success
boolean
400

Bad Request

Removed or unknown parameter
{
  "success": false,
  "error": "must NOT have additional properties",
  "errorType": "error-invalid-params"
}
Empty username
{
  "success": false,
  "error": "must NOT have fewer than 1 characters",
  "errorType": "error-invalid-params"
}
customFields sent as a JSON string
{
  "success": false,
  "error": "must be object",
  "errorType": "error-invalid-params"
}
Invalid includeCustomFields value
{
  "success": false,
  "error": "must be boolean",
  "errorType": "error-invalid-params"
}
object
success
boolean
error
string
errorType
string
401

Unauthorized

Authorization Error
{
  "success": false,
  "error": "You must be logged in to do this."
}
object
success
boolean
error
string
403

Forbidden

Permission Error
{
  "success": false,
  "error": "forbidden"
}
object
success
boolean
error
string

Note:

The success response does not return the custom fields for users. To view the custom field information, you must add the query and fields parameters. For example, you want to view the users having the custom field clearance with the value High. To do this, update the request URL as follows:

curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \ -H "X-User-Id: aobEdbYhXfu5hkeqG" \ http://localhost:3000/api/v1/users.list?query={"customFields.clearance" : "High"}&fields={"customFields" : 1} 

The response looks something like this:

{ "users": [ { "_id": "ebKHhqGzw3Mu4KeBw", "username": "ciel", "emails": [ { "address": "example@test.com", "verified": false } ], "type": "user", "roles": [ "user" ], "status": "offline", "active": true, "name": "Ciel", "customFields": { "clearance": "High", "team": "Queen" }, "nameInsensitive": "ciel" } ], "count": 1, "offset": 0, "total": 1, "success": true }

To save and view the custom fields, you must first define the Custom Fields in the admin panel of your workspace (Administration > Workspace > Settings > Accounts > Registration > Custom Fields). See the Create User and Update User endpoints to add custom fields for new and existing users, respectively.