Edit a DNS Monitor

Last modified on May 22, 2024

To update an existing DNS monitor, send a PATCH request to /monitors/name-server/{id}, where {id} is the monitor ID.

Request URL

PATCH https://api.alertsite.com/api/v3/monitors/name-server/{id}


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.

For example, change the domain name to test the DNS lookup for and browser timeout:

  "name_to_resolve": "example.com",
  "timeout": 45

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

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

Code examples

This code updates the monitor with ID 123456 and changes the Name to Resolve and browser timeout options.

cURL (Windows)

curl -X POST https://api.alertsite.com/api/v3/monitors/name-server/123456
  -H "Authorization: Bearer ACCESS_TOKEN"
  -H "Content-Type: application/json"
  -d "{\"hostname\": \"example.com\", \"timeout\": 45"}"

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

cURL (bash)

curl -X POST https://api.alertsite.com/api/v3/monitors/name-server/123456 \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-type: application/json" \
  -d '{"name_to_resolve": "example.com", "timeout": 45}'


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 = {
  "name_to_resolve": "example.com",
  "timeout": 45

# 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/neame-server/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))
    print('Could not update the monitor. The following error(s) occurred:', *result['errors'], sep='\n')

See Also

Monitor Operations
Create a DNS Monitor
Delete Monitor

Highlight search results