Deleting Users

Last updated on 31 May, 2024

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

URI: DELETE /setting/admins/{id}

idInteger(Mandatory) The ID of the user that you want to delete.

The following Python script deletes user 32 from account

#!/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: ")
Company = 'apiAccount'
#Request Info
httpVerb ='DELETE'
resourcePath = '/setting/admins/32'
queryParams =''
data = ''
#Construct URL
url = 'https://'+ Company +'' + resourcePath + queryParams
#Get current time in milliseconds
epoch = str(int(time.time() * 1000))
#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath  
#Construct signature
digest =
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.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