Add SDTs
Last updated on 13 October, 2023You can use LogicMonitor’s REST API to programmatically add new SDTs.
As with all of our API calls, authentication is required.
HTTP Method:POST
URI: /sdt/sdts
The request parameters that need to be included in your request depends on the type of SDT you’re adding:
Add a One Time SDT
Request Parameters: You can POST the following properties for a new one time SDT:
Property | Description | Required? | Values | Type |
type | The type resource that this SDT is for. You can set SDTs for Services, Service Groups, Devices, Device Groups, Collectors, Batchjobs, Eventsources, Datasources, Instances & Instance Groups. Depending on the type of SDT, you’ll need to include additional information — see below this table for details. | Yes | ServiceSDT | ServiceGroupSDT | DeviceSDT | DeviceGroupSDT | CollectorSDT | DeviceBatchJobSDT | DeviceDataSourceSDT | DeviceEventSourceSDT | DeviceDataSourceInstanceSDT | DeviceDataSourceInstanceGroupSDT | String |
sdtType | The recurrence type of this SDT | Yes | For a One Time SDT, “sdtType”:1 | Integer |
comment | The comment associated with the SDT | No | This value defaults to a blank String | String |
startDateTime | The epoch time, in milliseconds,that the SDT will start | Yes | – | Integer |
endDateTime | The epoch time, in milliseconds, that the SDT will end | Yes | – | Integer |
Website SDTs
For SDTs of type=ServiceSDT (note that this is a website SDT, and does not relate to LM Service Insight), you must provide one of serviceId & serviceName:
Property | Description | Type |
serviceId | The id of the website that the SDT will be associated with | Integer |
serviceName | The name of the website that this SDT will be associated with | String |
Website Group SDTs
For SDTs of type=ServiceGroupSDT (note that this is a website group SDT, and does not relate to LM Service Insight), you must provide one of serviceGroupId. The serviceGroupName is optional:
Property | Description | Type |
serviceGroupId | Required. The id of the website group that the SDT will be associated with | Integer |
serviceGroupName | The name of the website group that this SDT will be associated with | String |
Device SDTs
For SDTs of type=DeviceSDT, you must provide the deviceId or the deviceDisplayName:
Property | Description | Type |
deviceId | The id of the device that the SDT will be associated with | Integer |
deviceDisplayName | The name of the device that this SDT will be associated with | String |
Device Group SDTs
For SDTs of type=DeviceGroupSDT, you must provide one of deviceGroupId & deviceGroupFullPath AND one of dataSourceId & dataSourceName:
Property | Description | Type |
deviceGroupId | The id of the device group that the SDT will be associated with | Integer |
deviceGroupFullPath | The full path of the device group that this SDT will be associated with | String |
dataSourceId | The id of the datasource that this SDT will be associated with, for the specified group. dataSourceId 0 indicates all datasources. | Integer |
dataSourceName | The name of the datasource that this SDT will be associated with, for the specified group. dataSourceName “All” indicates all datasources. | String |
Collector SDTs
For SDTs of type=CollectorSDT, the following parameter is required:
Property | Description | Type |
collectorId | The id of the collector that the SDT will be associated with | Integer |
Device DataSource SDTs
For SDTs of type=DeviceDataSourceSDT, you must provide either deviceDataSourceId OR the combination of dataSourceName, and either deviceId or deviceDisplayName:
Property | Description | Type |
deviceDataSourceId | The id of the device datasource that the SDT will be associated with | Integer |
deviceId | The id of the device associated with the datasource that the SDT will apply to | Integer |
deviceDisplayName | The display name of the device associated with the datasource that the SDT will apply to | String |
dataSourceName | The name of the datasource that the SDT will apply to | String |
Device Eventsource SDTs
For SDTs of type=DeviceEventSourceSDT, you must provide either deviceEventSourceId OR the combination of eventSourceName and either deviceId or deviceDisplayName:
Property | Description | Type |
deviceEventSourceId | The id of the device eventsource that the SDT will be associated with | Integer |
deviceId | The id of the device associated with the eventsource that the SDT will apply to | Integer |
deviceDisplayName | The display name of the device associated with the eventsource that the SDT will apply to | String |
eventSourceName | The name of the eventsource that the SDT will apply to | String |
Device Batchjob SDTs
For SDTs of type=DeviceBatchJobSDT, you must provide either deviceBatchJobId OR the combination of batchJobName and either deviceId or deviceDisplayName:
Property | Description | Type |
deviceBatchJobId | The id of the device batchjob that the SDT will be associated with | Integer |
deviceId | The id of the device associated with the batchjob that the SDT will apply to | Integer |
deviceDisplayName | The display name of the device associated with the batchjob that the SDT will apply to | String |
batchJobName | The name of the batchjob that the SDT will apply to | String |
Instance SDTs
For SDTs of type=DeviceDataSourceInstanceSDT, the following parameters are required:
Property | Description | Type |
dataSourceInstanceId | The id of the datasource instance that the SDT will be associated with | Integer |
deviceId | The id of the device that the SDT will be associated with | Integer |
Instance Group SDTs
For SDTs of type=DeviceDataSourceInstanceGroup, you must provide one of deviceDataSourceInstanceGroupId and deviceDataSourceInstanceGroupName:
Property | Description | Type |
deviceDataSourceInstanceGroupId | The id of the device datasource instance group that the SDT will be associated with | Integer |
deviceDataSourceInstanceGroupName | The name of the device datasource instance group that the SDT will be associated with | String |
Example 1: Add a One-Time website SDT
The following Python script adds a one-time website SDT to the website with an id of 47:
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
#Account Info
AccessId ='YQQ75w6Mxx9zWIeAMq5H'
AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8'
Company = 'api'
#Request Info
httpVerb ='POST'
resourcePath = '/sdt/sdts'
data = '{"sdtType":1,"type":"ServiceSDT","serviceId":47,"startDateTime":1469134752000,"endDateTime":1469144995000}'
#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
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)
Example 2: Add a One-Time Device SDT
The following Python script adds a one-time device SDT to the device with an id of 39:
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
#Account Info
AccessId ='YQQ75w6Mxx9zWIeAMq5H'
AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8'
Company = 'api'
#Request Info
httpVerb ='POST'
resourcePath = '/sdt/sdts'
data = '{"sdtType":1,"type":"DeviceSDT","deviceId":39,"startDateTime":1469134752000,"endDateTime":1469144995000}'
#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
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)
Add a Repeating SDT
Request Parameters: You can POST the following parameters for a new repeating SDT:
Property | Description | Required? | Values | Type |
type | The type resource that this SDT is for. You can set SDTs for Services, Service Groups, Devices, Device Groups, Collectors, Batchjobs, Eventsources, Datasources, Instances & Instance Groups. Depending on the type of SDT, you’ll need to include additional information — see above this table for details. | Yes | ServiceSDT | ServiceGroupSDT | DeviceSDT | DeviceGroupSDT | CollectorSDT | DeviceBatchJobSDT | DeviceDataSourceSDT | DeviceEventSourceSDT | DeviceDataSourceInstanceSDT | DeviceDataSourceInstanceGroupSDT | String |
sdtType | The recurrence type of this SDT | Yes |
| Integer |
comment | The comment associated with the SDT | No | This value defaults to a blank String | String |
weekDay | The day of the week that the SDT will be active for a weekly SDT | No |
This value defaults to 1 | Integer |
monthDay | The day of the month that the SDT will be active for a monthly SDT | Yes, for sdtType=3 | 1 | 2….. | 31 | Integer |
hour | The hour that the SDT will be active for a repeating SDT (daily, weekly, monthly) | No | 0 | 2….. | 23. This value defaults to 0 | Integer |
minute | The minute of the hour that the SDT will begin for a repeating SDT (daily, weekly, monthly) | No | 0 | 2….. | 59. This value defaults to 0 | Integer |
endHour | The hour that the SDT will end for a repeating SDT (daily, weekly, monthly) | No | 0 | 2….. | 23. This value defaults to 0 | Integer |
endMinute | The minute of the hour that the SDT will be ends for a repeating SDT (daily, weekly, monthly) | No | 0 | 2….. | 59. This value defaults to 0 | Integer |
duration | The duration of the SDT, in minutes | No | This value defaults to 0 | Integer |
Example 3: Add a Weekly Website SDT
The following Python adds a weekly website SDT for website 23, where the SDT is effective for one hour every Sunday:
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
#Account Info
AccessId ='YQQ75w6Mxx9zWIeAMq5H'
AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8'
Company = 'api'
#Request Info
httpVerb ='POST'
resourcePath = '/sdt/sdts'
data = '{"sdtType":2,"type":"ServiceSDT","serviceId":23,"weekDay":1,"hour":16,"minute":30,"endHour":17,"endMinute":30}'
#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
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)
Example 4: Add a Monthly Device SDT
The following Python script adds a monthly device SDT for device 47, where the SDT is effective for one hour on the 15th of every month:
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
#Account Info
AccessId ='YQQ75w6Mxx9zWIeAMq5H'
AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8'
Company = 'api'
#Request Info
httpVerb ='POST'
resourcePath = '/sdt/sdts'
data = '{"sdtType":3,"type":"DeviceSDT","deviceId":47,"monthDay":15,"hour":16,"minute":30,"endHour":17,"endMinute":30}'
#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
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)
Example 5: Add a Daily Website SDT
The following Python script adds a daily website SDT for website 23, where the SDT is effective for one hour every day:
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
#Account Info
AccessId ='YQQ75w6Mxx9zWIeAMq5H'
AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8'
Company = 'api'
#Request Info
httpVerb ='POST'
resourcePath = '/sdt/sdts'
data = '{"sdtType":4,"type":"ServiceSDT","serviceId":23,"hour":16,"minute":30,"endHour":17,"endMinute":30}'
#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
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)