LogicMonitor REST API version 3 (also referred as API v3) is the actively supported version. While API v1 and v2 remain functional, they no longer receive updates. To take advantage of the latest features, enhancements, and security improvements, LogicMonitor recommends migrating to API v3.

Reasons to migrate to LogicMonitor REST API v3:

It is essential to understand the impact of migration to API v3 on your existing integrations. In API v3, there are significant improvements to authentication methods, response formats, and error handling that can impact your custom scripts and applications. You must understand these changes to ensure smooth transition and prevent potential disruption of your workflows.

LogicMonitor provides the following product documentation for your migration:

If you have any questions or require assistance during the migration process, contact the Support team.

For more information, see the following:

To migrate to LogicMonitor REST API v3, you need the following:

LogicMonitor REST API v3 Migration Considerations

LogicMonitor REST API v3 has all the enhancements and fixes compared to API v2. The following are key highlights why you must migrate to API v3:

LogicMonitor REST API v2 to v3 Changes

Version Header for REST API v2 to API v3

You can make API v3 request using one of the following version headers:

For more information, see REST API v3 Swagger Documentation.

API Response Format for REST API v2 and API v3

There is no difference in the success and error response format of API v2 and API v3. Therefore, migrating from API v2 to API v3 does not require any changes to the parsing logic.

Success Response for REST API v2 and v3

The success response format for API v3 is as follows:

{
   <API specific data>
}

Error Response for REST API v2 and API v3

The error response format for API v3 is as follows:

{
    "errorMessage": <ERROR_MESSAGE>,
    "errorCode": <ERROR_CODE>,
    "errorDetail": null
}

Example of Response Format in Python Code

import json
  
# Success Response Handling
def handle_success_response(json_response):
    response = json.loads(json_response)
    # Process the fields directly from the response
    # Example: total = response['total']
  
# Error Response Handling
def handle_error_response(json_response):
    response = json.loads(json_response)
    error_message = response['errorMessage']
    error_code = response['errorCode']
    error_detail = response['errorDetail']
    # Process the error message, code, and detail

LogicMonitor REST API v3 is far more advance than API v1. All enhancements and fixes are done only to API v3. The following are key highlights why you must migrate to API v3:

Requirements for Migration from LogicMonitor REST API v1 to API v3

To migrate to API v3, you need the following:

LogicMonitor REST API v1 to API v3 Changes

You must note the following changes in both the API v1 and API v3:

Support for Token-based Authentication

Starting with API v2, LogicMonitor no longer supports basic authentication. It is done to encourage use of API tokens for authentication. The API tokens are secure, they help in separation of LogicMonitor portal and LogicMonitor REST API access, and audit log entries.

To encourage use of taken-based authentication, LogicMonitor supports LMv1 API and bearer token for API v2 and API v3. For more information, see REST API Authentication.

Support for PATCH Method

API v3 includes support for PATCH method for most of the API endpoints. You may find this useful for updating specific fields of an endpoint, instead of using the PUT method for updating all the fields (that is, the entire API endpoint). For more information, see REST API v3 Swagger Documentation.

Version Header for REST API v1 to API v3

You can make API v3 request using one of the following version headers:

For more information, see REST API v3 Swagger Documentation.

Adding Version Header using cURL

Enter the following command and use -H or --header followed by the header name and value:

curl -H "X-version: 3" https://COMPANY.logicmonitor.com/santaba/rest/device/devices/1
Bash
curl --header "X-version: 3" https://COMPANY.logicmonitor.com/santaba/rest/device/devices/1
Bash
curl "https://COMPANY.logicmonitor.com/santaba/rest/device/devices/1?v=3"
Bash

Adding Version Header using Python

Enter the following command and use the headers parameter in the requests library.

headers = {'X-Version':'3'}
response = requests.get("https://COMPANY.logicmonitor.com/santaba/rest/device/devices/1", headers=headers)
Python
response = requests.get("https://COMPANY.logicmonitor.com/santaba/rest/device/devices/1?v=3")
Python

API Response Format for REST API v1 to API v3

The following are the key updates to API response format:

Examples of Success Response Format for REST API v1 and API v3

The response payload of API v1 is different from API v3, hence the parsing of response has been changed. When the API successfully fetches the response, the response format is as follows:

{
    "status": 200,
    "errmsg": "OK",
    "data": {
            <API specific data fields and value>
    }
}
Python
{
   <API specific data, same data that we are returning in "data" field of API V1 response>
}
Python

