LogicMonitor seeks to disrupt AI landscape with $800M strategic investment at $2.4B valuation to revolutionize data centers.

Learn More

Adding Users

Last updated on 07 October, 2024

You can use LogicMonitor REST API v3 to add users. You must authenticate yourself before making the API request.

URI: POST /setting/admins

ParameterTypeDescription
lastNameStringThe last name of the user.
Example – "lastName": "Potter"
noteStringAdd a note about the user.
Example – "note": "Harry Potter has super admin role."
viewPermissionJSON ObjectThe Account tabs visible to the user. The View Permission area of a user’s configuration determines the visibility of pages to the user. If a page is not selected, the user will not be able access it regardless of the permission levels provided by the assigned roles.

Generally, you may want to select all the pages and let the user’s assigned roles determine visibility and access, but there may be some circumstances in which the user needs to be definitively restricted from a particular page.

Example – { "Resources" : true, "Websites" : true, "Reports" : true, "Dashboards" : true, "Alerts" : true, "Settings" : true, "Maps" : true, "Logs" : true, "Traces" : true }
timezoneStringThe timezone of the user.
Example – "timezone": "America/Los Angeles"
rolesJSON Object(Mandatory) The roles assigned to the user. It includes the account privileges of the role. Privileges can be added to a role for each area of the account. The name, description, and group ID of the role, if two-factor authentication is required for this role, if the user is required to acknowledge the EULA, and so on is specified for the role. If a user is assigned multiple roles, the user’s privileges are a sum of the privileges of each of the assigned roles.

For example, if one assigned role provides view only permission to all resources, but another assigned role provides manage permission to all resources, the user has both the view and manage permissions for all resources. If yet another assigned role provides view permission for all dashboards, but no permission for resources, the user still has manage permission for all resources and additionally has view permission for all dashboards.
smsEmailFormatStringIndicates the sms or fullText format. For SMS, 160 characters and for full text, all characters are allowed.
Example – "smsEmailFormat": "sms"
apionlyBooleanIndicates if the user is a API only user.
Example – "apionly": true

API only users can only access LogicMonitor REST API. The only relevant fields to them are the Username, API Tokens, Roles, Status, and Notes. They do not have passwords or other user interface-specific fields, making them more secure as a dedicated user for an API-based integration.
apiTokensJSON ObjectThe API token of the user. The API token consists of
  • note – The note for the API token.
    Example – "note": "Harry Potter's API Token"
  • status – Indicates if the API token is enabled. 1 indicates disabled and 2 indicates enabled.
"apiTokens": [
{ "note": "Harry Potter's API Token", "status": 2 }
],
adminGroupIdsIntegerGroup ID(s) of groups with admin. Multiple group IDs are separated by a comma.
Example – "adminGroupIds": 1,2,3
passwordString(Mandatory) The password of the user.
Example – "password": "hPo131"
emailString(Mandatory) The email address of the user.
Example – "email": "[email protected]"
contactMethodStringThe method to contact the user. The supported contact methods are email and smsemail.
Example – "contactMethod": "email"
smsEmailStringThe sms email address of the user.
Example – "smsEmail": [email protected]
twoFAEnabledBooleanIndicates if two factor authentication is enabled for the user.
Example – "twoFAEnabled": true
firstNameStringThe first name of the user.
Example – "firstName": "Harry"
phoneStringThe phone number of the user.
Example – "phone": "9091929394"
createdByStringDetails of the user who created the user. It may be another user, SAML, or LogicMonitor.
Example – "createdBy": "Chief Admin" 
forcePasswordChangeBooleanIndicates if the user should be forced to change the password during the next login.
Example – "forcePasswordChange": false
acceptEULABooleanIndicates if the user has to accept the End User License Agreement (EULA).
Example – "acceptEULA": false
usernameString(Mandatory) The username of the user.
Example – "username": "Harry"
statusStringThe status of the user. The supported values are active and suspended.
Example – "status": "active"

The following Python script adds a user with administrator privileges to account api.logicmonitor.com

#!/bin/env python
 
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass
 
#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
UserPassword = getpass.getpass("Enter password for user : ")
Company = 'apiAccount'  
 
#Request Info
httpVerb ='POST'
resourcePath = '/setting/admins'
queryParams =''
data = '{"roles":[{"name":"administrator"}],"email":"[email protected]","username":"sara","password":"%s","smsEmail":"[email protected]"}'
 
#Construct URL
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath + queryParams
 
#Get current time in milliseconds
epoch = str(int(time.time() * 1000))
 
#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath  
 
#Construct signature
digest = hmac.new(
        AccessKey.encode('utf-8'),
        msg=requestVars.encode('utf-8'),
        digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8')   
 
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}
 
#Make request
response = requests.post(url, data=data, headers=headers)
 
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3