Get a Single Blackout

Last modified on March 27, 2024

Get blackout configuration for the specified blackout ID. This can be a monitor blackout or a recipient blackout.

Request URL

GET https://api.alertsite.com/api/v3/blackouts/{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. Blackout 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 Blackout Object.

Response body

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

Recurring (persistent) blackout example:

{
  "assoc_id": 123808,
  "date_added": "2018-06-08T13:08:18Z",
  "end_day": 2,
  "end_time": "16:10",
  "from_date": null,
  "id": 1298524,
  "login": null,
  "note": null,
  "persistent": true,
  "start_day": 2,
  "start_time": "16:08",
  "thru_date": null,
  "type": "Monitor"
}

One-time blackout example:

{
  "assoc_id": 189477,
  "date_added": "2016-04-28T15:52:38Z",
  "end_day": null,
  "end_time": null,
  "from_date": "2016-04-29 10:52:00",
  "id": 1178507,
  "login": "[email protected]",
  "note": "Scheduled maintenance",
  "persistent": false,
  "start_day": null,
  "start_time": null,
  "thru_date": "2016-04-29 12:52:00",
  "type": "Recipient"
}

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 blackout # 123456:

curl https://api.alertsite.com/api/v3/blackouts/123456 -H "Authorization: Bearer ACCESS_TOKEN"

Get from_date and thru_date of a one-time blackout # 123456:

curl https://api.alertsite.com/api/v3/blackout/123456?select=from_date,thru_date -H "Authorization: Bearer ACCESS_TOKEN"

Python

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
blackout_id = 123456

# 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 blackout configuration
r = requests.get(baseUrl + '/blackouts/{}'.format(blackout_id), headers={'Authorization': 'Bearer ' + token})
if r.status_code == requests.codes.ok:
    print(json.dumps(r.json(), indent=2))
else:
    print('Could not get blackout #{}. The following error(s) occurred:'.format(blackout_id), *r.json()['errors'], sep='\n')

See Also

Blackout Operations

Highlight search results