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

Learn More

Deleting Devices

Last updated on 07 October, 2024

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

Deleting Device

URI: DELETE device/devices/{id}

ParameterTypeDescription
deleteHardBooleanIndicates if you want to permanently delete the device. By default, it is set to true.
idInteger(Mandatory) It is the ID of the device that you want to delete.

Example

Use the following Python script to delete a device with ID 425 from api.logicmonitor.com 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 = '/device/devices/425'
data = ''
 
#Construct URL
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath
 
#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.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

Deleting Device Properties

URI: DELETE /device/devices/{deviceId}/properties/{name}

ParameterTypeDescription
deviceIdInteger(Mandatory) The ID of the device whose property you want to delete.
nameString(Mandatory) The name of the property that you want to delete.

Example

The following Python script deletes the property with the name prod1.

#!/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 = '/device/devices/4374/properties/prod1'
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
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.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
In This Article