Examples of Error Response Format for REST API v1 and API v3

In case of error response, the format is as follows:

{
    "data": null,
    "errmsg": <ERROR_MESSAGE>,
    "status": <ERROR_CODE>
}
Python
{
    "errorMessage": <ERROR_MESSAGE>,
    "errorCode": <ERROR_CODE>,
    "errorDetail": null
}
Python

Comparison of Parameter Differences between REST API v1 and API v3

When migrating from API v1 to API v3, you must consider the differences in API URL, error codes, and filter syntax.

Filter SyntaxAPI v1 Parameter ValueAPI v3 Parameter Value
Enclose value in double quotes (“”)GET /device/devices?filter=name:127.0.0.1GET /device/devices?filter=name:"127.0.0.1"
Encode twice values with special character “+” GET /device/devices?filter=name:Prod+ServerGET /device/devices?filter=name:"Prod%252BServer"
Encode once values with special characters EXCEPT “+” (&, -, and so on) GET /device/devices?filter=name:Prod&ServerGET /device/devices?filter=name:"Prod%26Server"

API URL Updates for REST API v1 and API v3

When migrating from API v1 to API v3, you must replace the API v1 URL with the API v3 URL. Some API URLs for components such as Collectors and Websites have changed. The mapping between the v1 and v3 URLs is given in the following table:

ComponentAPI v1 URLAPI v3 URL
CollectorsPOST /setting/collectorsPOST /setting/collector/collectors
GET /setting/collectorsGET /setting/collector/collectors
GET /setting/collectors/id/installers/idGET /setting/collector/collectors/id/installers/id
POST /setting/collectors/id/ackdownPOST /setting/collector/collectors/id/ackdown
DELETE /setting/collectors/idDELETE /setting/collector/collectors/id
PUT /setting/collectors/idPUT /setting/collector/collectors/id
PATCH /setting/collectors/idPATCH /setting/collector/collectors/id
GET /setting/collectors/idGET /setting/collector/collectors/id
Collector GroupsGET /setting/collectors/groups/idGET /setting/collector/groups/{id}
DELETE /setting/collectors/groups/idDELETE /setting/collector/groups/{id}
PUT /setting/collectors/groups/idPUT /setting/collector/groups/id
GET /setting/collectors/groupsGET /setting/collector/groups
POST /setting/collectors/groupsPOST /setting/collector/groups
WebsiteGET /service/smcheckpointsGET /website/smcheckpoints
GET /service/services/id/sdtsGET /website/websites/id/sdts
GET /service/services/id/propertiesGET /website/websites/{id}/properties
GET /service/services/id/graphs/id/dataGET /website/websites/id/graphs/id/data
GET /service/services/id/checkpoints/id/graphs/id/dataGET /website/websites/id/checkpoints/id/graphs/id/data
GET /service/services/id/checkpoints/id/dataGET /website/websites/id/checkpoints/id/data
GET /service/services/id/alertsGET /website/websites/id/alerts
DELETE /service/services/idDELETE /website/websites/id
PATCH /service/services/idPATCH /website/websites/id
PUT /service/services/idPUT /website/websites/id
GET /service/services/idGET /website/websites/{id}
POST /service/servicesPOST /website/websites
GET /service/servicesGET /website/websites
Website GroupsGET /service/groups/id/servicesGET /website/groups/id/websites
GET /service/groups/id/sdtsGET /website/groups/id/sdts
DELETE /service/groups/idDELETE /website/groups/id
PATCH /service/groups/idPATCH /website/groups/id
GET /service/groups/idGET /website/groups/{id}
PUT /service/groups/idPUT /website/groups/id
POST /service/groupsPOST /website/groups
GET /service/groupsGET /website/groups

Error Code Updates for REST API v1 and API v3

LogicMonitor has updated some error codes in API v3. When migrating from API v1 to API v3, you must consider the API v3 error codes. The mapping between the v1 and v3 error codes is given in the following table:

Note:

