REST API Authentication

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.

  • v1 API authentication– Supports basic authentication.
  • v2 and v3 API authentication– Supports token-based authentication.

API Token-Based Authentication

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

  • Your API Token Access ID
  • A Base64 encoded HMAC signature based on your API Token Access Key
  • A timestamp in epoch milliseconds

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: LMv3 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 should 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 -v --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"

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"
In This Article