user.create

Description

object user.create(object/array **users**)

This method allows to create new users.

This method is only available to Super admin user type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object/array) Users to create.

Additionally to the standard user properties, the method accepts the following parameters.

ParameterTypeDescription
passwd
(required)
stringUser’s password.

Can be omitted if user is added only to groups that have LDAP access.
usrgrps
(required)
arrayUser groups to add the user to.

The user groups must have the usrgrpid property defined.
mediasarrayUser media to be created.

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 a new user, add him to a user group and create a new media for him.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "user.create",
  4. "params": {
  5. "alias": "John",
  6. "passwd": "Doe123",
  7. "roleid": "5",
  8. "usrgrps": [
  9. {
  10. "usrgrpid": "7"
  11. }
  12. ],
  13. "medias": [
  14. {
  15. "mediatypeid": "1",
  16. "sendto": [
  17. "[email protected]"
  18. ],
  19. "active": 0,
  20. "severity": 63,
  21. "period": "1-7,00:00-24:00"
  22. }
  23. ]
  24. },
  25. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  26. "id": 1
  27. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "userids": [
  5. "12"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

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