API v1 Error CodeAPI v3 Error CodeDefault New Error Message
34031400Bad request
24031404No such record
13121400Bad request
131014042No such company
130414041No such record in TSDB
13031400Bad request
13021404No such record
13011400Bad request
130014002Partial success
120114002Partial success
110414001Resource dependency
110115001Query timeout
11001429Too many requests
10911429Too many requests
10791400Bad request
10781400Bad request
10771400Bad request
10761400Bad request
10751413The request entity is too large
10741074Report refuse to view as timely
10731400Bad request
10691404No such record
10651404No such record
10601404No such record
10581404No such record
10531404No such record
10481404No such record
10411403Permission denied
10401400Bad request
10371404No such record
10351400Bad request
10331404No such record
10311400Bad request
10271404No such record
10261400Bad request
10251400Bad request
10221404No such record
10201400Bad request
10191400Bad request
10181400Bad request
10171400Bad request
10161400Bad request
10151404No such record
10141400Bad request
10131404No such record
10101400Bad request
10071400Bad request
10041404No such record
10011500Internal error
10001500Internal error
6001409The record already exists
5031404No such record
5001500Internal error
4031401Authentication failed
4001401Authentication failed
1001202The task is running

Error Code Update Examples for REST API v1 and API v3

Following are the examples of API v1 and API v3 of the Processing fields. 

import json
  
# Success Response Handling
def handle_success_response_v1(json_response):
    response = json.loads(json_response)
    status = response['status']
    errmsg = response['errmsg']
    data = response['data']
    # Process the fields from the data object
    # Example: total = data['total']
  
# Error Response Handling
def handle_error_response_v1(json_response):
    response = json.loads(json_response)
    status = response['status']
    errmsg = response['errmsg']
    data = response['data']
    # Process the error message and status
Python
#!/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 ='GET'
resourcePath = '/device/devices/1'
fields = 'id,name,displayName'
queryParams = '?fields=' + fields
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}
headers = {'X-version':'1','Content-Type':'application/json','Authorization':auth}
  
#Make request
response = requests.get(url, data=data, headers=headers)
  
#body of response
response_body = json.loads(response.content.decode('utf-8'))
print ('Response Body:',response_body)
  
status = response_body['status']
if (status == 200):
    #Fetch data from body of response
    data = response_body['data']
  
    #Read device fields value from data
    device_name = data['name']
    device_displayName = data['displayName']
    print ("name:", device_name)
    print ("displayName:", device_displayName)
else:
    data = response_body['data']
    errmsg = response_body['errmsg']
    print ("Error status code:",status)
    print ("Error data:",data)
    print ("Error message:",errmsg)
Python
import json
  
# Success Response Handling
def handle_success_response_v3(json_response):
    response = json.loads(json_response)
    # Process the fields directly from the response
    # Example: total = response['total']
  
# Error Response Handling
def handle_error_response_v3(json_response):
    response = json.loads(json_response)
    error_message = response['errorMessage']
    error_code = response['errorCode']
    error_detail = response['errorDetail']
    # Process the error message, code, and detail
Python
#!/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 ='GET'
resourcePath = '/device/devices/1'
fields = 'id,name,displayName'
queryParams = '?fields=' + fields
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 = {'X-version':'3','Content-Type':'application/json','Authorization':auth}
  
#Make request
response = requests.get(url, data=data, headers=headers)
  
#body of response
print ('Response Status:',response.status_code)
response_body = json.loads(response.content.decode('utf-8'))
print ('Response Body:',response_body)
  
status = response.status_code
if (status == 200):
    #Read device fields value from response_body
    device_name = response_body['name']
    device_displayName = response_body['displayName']
    print ("name:", device_name)
    print ("displayName:", device_displayName)
else:
    errorMessage = response_body['errorMessage']
    errorCode = response_body['errorCode']
    errorDetail = response_body['errorDetail']
    print ("Error status code:",errorCode)
    print ("Error details:",errorDetail)
    print ("Error message:",errorMessage)
Python

This article highlights the changes to LogicMonitor REST API with each version. It aims to give you a clear view of how our APIs have evolved and improved.

Updates in v224 Platform Release

In v224 Platform release, LogicMonitor has made the following updates to API v3 Swagger and SDK files.

For more information, see REST API v3 Swagger Documentation

New Endpoints Added to API v3 Swagger and SDK Files

In v224 Platform release, LogicMonitor has updated LogicMonitor REST API v3 Swagger, v3 Python, and GO SDK files with the following new endpoints.

CategoryEndpointPurpose
Cost Optimization RecommendationsGET /cost-optimization/recommendations/categoriesGet a list of recommendation categories
GET /cost-optimization/recommendationsGet a list of recommendations
GET /cost-optimization/recommendations/{id}Get details of a recommendation based on the ID

Display of x-minimum-permissions Metadata in API v3 Swagger

