Edit a Website Monitor

Last modified on July 26, 2024

With AlertSite Management API, you can edit HTTP and HTTPS website monitors.

HTTP website

To modify a website monitor for an http:// URL, send a PATCH request to /monitors/website/{id}, where {id} is the monitor ID.

HTTPS website

To modify a website monitor for an https:// URL, send a PATCH request to /monitors/website-ssl/{id}, where {id} is the monitor ID.

Request URL

HTTP website

PATCH https://api.alertsite.com/api/v3/monitors/website/{id}

HTTPS website

PATCH https://api.alertsite.com/api/v3/monitors/website-ssl/{id}

Authentication

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

Authorization: Bearer ACCESS_TOKEN

See Authentication for more information.

Request body

The request body is a JSON object containing the monitor configuration fields you want to update.

HTTP website

For example, enable full-page object alerts and add keyword validation:

{
    "check_fullpage_missing_objects":true,
    "check_fullpage_object_sizes":true,
    "fullpage_object_timeout":10,
    "keyword_match_invert":false,
    "keyword_match_type":"Plain Text",
    "keyword_string":"Featured products",
    "notify_on_fullpage_errors":false
}

HTTPS website

For example, change the SSL certificate version and enable notifications when the SSL certificate has expired:

{
    "use_ssl_version":2,
    "check_ssl_expiration_dates":"Expired"
}

Response body

On success, the operation returns the ID of the updated monitor.

{
  "id": "123456"
}

Error responses have a non-200 status code and contain the errors list, such as:

{
  "errors": [
    {
      "code": 400,
      "message": "invalid_request - User authentication failed."
    }
  ]
}

Try it out

HTTP website

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

HTTPS website

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

Code examples

HTTP website

This code updates the monitor with ID 123456 and enables full-page object alerts and adds keyword validation.

cURL (Windows)

curl -X PATCH https://api.alertsite.com/api/v3/monitors/website/123456
  -H "Authorization: Bearer ACCESS_TOKEN"
  -H "Content-Type: application/json"
  -d '{\"check_fullpage_missing_objects\":true, \"check_fullpage_object_sizes\":true, \"fullpage_object_timeout\":10, \"keyword_match_invert\":false, \"keyword_match_type\":\"Plain Text\", \"keyword_string\":\"Featured products\", \"notify_on_fullpage_errors\":true}'


Note: New lines are added for readability.
The actual command should be one continuous line.

cURL (bash)

curl -X PATCH https://api.alertsite.com/api/v3/monitors/website/123456 \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-type: application/json" \
  -d '{"check_fullpage_missing_objects":true, "check_fullpage_object_sizes":true, "fullpage_object_timeout":10, "keyword_match_invert":false, "keyword_match_type":"Plain Text", "keyword_string":"Featured products", "notify_on_fullpage_errors":true}'

Python

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

monitor_params = {
  'check_fullpage_missing_objects': True,
  'check_fullpage_object_sizes': True,
  'fullpage_object_timeout': 10,
  'keyword_match_invert': False,
  'keyword_match_type': 'Plain Text',
  'keyword_string': 'Featured products',
  'notify_on_fullpage_errors': False
}

# Login
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']

# Update the monitor
headers = {
  'Authorization': 'Bearer ' + token,
  'Content-Type': 'application/json'
}
r = requests.patch(baseUrl+'/monitors/website/123456', data=json.dumps(monitor_params), headers=headers)
result = r.json()
if r.status_code == requests.codes.ok:
    monitor_id = result['id']
    print('Successfully updated the monitor. ID:{}'.format(monitor_id))
else:
    print('Could not update the monitor. The following error(s) occurred:', *result['errors'], sep='\n')

HTTPS website

This code updates the monitor with ID 123456, changes the SSL certificate version, and enables notifications when the SSL certificate has expired.

cURL (Windows)

curl -X PATCH https://api.alertsite.com/api/v3/monitors/website-ssl/123456
  -H "Authorization: Bearer ACCESS_TOKEN"
  -H "Content-Type: application/json"
  -d '{\"use_ssl_version\":2, \"check_ssl_expiration_dates\":\"Expired\"}'


Note: New lines are added for readability.
The actual command should be one continuous line.

cURL (bash)

curl -X PATCH https://api.alertsite.com/api/v3/monitors/website-ssl/123456 \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-type: application/json" \
  -d '{"use_ssl_version":2, "check_ssl_expiration_dates":"Expired"}'

Python

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

monitor_params = {
  'use_ssl_version': 2,
  'check_ssl_expiration_dates': 'Expired',
}

# Login
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']

# Update the monitor
headers = {
  'Authorization': 'Bearer ' + token,
  'Content-Type': 'application/json'
}
r = requests.patch(baseUrl+'/monitors/website-ssl/123456', data=json.dumps(monitor_params), headers=headers)
result = r.json()
if r.status_code == requests.codes.ok:
    monitor_id = result['id']
    print('Successfully updated the monitor. ID:{}'.format(monitor_id))
else:
    print('Could not update the monitor. The following error(s) occurred:', *result['errors'], sep='\n')

See Also

Monitor Operations
Create a Website Monitor
Delete Monitor

Highlight search results