Zabbix Documentation 2.0

3.04.05.0 (current)| In development:5.2 (devel)| Unsupported:1.82.02.22.43.23.44.24.4Guidelines

User Tools

Site Tools


manual:appendix:api:user:create

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
manual:appendix:api:user:create [2010/09/14 11:14]
127.0.0.1 external edit
manual:appendix:api:user:create [2019/01/28 14:49] (current)
sasha <code js> => <code java>
Line 1: Line 1:
-===== create() ===== +===== user.create ===== 
-This function allows you to create a user as defined by the **user data** array. Available only to super admins.+ 
 +==== Description ==== 
 + 
 +''​object ​user.create(object/​array ​**users**)''​ 
 + 
 +This method allows ​to create new users.
  
 ==== Parameters ==== ==== Parameters ====
-^Parameter^Type^Optional^Description^Details^ 
-|**user data**|//​array or object//| No |Array of User objects or a single object|**userid** shouldn'​t be specified | 
-|**usrgrps**|//​array//​| No |User Groups add User to. | | 
-|**user_medias**|//​array//​| No |Create User Medias for User. | | 
  
-====Returns==== +''​(object/​array)''​ Users to create. 
-^Parameter^Description^ + 
-|**result**|Operation successful. Result will contain array of created ​User IDs. **userid** are assigned to each User object ​+Additionally to the [[definitions#​user|standard user properties]],​ the method accepts the following parameters. 
-|**error**|In case of any errors+ 
-==== Example ​==== +^ Parameter ​^ Type ^ Description ^ 
-Create new user and added it to user groups. Password "​zabbix"​ will automaticly be encoded by MD5 hash function+| **passwd** \\ //​(required)//​ | string ​| User's password
-<​code>​+**usrgrps** \\ (required) | array | User groups to add the user to. \\ \\ The user groups must have the ''​usrgrpid''​ property defined. ​
 +user_medias ​array | Media to create for the user. \\ \\ The media ''​userid''​ property must not be defined. ​
 +==== Return values ​==== 
 + 
 +''​(object)''​ Returns an object containing the IDs of the created users under the ''​userids''​ property. The order of the returned IDs matches the order of the passed users. 
 + 
 +==== Examples ==== 
 + 
 +=== Creating a user === 
 + 
 +Create ​new user, add him to user group and create a new media for him. 
 + 
 +Request: 
 +<​code ​java>
 { {
-"​jsonrpc":"​2.0",​ +    ​"​jsonrpc":​ "​2.0",​ 
-"​method":"​user.create",​ +    "​method":​ "​user.create",​ 
-"​params":​[+    "​params":​ { 
- "usrgrps":[{ +        "alias": "John", 
- "usrgrpid":"​100100000000009", +        "passwd": "Doe123", 
- "name":"​Internal login" +        "usrgrps": ​[ 
- },{ +            
- "usrgrpid":"​100100000000020",​ +                "​usrgrpid":​ "7
- "​name":"​API access"​ +            } 
- },+        ], 
- "​usrgrpid":"​100100000000022", +        "user_medias": ​[ 
- "​name":"​Debug group" +            { 
- }], +                "mediatypeid": "1", 
- "alias":"Test User", +                "sendto": "[email protected]", 
- "​name":"​Test User Name", +                "active": 0, 
- "surname":"​Test User Surname", +                "severity": ​63
- "passwd":"​zabbix", +                "period": "1-7,00:00-24:00
- "url":"",​ +            } 
- "​autologin":"​0"+        ] 
- "autologout":"​600"​+    }, 
- "lang":"​en_gb",​ +    "​auth":​ "​038e1d7b1735c6a5436ee9eae095879e",​ 
- "​refresh":"​90",​ +    "​id": ​1
- "type":"​1", +
- "​theme"​:"​css_ob.css",​ +
- "​attempt_failed"​:"0", +
- "​attempt_ip":"",​ +
- "​attempt_clock":"​0",​ +
- "​rows_per_page":"​50"​ +
-}]+
-"​auth":"​038e1d7b1735c6a5436ee9eae095879e",​ +
-"​id":​3+
 } }
 </​code>​ </​code>​
  
-User added successfully+Response
-<​code>​+<​code ​java>
 { {
-"​jsonrpc":"​2.0",​ +    ​"​jsonrpc":​ "​2.0",​ 
-"​result":​{ +    "​result":​ { 
-   ​"​userids":​ ["107819"] +        "​userids":​ [ 
-}, +            ​"12" 
-"​id":​3+        ​
 +    }, 
 +    "​id": ​1
 } }
 </​code>​ </​code>​
  
-User already exists:+==== See also ====
  
-<​code>​ +  * [[manual:appendix:api:usermedia:definitions#​media|Media]] 
-+  ​* ​[[manual:appendix:api:​usergroup:​definitions#​user_group|User group]
-"​jsonrpc"​:"​2.0",​ + 
-"​error"​:+ 
-      "​code"​:-32602, +==== Source ==== 
-      "​message"​:"​Invalid params.",​ + 
-      "​data":"​CUser::create ] User [ Admin already exists"​ +CUser::​create() in //​frontends/​php/​api/​classes/​CUser.php//​.
-}, +
-"​id":​3 +
-} +
-</code>+