To strengthen security, LogicMonitor REST API v3 Swagger now includes the x-minimum-permissions metadata in the Extensions section of each API endpoint. This metadata specifies the minimum permission required to access the API endpoint.

Recommendation: Use the minimum necessary permissions to make LogicMonitor REST API v3 request.

Updates in v210 Platform Release

In v210 Platform release, we have updated LogicMonitor REST API v3 Swagger, v3 Python and GO SDK files with the following new endpoints.

CategoryEndpointPurpose
ConfigSourcesPATCH/setting/configsources/{id}Update ConfigSource by ID
GET/setting/configsources/{id}Get ConfigSource by ID
DELETE/setting/configsources/{id}Delete ConfigSource by ID
PUT/setting/configsources/{id}Update ConfigSource by ID
POST/setting/configsourcesAdd ConfigSource
GET/setting/configsourcesGet ConfigSource list
EventSources



POST /setting/eventsourcesAdd EventSource
PATCH /setting/eventsources/{id}Update EventSource by ID
GET /setting/eventsources/{id}Get EventSource by ID
DELETE /setting/eventsources/{id}Delete EventSource by ID
PUT /setting/eventsources/{id}Update EventSource by ID
JobMonitor




PATCH /setting/batchjobs/{id}Update JobMonitor
GET /setting/batchjobs/{id}Get JobMonitor by ID
DELETE /setting/batchjobs/{id}Delete JobMonitor
PUT /setting/batchjobs/{id}Update JobMonitor
POST /setting/batchjobsAdd JobMonitor
GET /setting/batchjobsGet JobMonitor list
OID




PATCH /setting/oids/{id}Update an OID
GET /setting/oids/{id}Get OID by ID
DELETE /setting/oids/{id}Delete an OID
PUT /setting/oids/{id}Update an OID
POST /setting/oidsAdd an OID
GET /setting/oidsGet OID list
PropertySource




PATCH /setting/propertyrules/{id}Update a property rule
GET /setting/propertyrules/{id}Get property rules by ID
DELETE /setting/propertyrules/{id}Delete a property rule
PUT /setting/propertyrules/{id}Update a property rule
POST /setting/propertyrulesAdd a property rule
GET /setting/propertyrulesGet property rules list
TopologySource




PATCH /setting/topologysources/{id}Update TopologySource
GET /setting/topologysources/{id}Get TopologySource by ID
DELETE /setting/topologysources/{id}Delete TopologySource
PUT /setting/topologysources/{id}Update TopologySource
POST /setting/topologysourcesAdd TopologySource
GET /setting/topologysourcesGet TopologySource List
ThresholdGET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/alertsettings/{id}Get a list of alert settings for a specific device datasource instance
POST /device/groups/{deviceGroupId}/clusterAlertConfAdd cluster alert configuration
GET /device/groups/{deviceGroupId}/clusterAlertConfGet a list of cluster alert configurations for a device group
DELETE /device/groups/{deviceGroupId}/clusterAlertConf/{id}Delete cluster alert configuration
PATCH /device/groups/{deviceGroupId}/clusterAlertConf/{id}Update cluster alert configuration
PUT /device/groups/{deviceGroupId}/clusterAlertConf/{id}Update cluster alert configuration
GET /device/groups/{deviceGroupId}/clusterAlertConf/{id}Get cluster alert configuration by ID
DevicesGET /device/devices/{deviceId}/alertsettingsGet all thresholds for all instances of a given device
GET /device/devices/{id}/endpointsGet NetFlow endpoints
GET /device/devices/{id}/portsGet NetFlow ports
DataGET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/config/{id}Get configuration for a device

Updates in v207 Platform Release

In v207 Platform release, we have updated LogicMonitor REST API v3 Swagger with the accessGroups and accessGroupIds fields. You can find the fields in the response of the following API endpoints:

AppliesToFunctions

GET /setting/functions

GET /setting/functions/{id}

Datasources

GET /setting/datasources

GET /setting/datasources/{id}

ParameterTypeDescription
createdByString(Read only) The name of the user who created the access group.
nameString(Mandatory) The name of the access group. For example, LinuxGroup
tenantIdStringThe ID of the tenant and tenancy details.
descriptionStringThe description of the access group.
idInteger(Read only) The ID of the access group.
updatedOnInteger(Read only) Time when the access group was updated.
createdOnInteger(Read only) Time when the access group was created.
accessGroupIdIntegerThe ID of the access group.

