The admin/users resource can be used to manage M/Monit users.

Available methods:

GET /api/2/admin/users/list The users list
GET /api/2/admin/users/get Details for a particular user
POST /api/2/admin/users/create Create a new user
POST /api/2/admin/users/update Update a user
POST /api/2/admin/users/delete Delete a user

list

Returns a list of all M/Monit users.

Arguments

none
curl -b ~/.mmonit/cookie \
 https://127.0.0.1:8080/api/2/admin/users/list

Output

id The numeric user id (immutable)
uname The username used for login
fullname The full name of the user
image Image basename or an empty string for default image. Images are located in the docroot/uploads directory
title The user's title
email The user's email
mobile The cell-phone/mobile number
imname The instant messaging address
imtype The instant messaging type. E.g. Skype, MSN etc.
avatar The file name of the user's image.
unsafepassword The attribute is true, if password audit is enabled and some user has unsafe password.
[
    {
        "id": "123",
        "uname": "admin",
        "fullname": "Administrator",
        "image": "",
        "title": "M/Monit Administrator",
        "email": "admin@foo.bar",
        "mobile": "123456",
        "imname": "admin@gtalk.com",
        "imtype": "Jabber",
        "avatar": "avatar-1.png",
        "unsafepassword": 0
    },
    {
        "id": "321",
        "uname": "monit",
        "fullname": "Monit",
        "image": "id1405310131422.jpg",
        "title": "Default User",
        "email": "operator@foo.bar",
        "mobile": "654321",
        "imname": "",
        "imtype": "",
        "avatar": "avatar-2.png",
        "unsafepassword": 1
    }
]

get

Get details of the user with the given uname.

Arguments

id number required The user id to get
curl -b ~/.mmonit/cookie \
 https://127.0.0.1:8080/api/2/admin/users/get?id=123

Output

id The numeric user id (immutable)
uname The username used for login
password The SHA256 digest of the user's password
roles An array of assigned role ids
fullname The user's full name
image Image basename or an empty string for default image.
title The user's title
email The user's email
phone The phone number
mobile The cell-phone/mobile number
imname The instant messaging address
imtype The instant messaging type. E.g. Skype, MSN etc
{
    "id": "123",
    "uname": "monit",
    "password": "d251eb7264c50433db87b3758590654a0de62551cd6bf5a5c26cd59672d4f952",
    "roles: [4,5,6],
    "fullname": "Monit",
    "title": "Default User",
    "email": "",
    "phone": "123456",
    "mobile": "654321",
    "imname": "",
    "imtype": "",
    "image": "id1405310131422.jpg"
}

create

Create a new M/Monit user. Parameters with space in them must be URL encoded (space=%20) as curl won’t escape it automatically.

Arguments

uname string required The username used for login
password string required The user's password in clear text. M/Monit will convert it to a salted SHA256 digest and store that string in its database
roleid numeric required The role id, assigned to the user. The argument can be used multiple times to assign multiple roles
fullname string required The user's full name
title string optional The user's title
email string optional The user's email
phone string optional The phone number
mobile string optional The cell-phone/mobile number
imname string optional The instant messaging address
imtype string optional The instant messaging type. E.g. Skype, MSN etc.
image string optional Image basename or an empty string for default image. Images are located in the docroot/uploads directory
curl -b ~/.mmonit/cookie \
 -d uname=test \
 -d fullname=my%20test%20user \
 -d password=secret \
 https://127.0.0.1:8080/api/2/admin/users/create

update

Update user in the M/Monit database. Parameters with space in them must be URL encoded (space=%20) as curl won’t escape it automatically.

Arguments

id number required The user id to update
uname string required The username used for login
password string required The user's new password in clear text or if unchanged, the SHA256 digest of the user's existing password
roleid numeric required The role id, assigned to the user. The argument can be used multiple times to assign multiple roles
fullname string required The user's full name
title string optional The user's title
email string optional The user's email
phone string optional The phone number
mobile string optional The cell-phone/mobile number
imname string optional The instant messaging address
imtype string optional The instant messaging type. E.g. Skype, MSN etc.
image string optional Image basename or an empty string for default image. Images are located in the docroot/uploads directory
curl -b ~/.mmonit/cookie \
 -d id=123 \
 -d uname=test \
 -d fullname=my%20test%20user \
 -d password=d251eb7264c50433db87b3758590654a0de62551cd6bf5a5c26cd59672d4f952 \
 https://127.0.0.1:8080/api/2/admin/users/update

delete

Deletes the user with the given id.

Arguments

id number required The user id to delete
curl -b ~/.mmonit/cookie \
 -d id=123 \
 https://127.0.0.1:8080/api/2/admin/users/delete