Edit a Round-Trip Email Monitor

Last modified on August 24, 2020

With AlertSite Management API, you can edit round-trip email monitors.

To modify a round-trip email monitor, send a PATCH request to /monitors/email-round-trip/{id}, where {id} is the monitor ID:

Request URL

PATCH https://api.alertsite.com/api/v3/monitors/email-round-trip/{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.

For example, change the SMTP and POP3 servers and the email to which a test message is sent:

{
    "smtp_hostname": "smtps://smtp.example.com:465",
    "pop3_hostname": "pop3s://mail.example.com:995",
    "email": "demo@example.com"
}

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 SMTP monitor with ID 123456 and changes the SMTP and POP3 servers and the email to which a test message is sent:

cURL (Windows)

curl -X PATCH https://api.alertsite.com/api/v3/monitors/email-round-trip/123456
  -H "Authorization: Bearer ACCESS_TOKEN"
  -H "Content-Type: application/json"
  -d '{\"smtp_hostname\":\"smtps://smtp.example.com:465\", \"pop3_hostname\":\"pop3s://mail.example.com:995\", \"email\":\"demo@example.com\"}'


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/email-round-trip/123456 \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-type: application/json" \
  -d '{"smtp_hostname":"smtps://smtp.example.com:465", "pop3_hostname":"pop3s://mail.example.com:995", "email":"demo@example.com"}'

Python

import requests # Requests library https://requests.kennethreitz.org/en/master/
import json

baseUrl = 'https://api.alertsite.com/api/v3'
username = 'demo@example.com'  # Replace with your AlertSite login email
password = 'pa55w0rd'          # Replace with your AlertSite password


monitor_params = {
  'smtp_hostname': 'smtps://smtp.example.com:465',
  'pop3_hostname': 'pop3s://mail.example.com:995',
  'email': 'demo@example.com'
}

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

# Create the monitor
headers = {
  'Authorization': 'Bearer ' + token,
  'Content-Type': 'application/json'
}
r = requests.patch(baseUrl+'/monitors/email-round-trip/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 Round-Trip Email Monitor
Delete Monitor

Highlight search results