Updates in v201 Platform Release

Starting with Platform release v201, in addition to the existing filter _all~ you can also use a new filter description~ to search for specific data.

Updates in v200 Platform Release

In v200 Platform release, we have updated LogicMonitor REST API v3 Swagger with the following fields:

The impacted API endpoints are:

Updates in v198 Platform Release

Updates to Swagger and SDK Files

In v198 Platform release, we have updated LogicMonitor REST API v3 Swagger and v3 Python and GO SDK files. The Swagger and SDK files will be available after v198 deployment to production is complete. For any questions, contact your LogicMonitor Customer Success Manager. For details, see REST API v3 Swagger Documentation.

Refer to the following table for the new API endpoints that are added to LogicMonitor REST API v3.

CategoryEndpointsPurpose
Device GroupsPOST /azure/functions/discoverSubscriptions
POST /azure/functions/testAccount
GET /aws/accountId
POST /aws/functions/testAccount
POST /saas/functions/testAccount
POST /gcp/functions/testAccount
View subscription IDs
Test Azure account
Get AWS account ID
Test AWS account
Test SaaS account
Test GCP account
ReportGET /report/reports/{id}/tasks/{taskId}Run a report
userdataPATCH /setting/userdata/{id}
PUT /setting/userdata/{id}
Update default Dashboard
ConfigSourceGET /setting/configsources/{id}/updatereasonsGet update history for a configSource
DatasourcesPOST /setting/datasources
PUT /setting/datasources/{id}
PATCH /setting/datasources/{id}
Add datasource
Update datasource
Dashboard GroupsPOST /dashboard/groups/{id}/asynccloneAdd dashboard group asynchronously
DataSource InstancesPOST /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups
PUT /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups/{id}
PATCH /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups/{id}
Add device datasource instance group 
Update device datasource instance group 
DataPOST /device/instances/datafetchFetch device instance data
DeltaGET /device/devices/delta
GET /device/devices/delta/{deltaId}
Get filter matched devices with new Delta ID
Get delta devices using Delta ID

Refer to the following table for the API endpoints that are removed from LogicMonitor REST API v3.

CategoryEndpoint
DatasourcesPOST /setting/datasources/{id}/audit
ConfigSourcePOST /setting/configsources/{id}/audit
PropertySourcesPOST /setting/propertyrules/{id}/audit 
EventSourcesPOST /setting/eventsources/{id}/audit

Block Access to LM REST API v4 using Bearer Token

Starting with v198 release, you will not be able to use bearer token to authenticate yourself to use LogicMonitor REST API v4 external endpoints. We have already disabled Basic and LMv1 authentication to use API v4. Note that API v4 is not officially supported. We recommend you to use LogicMonitor REST API v3.

Bearer Token Support for Python and GO SDK

You can now use Bearer token to authenticate yourself to use GO and Python v3 SDK. The SDK files will be available after v198 deployment to production is complete. For any questions, contact your LogicMonitor Customer Success Manager. For details, see LogicMonitor v3 SDK.

Additional Updates

General Changes

REST API v1 and v2 Sunset Notice

We have decided to sunset LogicMonitor REST API v1 and v2. We encourage you to migrate to API v3 starting April 2023. We will continue to support API v1 and v2 until October 2024 and then stop supporting them. We will communicate the end of support date in advance to help you migrate to API v3. For more info, see LogicMonitor REST API v1 and v2 Sunset.

REST API Filters

When you call the endpoint GET /alert/alerts with filters, previously, even if there were no new alerts the result was inconsistent and shuffled. We have fixed this issue. As long as no new alert is generated or an existing one cleared, the result does not shuffle and the sequence of alerts list remains consistent. For more info, see REST API Basic Filters and REST API Advanced Filters.

LMv1 Token

Applications consume APIs and SDKs to connect with multiple backend platforms which provide tokens/secrets for authentication of the APIs and SDKs with backend platforms. To authenticate, many times users enter the secrets/tokens along with the source code leading to major security issue. As a security measure, we have now revised the token format. 

LMv1 token is dynamically built using access_id+access_key+payload+time+http_method. It is valid only for 10 minutes, thus storing it or committing in the repository serves no purpose.

Changes in REST API v3

Addition of numOfKuberntesDevices field

