You can use LogicMonitor’s REST API to programmatically manage the users in your account.

 

Using LogicMonitor’s REST API, you can:

Note: As with all of our API calls, authentication is required.

 

 

Resource URI:

/setting/admins

 

Resource Properties:

All users have the following properties:

 

Property

Description

Type

id The Id of the user Integer
roles The roles assigned to the user JSON Object
contactMethod email | smsemail String
email The email address associated with the user String
phone The phone number associated with the user String
smsEmail The sms email address associated with the user String
smsEmailFormat sms | fullText, where sms = 160 characters and fullText= all characters String
username The username associated with the user String
firstName The first name associated with the user String
lastName The last name associated with the user String
status The user’s status. Should be one of active and suspended String
lastLoginOn The time that the user last logged in, in epoch format Integer
note Any notes assocaited with the user String
createBy Who created the user. This may be another user, SAML or LogicMonitor String
forcePasswordChange Whether or not the user should be forced to change their password on the next login Boolean
apiTokens Any API Tokens associated with the user JSON Object
viewPermission The account tabs that will be visible to the user JSON Object
lastAction The last action taken by the user String
lastActionOnLocal The time, in local format, of the user’s last action String
lastActionOn The time, in epoch format, of the user’s last action Integer
acceptEulaOn The time, in epoch format, that the user accepted the EULA (if required to) Integer
acceptEULA Whether or not the user is required to accept the EULA (end user license agreement) Boolean
twoFAEnabled Whether or not two factor authentication is enabled for the user Boolean

 

You can use LogicMonitor’s REST API to programmatically add users to your account.

Note: As with all our API resources, authentication is required.

Add a User

HTTP Method:POST

URI: /setting/admins

Request Parameters:You can POST the following properties for a new user

Property

Description

Type

Required?

roles The roles assigned to the user JSON Object yes
contactMethod email | smsemail String no – defaults to email
email The email address associated with the user String yes
phone The phone number associated with the user String no
smsEmail The sms email address associated with the user String no
smsEmailFormat sms | fullText, where sms = 160 characters and fullText= all characters String no – defaults to sms
username The username associated with the user String yes
firstName The first name associated with the user String no
lastName The last name associated with the user String no
password The password associated with the user String yes
status The user’s status. Should be one of active and suspended String no – defaults to active
note Any notes assocaited with the user String no
forcePasswordChange Whether or not the user should be forced to change their password on the next login Boolean no – defaults to false
viewPermission The account tabs that will be visible to the user JSON Object no – defaults to all pages visible
acceptEULA Whether or not the user is required to accept the EULA (end user license agreement) Boolean no – defaults to false
twoFAEnabled Whether or not two factor authentication is enabled for the user Boolean no – defaults to false

Example

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

#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'

#Request Info
httpVerb ='POST'
resourcePath = '/setting/admins'
queryParams =''
data = '{"roles":[{"name":"administrator"}],"email":"[email protected]","username":"sarah","password":"8v.VM^3LPrQKbH","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
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(hmac1.encode())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#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

You can use LogicMonitor’s REST API to programmatically update users in your account.

Note: As with all of our API calls, authentication is required.

HTTP Method: PUT

Resource URI: /setting/admins/{adminID}

Where adminID is the ID of the user you’d like to update.

You can include the following parameters in your PUT request.  

Notes:

Property

Description

Type

Required?

roles The roles assigned to the user JSON Object yes
contactMethod email | smsemail String no – defaults to email
email The email address associated with the user String yes
phone The phone number associated with the user String no
smsEmail The sms email address associated with the user String no
smsEmailFormat sms | fullText, where sms = 160 characters and fullText= all characters String no – defaults to sms
username The username associated with the user String yes
firstName The first name associated with the user String no
lastName The last name associated with the user String no
password The password associated with the user String no – defaults to no change
status The user’s status. Should be one of active and suspended String no – defaults to active
note Any notes assocaited with the user String no
forcePasswordChange Whether or not the user should be forced to change their password on the next login Boolean no – defaults to false
viewPermission The account tabs that will be visible to the user JSON Object no – defaults to all pages visible
acceptEULA Whether or not the user is required to accept the EULA (end user license agreement) Boolean no – defaults to false
twoFAEnabled Whether or not two factor authentication is enabled for the user Boolean no – defaults to false

Example

The following Python script updates the user sarah, including the user’s password (hence the changePassword=true in the request) in account api.logicmonitor.com:

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'

#Request Info
httpVerb ='PUT'
resourcePath = '/setting/admins/147'
queryParams ='?changePassword=true'
data = '{"roles":[{"name":"administrator"}],"email":"[email protected]","username":"sarah","password":"8v.VM^3LPrQKbHxyz","status":"active"}'

#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
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(hmac1.encode())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.put(url, data=data, headers=headers)

#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3

You can use LogicMonitor’s REST API to programmatically get information about users to your account. You can use the users resource to:

  1. Get information about all users in an account
  2. Get information about one user in an account

Note: As with all our API resources, authentication is required.

Get information about all users in an account

HTTP Method:GET

URI: /setting/admins

Request Parameters:By default, a list of 50 users will be returned. You can include sort, filter,  fields, size, and offset parameters that control what data is included in the response and how it is formatted. Note that query parameters are not considered part of the resource path, and should not be included the calculation of the LMv1 authentication signature.

Property Syntax Description Example URI
sort sort={+ or -}property Sorts the response by the property specified in either increasing (+) or decreasing (-) order /setting/admins?sort=-id
filter filter=property{operator}value Filters the response according to the operator and value specified. Note that you can use * to match on more than one character.You can use the ‘.’ character to filter values within an object (e.g. custom properties), and multiple filters can be separated by a comma. 

 

Operators include:

  • Greater than or equals: >:
  • Less than or equals: <:
  • Greater than: >
  • Less than: <
  • Does not equal: !:
  • Equals: :
  • Includes: ~
  • Does not include: !~
/setting/admins?filter=username:sarah
fields fields=list of properties separated by commas Filters the response to only include the following fields for each object /setting/admins?fields=id,username
size size=integer The number of results to display. Max is 1000 /setting/admins?size=10
offset offset=integer The number of results to offset the displayed results by /setting/admins?offset=20

Example

The following Python script gets all users in the account api.logicmonitor.com:

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'

#Request Info
httpVerb ='GET'
resourcePath = '/setting/admins'
queryParams =''
data = ''

#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
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(hmac1.encode())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.get(url, data=data, headers=headers)

#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3

Get information about a particular user

HTTP Method: GET

Resource URI: /setting/admins/{adminID}

Where adminID is the id of the user you’d like to get information about.

Example

The following Python script gets information about user 32 in account api.logicmonitor.com:

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'

#Request Info
httpVerb ='GET'
resourcePath = '/setting/admins/32'
queryParams =''
data = ''

#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
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(hmac1.encode())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.get(url, data=data, headers=headers)

#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3

You can use LogicMonitor’s REST API to programmatically delete users in your account.

Note: As with all of our API calls, authentication is required.

HTTP Method: DELETE

Resource URI: /setting/admins/{adminID}

Where adminID is the id of the user you’d like to delete.

Example

The following Python script deletes user 32 from account api.logicmonitor.com:

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'

#Request Info
httpVerb ='DELETE'
resourcePath = '/setting/admins/32'
queryParams =''
data = ''

#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
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(hmac1.encode())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}
#Make request
response = requests.delete(url, data=data, headers=headers)

#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3