Skip to main content

createUser

A MoogDb v2 method that creates a user, by passing an object containing user properties.

Back to MoogDb V2 API Method Reference.

Request arguments

Method createUser takes the following request arguments:

Name

Type

Required

Description

userObj

Object

Yes

An object containing the following user information.

username

String

Yes

New user login name. Must be unique.

password

String

Yes

New user password. Only valid for DB realm.

active

Boolean

No

Set to true if user is active; set to false if user is inactive. Default is true.

email

String

Yes

User's email address.

fullname

String

Yes

User's full name.

roles

JSON Array

Yes

List of either the roleIDs or role names. For example, "roles":["Super User"].

primary_group

String or Number

Yes

User's primary group name or primary group ID.

department

String or Number

Yes

User's department name or ID.

joined

Number

Yes

Time the user joined in Unix epoch time.

timezone

String

Yes

User's timezone.

contact_num

String

Yes

User's phone number.

session_expiry

Number

No

Number of minutes after which the user's session expires. Default is the system default.

teams

JSON Array of Numbers or Strings

Yes

List of the user's team names or team IDs.

Response

Method createUser returns the following response:

Type

Description

Integer

ID of the new user, or null if an error occurred.

Examples

The following examples demonstrate typical use of method createUser:

Request example

Example request to create a new user "user1":

{
    "username": "phil",
    "fullname": "Phil Customer",
    "roles": ["Super User"],
    "department": 3,
    "active": true,
    "email": "phil@example.com",
    "timezone": "(GMT 00:00) Europe/London - Greenwich Mean Time",
    "teams": [1, 2, 4],
    "joined": 12345678,
    "contact_num": "0965412345"
}

Response example

Example response returning the ID of the new user:

72