We added a numOfKuberntesDevices field to the DeviceGroup API model. It is present in the response body of all the endpoints that refer to the DeviceGroup API model. It indicates the number of Kubernetes resources in the target group. It also includes the count of Kubernetes resources in the sub groups of the target group.

Examples: 

HTTP MethodAPI Response
GET
PUT
PATCH
santaba/rest/device/groups/{id}
POST
GET
santaba/rest/device/groups

If you select:

New Endpoints

The major highlight of REST API v3 is the addition of five new endpoints. They are:

For more information, see REST API v3 Swagger Documentation.

Changes in REST API v2

LogicMonitor REST API v2 includes new features, including non-backwards compatibility.

Status Codes

In REST API v1, there were two status codes for a response: HTTP status code (almost always 200), and a different LogicMonitor status code in the response body. With REST API v2, we’re returning one HTTP status code, and we’ve considerably narrowed the list of possible status codes that will be returned. 

No Basic Authentication Support

We’ve removed support for basic authentication with REST API v2. We did this to encourage more use of API tokens for authentication, as there are many additional benefits (separation of UI / API access, audit log entries, and more secure).

Support for PATCH Method

REST API v2 includes support for HTTP PATCH for most resources. You may find this useful for updating just one field of a resource, instead of having to use PUT to update the entire resource (all fields). 

Response Body Structure

In REST API v1, successful responses included status, errmsg, and data objects at the top level of the response. With REST API v2, since the HTTP status now matches the LM status, the contents of ‘data’ will be returned at the top level for a successful response. A non-successful response will include error message fields. Note that this does mean that scripts written for REST API v1 and configured to parse API response should be adjusted to reflect this.

Recommendation: Use LogicMonitor REST API v3 to programmatically leverage the latest features and enhancements. LogicMonitor does not add new features endpoints to earlier API versions. If you are leveraging earlier versions of the API, see About REST API v2 or About REST API v1.

For more information regarding LogicMonitor’s sunset updates of the REST API, see Updates for LogicMonitor REST API v1, v2, and v3 in the Community.

LogicMonitor REST API v3 Swagger documentation contains a complete list of v3 API endpoints and Models related to the endpoints. You can expand each API endpoint to explore the details. It contains request and response parameters with examples and description.

v3 Swagger Doc

When an unsuccessful request is made, in LogicMonitor REST API v2 and v3, the response body will contain an errorCode field with one of the following codes:

HTTP Status CodeAPI v2 & v3 Error CodeDescription
2021202The request has been accepted for processing, but the processing has not been completed.
4001400Bad request (resource cannot be deleted because something else is dependent on it)
4011401Authentication failed
4031403Authentication succeeded; permission denied.
4041404No such resource
4091409The resource already exists
4121412A precondition was not met (two factor authentication)
4131413Request entity too large (the report is too large to generate)
4291429Too many requests (exceeded rate limits) 
5001500Internal error

Along with a data object, the response body contains a ‘status’ field which should display one of the following codes for v1 of the API:

Status CodeDescription
200Success
1201The update was partially successful.
600The record already exists.
1041RBAC issue
1403Two-factor authentication is required.
403Authentication failure
2403User must enable two-factor authentication
3403Incorrect password
1001Internal error
1007Request failed – possibly due to duplicate records
1069, 500No such record
1013, 1004, 1015, 1022, 1027, 1033, 1037, 1060, 1058, 1048No such Device DataSource, Device Group, Instance Group, DataSource, Instance, Collector, Datapoint, Widget, SDT
1101Query timed out
1010Device Group was not deleted
1014Instance group cannot be created
1301Save failed
1074Report too large
1073Collector is down
1040Import DataSource failed

When a REST API operation fails, an error code is provided in the response body. This can happen due to invalid or incorrect inputs or issues in the server. We use standard HTTP error codes to indicate the error in the response body. 

This table will help you understand more about errors and ways to resolve them. The following are default error messages, and can differ as per API.

Error CodeError Message
1202The task is running
1400Bad request
1409The record already exists
1403Permission denied
1500Internal error
1204No Content
1404No such record
14004Error in query string parameters
14002Partial success
1412The supplied precondition evaluated to false
1313Report in progress
1413The request entity is too large
14001Resource Dependency
14003Properties must start with a letter to be valid.
1401Authentication failed
14042No Such Company
1303All Locations are disable / No valid locations selected
403Authentication failed
1007Bad request
1078Please upload a .docx file
1000Server is busy
1040Cannot import LogicModule 
1100Too many requests
1073The collector isn’t active
503Company is deactive
100Continuing …
1104Resource Dependency
1075The request entity/report is too large
1001Internal error
500Internal error
1031There is a syntax error in the appliesTo field.
1077Invalid Macros / Bad request
1074Report too large
1076Template too large
1000Server is busy
1301Save failed
1065No such company
1069No such record
1058No such widget
1201Partial success /  The update was partially successful
1041Permission denied
1091Rate exceed
403Session timeout
1079The report template could not be uploaded
1101Query timed out
600The record already exists
1001Unknown error

