Get SLA

Last modified on March 27, 2024

Get the service-level agreement (SLA) configuration by SLA ID.

To get an SLA by monitor ID, use GET /slas?monitor_id={id} instead.

Request URL

GET https://api.alertsite.com/api/v3/slas/{id}[?select=field1,field2,...]

Authentication

The request must include the Authorization header containing a user’s access token:

Authorization: Bearer ACCESS_TOKEN

See Authentication for more information.

Parameters

id

Integer. SLA ID.

select

String. A comma-separated list of blackout data fields to return in the response. The field names are case-sensitive. Unrecognized field names are ignored.

If this parameter is omitted, all fields are included. Note that select= with an empty value is not the same as an omitted parameter, and means no fields will be returned.

For more information, see Filter response fields.

For a list of field names that can be used in the select parameter, see SLA Object.

Response body

On success, the operation returns HTTP status 200 and a JSON representation of an SLA object.

{
  "availability": 97,
  "description": "Home page SLA",
  "exclusions": [
    {
      "from_date": "2018-10-20 04:17:00",
      "id": 2413,
      "location_description": "-- All --",
      "location_id": 10,
      "note": "ISP outage",
      "thru_date": "2018-10-20 04:25:00"
    }
  ],
  "id": 1234,
  "monitor_id": 123456,
  "monitor_name": "Home page",
  "name": "Home Page SLA",
  "operating_periods": [
    {
      "exclude": false,
      "from_day": 1,
      "from_time": "00:00",
      "id": 3214,
      "thru_day": 7,
      "thru_time": "23:59"
    }
  ],
  "response_time": 2,
  "secondary_response_time": 0,
  "uptime": 99.5,
  "uptime_allowed": true,
  "use_fullpage_time": false,
  "use_fullpage_time_allowed": true
}

Error responses have a non-200 status code and include the errors list:

{
  "errors": [
    {
      "code": 404,
      "message": "Record not found"
    }
  ]
}

Try it out

Click here to test this operation in AlertSite’s interactive API console.

Code examples

cURL

Get the SLA with ID 1234:

curl https://api.alertsite.com/api/v3/slas/1234 -H "Authorization: Bearer ACCESS_TOKEN"

Get service-level objectives (availability, uptime, response time) for SLA ID 1234:

curl https://api.alertsite.com/api/v3/slas/1234?select=availability,uptime,response_time -H "Authorization: Bearer ACCESS_TOKEN"

Python

This code outputs SLA information for SLA ID 1234.

Python

# Python 3.5+
import requests  # Requests library http://docs.python-requests.org
import json

baseUrl = 'https://api.alertsite.com/api/v3'
username = '[email protected]'  # Replace with your AlertSite login email
password = 'pa55w0rd'          # Replace with your AlertSite password
sla_id = 1234

# Log in
payload = {'username': username, 'password': password}
r = requests.post(baseUrl + '/access-tokens', data=json.dumps(payload), headers={'Content-Type': 'application/json'})
token = r.json()['access_token']

# Get the SLA configuration
r = requests.get(baseUrl + '/slas/{}'.format(sla_id), headers={'Authorization': 'Bearer ' + token})
if r.status_code == requests.codes.ok:
    print(json.dumps(r.json(), indent=2))
else:
    print('Could not get SLA #{}. The following error(s) occurred:'.format(sla_id), *r.json()['errors'], sep='\n')

See Also

SLA Operations

Highlight search results