You are viewing documentation for the development version, it may be incomplete.
Join our translation project and help translate Zabbix documentation into your native language.

user.get

Description

integer/array user.get(object parameters)

The method allows to retrieve users according to the given parameters.

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

When requesting user media, permissions, or role information, Admin and User type users may retrieve data only about their own user. For an example, see Retrieving users as Admin.

Parameter Type Description
mediaids ID/array Return only users that use the given media.
mediatypeids ID/array Return only users that use the given media types.
userids ID/array Return only users with the given IDs.
usrgrpids ID/array Return only users that belong to the given user groups.
getAccess flag Adds additional information about user permissions.

Adds the following properties for each user:
gui_access - (integer) user's frontend authentication method. Refer to the gui_access property of the user group object for a list of possible values.
debug_mode - (integer) indicates whether debug is enabled for the user. Possible values: 0 - debug disabled, 1 - debug enabled.
users_status - (integer) indicates whether the user is disabled. Possible values: 0 - user enabled, 1 - user disabled.
selectMedias query Return media used by the user in the medias property.
selectMediatypes query Return media types used by the user in the mediatypes property.

See mediatype.get for restrictions based on user type.
selectUsrgrps query Return user groups that the user belongs to in the usrgrps property.

See usergroup.get for restrictions based on user type.
selectRole query Return user role in the role property.
filter object Return only those results that exactly match the given filter.

Accepts an object, where the keys are property names, and the values are either a single value or an array of values to match against.

Does not support properties of text data type.

Possible User object properties for Admin and User type users when requesting data on users in their user group: userid, name, surname, username.
output query User object properties to be returned.

Admin and User type users may retrieve only the following properties:
- For their own user: userid, attempt_clock, attempt_failed, attempt_ip, autologin, autologout, lang, name, provisioned, refresh, roleid, rows_per_page, surname, theme, timezone, url, username.
- For users in their user group: userid, name, surname, username.

Default: extend.
search object Return results that match the given pattern (case-insensitive).

Accepts an object, where the keys are property names, and the values are strings to search for. If no additional options are given, this will perform a LIKE "%…%" search.

Supports only properties of string and text data type.

Possible User object properties for Admin and User type users when requesting data on users in their user group: name, surname, username.
sortfield string/array Sort the result by the given properties.

Possible values: userid, username.
countOutput boolean These parameters are described in the reference commentary.
editable boolean
excludeSearch boolean
limit integer
preservekeys boolean
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

Return values

(integer/array) Returns either:

  • an array of objects;
  • the count of retrieved objects, if the countOutput parameter has been used.

Examples

Retrieving users

Retrieve all of the configured users.

Request:

{
           "jsonrpc": "2.0",
           "method": "user.get",
           "params": {
               "output": "extend"
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "userid": "1",
                   "username": "Admin",
                   "name": "Zabbix",
                   "surname": "Administrator",
                   "url": "",
                   "autologin": "1",
                   "autologout": "0",
                   "lang": "en_US",
                   "refresh": "0s",
                   "theme": "default",
                   "attempt_failed": "0",
                   "attempt_ip": "",
                   "attempt_clock": "0",
                   "rows_per_page": "50",
                   "timezone": "default",
                   "roleid": "3",
                   "userdirectoryid": "0",
                   "ts_provisioned": "0"
               },
               {
                   "userid": "2",
                   "username": "guest",
                   "name": "",
                   "surname": "",
                   "url": "",
                   "autologin": "0",
                   "autologout": "15m",
                   "lang": "default",
                   "refresh": "30s",
                   "theme": "default",
                   "attempt_failed": "0",
                   "attempt_ip": "",
                   "attempt_clock": "0",
                   "rows_per_page": "50",
                   "timezone": "default",
                   "roleid": "4",
                   "userdirectoryid": "0",
                   "ts_provisioned": "0"
               },
               {
                   "userid": "3",
                   "username": "user",
                   "name": "Zabbix",
                   "surname": "User",
                   "url": "",
                   "autologin": "0",
                   "autologout": "0",
                   "lang": "ru_RU",
                   "refresh": "15s",
                   "theme": "dark-theme",
                   "attempt_failed": "0",
                   "attempt_ip": "",
                   "attempt_clock": "0",
                   "rows_per_page": "100",
                   "timezone": "default",
                   "roleid": "1",
                   "userdirectoryid": "0",
                   "ts_provisioned": "0"
               }
           ],
           "id": 1
       }

Retrieving users as Admin

As an Admin type user, retrieve detailed data about your own user and limited data for users in your user group.

Request:

{
           "jsonrpc": "2.0",
           "method": "user.get",
           "params": {
               "output": "extend",
               "getAccess": true,
               "selectMedias": "extend",
               "selectMediatypes": "extend",
               "selectUsrgrps": "extend",
               "selectRole": "extend"
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "userid": "1",
                   "username": "Admin",
                   "name": "Zabbix",
                   "surname": "Administrator",
                   "usrgrps": [
                       {
                           "usrgrpid": "7",
                           "name": "Zabbix administrators",
                           "gui_access": "0",
                           "users_status": "0",
                           "debug_mode": "0",
                           "mfa_status": "0"
                       }
                   ]
               },
               {
                   "userid": "3",
                   "username": "database-admin",
                   "name": "John",
                   "surname": "Doe",
                   "url": "",
                   "autologin": "0",
                   "autologout": "0",
                   "lang": "default",
                   "refresh": "30s",
                   "theme": "default",
                   "attempt_failed": "0",
                   "attempt_ip": "",
                   "attempt_clock": "0",
                   "rows_per_page": "50",
                   "timezone": "default",
                   "roleid": "2",
                   "provisioned": "0",
                   "gui_access": "0",
                   "debug_mode": "0",
                   "users_status": "0",
                   "usrgrps": [
                       {
                           "usrgrpid": "7",
                           "name": "Zabbix administrators",
                           "gui_access": "0",
                           "users_status": "0",
                           "debug_mode": "0",
                           "mfa_status": "0"
                       }
                   ],
                   "medias": [
                       {
                           "mediaid": "2",
                           "mediatypeid": "1",
                           "sendto": [
                               "[email protected]"
                           ],
                           "active": "0",
                           "severity": "63",
                           "period": "1-7,00:00-24:00",
                           "provisioned": 0
                       }
                   ],
                   "mediatypes": [
                       {
                           "mediatypeid": "1",
                           "type": "0",
                           "name": "Email",
                           "status": "0",
                           "description": "",
                           "maxattempts": "3"
                       }
                   ],
                   "role": {
                       "roleid": "2",
                       "name": "Admin role",
                       "type": "2",
                       "readonly": "0"
                   }
               }
           ],
           "id": 1
       }

Retrieving user data

Retrieve data of a user with ID "12".

Request:

{
           "jsonrpc": "2.0",
           "method": "user.get",
           "params": {
               "output": ["userid", "username"],
               "selectRole": "extend",
               "userids": "12"
           },
           "id": 1
       }

Response:

{
         "jsonrpc": "2.0",
         "result": [
             {
                 "userid": "12",
                 "username": "John",
                 "role": {
                     "roleid": "5",
                     "name": "Operator",
                     "type": "1",
                     "readonly": "0"
                 }
             }
         ],
         "id": 1
       }

See also

Source

CUser::get() in ui/include/classes/api/services/CUser.php.