Each request sent to the LogicMonitor server is made over HTTPS and thoroughly authenticated. All data is received as JSON.  LogicMonitor’s REST API supports the API token authentication method.

LogicMonitor API authentication differs as per versions.

Bearer Token

The bearer token is a combination of multiple alpha numeric characters and is auto-generated by LogicMonitor. You can use bearer token to authenticate yourself to use LogicMonitor Python and GO v3 SDK files, and LogicMonitor REST API v3.

As a LogicMonitor customer, when you buy a license for a device you are eligible to get a bearer token. You do not need a specific role to get the token. It is unique for each user.

Once you get the bearer token, you must add it to the API requests just once. LogicMonitor REST API code reuses the token without you having to enter it every time. As a developer using LogicMonitor REST API, you need not develop authentication header or write commands to authenticate yourself.

To maintain secrecy of the bearer token, once you save the token, the system automatically masks some part of it with asterisks (*). For more information, see Bearer Token.

LMv1 Token

The LMv1 token-based authentication method requires that with every request you include a custom HTTP header containing:

Specifically, you must concatenate request details to form a string, and use your Access Key to calculate the HMAC-SHA256 of that string. You then need Base64 to encode the result. 

The complete Base64 encoded HMAC signature should be in the following format:

signature = base64(HMAC-SHA256(Access Key,HTTP VERB + TIMESTAMP (in epoch milliseconds) + POST/PUT DATA (if any) + RESOURCE PATH) )

The full authentication header must be in the following format:

Authorization: LMv1 AccessId:Signature:Timestamp

How is Authentication Done?

When LogicMonitor servers receive an API request, they ensure the specified timestamp is within 30 minutes of the current time. If that requirement is satisfied, they retrieve the Access Key associated with the specified Access ID and compute the signature in the above format. The servers compare that signature to the signature included in the request. If the two signatures match, the request is authenticated, but still subject to the permissions associated with the API Token (the token Access ID and Access Key must have sufficient permission to perform the requested action). In the event that the two signatures do not match, an error will be returned.

Note: Query parameters (for example: filter, fields, sort, and size) are not considered part of the resource path, and must not be included in the calculation of authentication signature.

Basic Authentication

LogicMonitor’s REST API for v1 supports HTTP Basic Authentication. To use HTTP Basic Authentication, each request must include an HTTP header with the following authentication information: Authorization:Basic `echo -n username:password | base64`

Almost all web clients support HTTP basic authentication and will construct this header for you.

In the following example, a user apiUser in account api.logicmonitor.com makes a request to update a website group.

Examples

curl --user 'apiUser:example' -H "Content-Type: application/json" -d '{"name":"newWebsiteGroup","description":"testSites","disableAlerting":false}' -X PUT "https://api.logicmonitor.com/santaba/rest/service/groups/7" -v

In the following example, a user apiUser in account api.logicmonitor.com makes a request to get all website groups.

wget --auth-no-challenge  --http-user='apiUser' --http-password='example' "https://api.logicmonitor.com/santaba/rest/website/groups"

Rate limits are imposed for requests to LogicMonitor’s REST API. Limits are assigned per endpoint and method combination. For example, requests to GET /device/devices may have a different limit than requests to POST /device/devices or requests to GET /device/devices/ID/devicedatasources. Requests that are made in excess of the rate limits will get an HTTP 429 Too Many Requests and a response containing an error. Limits are not per user, and will apply to all requests made for your account.

Important: Default limits are tested for occasional peak usage, and not continuous use of the API at these limits. Continuous use of the API at the rated limits can impact the overall performance of the portal. LogicMonitor gives the highest precedence to the portal availability and performance and, therefore, reserves the right to reduce the API limits from the defaults if portal performance, alerting, and data collection are adversely affected. If your needs exceed these design limits, please work with your customer success manager proactively to discuss possible options.

Rate Limit in Response Headers

