API > JSON API > Delete Monitor

Delete Monitor

To delete a monitor with, send a DELETE request to /devices/{id}, where {id} is the monitor ID.


Request URL

DELETE https://www.alertsite.com/alertsite-restapi/devices/{id}


This operation requires authentication. The authenticating user’s role must allow the user to delete monitors.

Request Body


Response Body

Successful response contains status 0:

  "metadata": {
    "login": "demo@example.com",
    "session": "ef770427109e343e",
    "status": "0",
    "message": "No errors."

Error response contains a non-zero status:

  "metadata": {
    "login": "demo@example.com",
    "session": "ef770427109e343e",
    "status": "65",
    "message": "Invalid device.",

Code Examples


These commands delete monitor 1234 using different authentication types.

Using the session ID:

curl -X DELETE "https://www.alertsite.com/alertsite-restapi/devices/1234?login=demo%40example.com&session=SESSION_ID"

Using the Authorization header with a bearer token:

curl -X DELETE -H "Authorization: Bearer BEARER_TOKEN" https://www.alertsite.com/alertsite-restapi/devices/1234


This code deletes monitor with ID 1234.

import requests  # Requests library - http://docs.python-requests.org
import json
import base64

baseUrl = 'https://www.alertsite.com/alertsite-restapi'
login = 'demo@example.com'  # Replace with your AlertSite login email
password = 'pa55w0rd'       # Replace with your AlertSite password
monitorId = 1234            # ID of the monitor to delete

# Log in
payload = {'login': login, 'password': password}
r = requests.post(baseUrl + '/login', data=json.dumps(payload), headers={'Content-Type': 'application/json'})
session = r.json()['metadata']['session']

# Generate the bearer token to authenticate subsequent requests
# For Python 2.4-2.x:
# token = base64.b64encode(login + ':' + session)
# For Python 3.x:
token = base64.b64encode((login + ':' + session).encode('ascii')).decode('ascii')

# Delete the monitor
r = requests.delete(baseUrl + '/devices/' + str(monitorId), headers={'Authorization': 'Bearer ' + token})
result = r.json()['metadata']
if int(result['status']) == 0:
   print('Monitor {} has been deleted.'.format(monitorId))
   print('Error {status}: {message}'.format(**result))

See Also

© 2016 SmartBear Software. All rights reserved.      Terms of Use · Privacy Policy