Information about limits and proximity to limits is returned in the below response headers. This enables you to view the rate limits that will be imposed and adjust scripts as needed to work around them.

Header Description
X-Rate-Limit-Limit Request limit per X-Rate-Limit-Window
X-Rate-Limit-Remaining The number of requests left for the time window
X-Rate-Limit-Window The rolling time window length with the unit of second

Rate Limiting Logic

We recommend basing any logic intended to work around rate limiting on the above headers and their values, as the limits are subject to change. For example, you may introduce logic in your script that, when rate limits have been met, waits 60 seconds before making another request. The following are examples of such logic across various languages.

Python

The following logic can be utilized in a loop using the requests module, and implements a simple timeout if the ‘X-Rate-Limit-Remaining’ header value gets to zero.

if (response.headers['X-Rate-Limit-Remaining'] == 0):
       window = response.headers['X-Rate-Limit-Window']
       time.sleep(float(window))
Python

Ruby

The following logic can be utilized in a loop using the net http library, and implements a simple timeout if the ‘X-Rate-Limit-Remaining’ header value gets to zero.

if resp['X-Rate-Limit-Remaining'].to_i == 0
  sleep resp['X-Rate-Limit-Window'].to_i
  end
Ruby

Groovy

The following logic can be utilized in a loop using the Apache http library, and implements a simple timeout if the ‘X-Rate-Limit-Remaining’ header value gets to zero.

remainingRequestsHeader = response.getHeaders('X-Rate-Limit-Remaining');
windowHeader = response.getHeaders('X-Rate-Limit-Window');
remainingRequests = remainingRequestsHeader[0].getValue();
window = windowHeader[0].getValue();
 
if (remainingRequests.toInteger() == 0){
    Thread.sleep(window.toInteger() * 1000);
    }
Groovy

PowerShell

How you should work around rate limiting with PowerShell depends on how you’re making requests. The Invoke-RestMethod cmdlet throws out response headers unless an exception occurs, and as such we recommend attempting retries when an HTTP 429 is returned if using Invoke-RestMethod. For example, you could make the API request in a try catch loop, and retry if the resulting status is 429, as shown in the following code example.

(Alternately, you can use Invoke-WebRequest cmdlet and add logic based on the rate limiting response headers.)

<# Make request & retry if failed due to rate limiting #>
$Stoploop = $false
 
do {
	try {
		<# Make Request #>
		$response = Invoke-RestMethod -Uri $url -Method $httpVerb -Headers $headers
		<# Print status and body of response #>
		$status = $response.status
		$body = $response.data| ConvertTo-Json -Depth 5
		Write-Host "Status:$status"
		Write-Host "Response:$body"
		$Stoploop = $true
		}
	catch {
		if ($response.status -eq 429){
			Write-Host "Request exceeded rate limit, retrying in 60 seconds..."
			Start-Sleep -Seconds 60
			}
		else {
			Write-Host "Request failed, not as a result of rate limiting"
			$Stoploop = $true
			}
		}
	}
While ($Stoploop -eq $false)
PowerShell

Default Rate Limits

The following table lists the default rate limit per request type.

HTTP MethodRate Limit
DELETE300/min
GET500/min
PATCH250/min
POST200/min
PUT200/min

Rate Limit Exceptions

The following table lists the rate limit per endpoint/method request combination.

HTTP MethodAPI RequestRate LimitDescription
GET/cost-optimization/recommendations200/minGet a list of recommendations
GET/cost-optimization/recommendations/{id}200/minGet details of a specific recommendation based on ID
GET/cost-optimization/recommendations/categories200/minGet a list of available recommendation categories
GET/santaba/rest/alert/alerts400/minGet alert list
GET/santaba/rest/device/devices/{id}/alerts600/minGet alerts
GET/santaba/rest/device/groups400/minGet device group list
GET/santaba/rest/device/groups/{id}1000/minGet device group by ID
GET/santaba/rest/device/devices/{deviceId}/properties700/minGet device properties
GET/santaba/rest/device/devices700/minGet device list
GET/santaba/rest/device/devices/{deviceId}/devicedatasources/{hdsId}/instances500/minGet device instance list
POST/santaba/rest/setting/opsnotes100/minAdd opsnote
GETsantaba/rest/swagger.json10/minSwagger documentation
POSTsantaba/rest/device/instances/datafetch5/minGet instances data

Note: The endpoints which are not mentioned in the above table follow the default rate limit.