Edit Alert Recipient

Last modified on July 26, 2024

To modify parameters of an alert recipient, send a PATCH request to /recipients/{id}, where {id} is the recipient ID.

Note: This operation cannot modify blackouts and recipient groups for a recipient. To modify recipient blackouts, use Blackout Operations. To modify the recipient groups for a recipient, use Recipient Groups Operations.

Request URL

PATCH https://api.alertsite.com/api/v3/recipients/{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 recipient fields you want to update. Below are some examples.

Change the recipient’s email address:

{
  "recipient": "[email protected]"
}

Disable the recipient:

{
  "availability_alert": false,
  "performance_alert": false
}

See the list of all editable fields:

{
  "name": "DevOps mailing list",
  "method_id": 12,
  "recipient": "[email protected]",
  "username": "",
  "password": "",

  "availability_alert": true,
  "notify_on_clear": true,
  "attach_screen_capture": true,
  "attach_server_response": true,
  "start_threshold": 1,
  "stop_threshold": 10,
  "remote_commands": false

  "performance_alert": true,
  "performance_alert_type": "20",
  "repeat_performance_alerts": true
}

Response body

On success, the operation returns HTTP status 200 with the recipient ID as a string:

{
  "id": "123456"
}

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

This code enables performance alerts for the recipient with ID 123456.

cURL (Windows)

curl -X PATCH https://api.alertsite.com/api/v3/recipients/123456
  -H "Authorization: Bearer ACCESS_TOKEN"
  -H "Content-Type: application/json"
  -d "{\"performance_alert\": true, \"performance_alert_type\": \"20\", \"repeat_performance_alerts\": 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/recipients/123456 \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"performance_alert": true, "performance_alert_type": "20", "repeat_performance_alerts": true}'

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
recipient_id = 123456
recipient_params = {
    'performance_alert': True,
    'performance_alert_type': '20',
    'repeat_performance_alerts': True
}

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

# Update the recipient configuration
url = baseUrl + '/recipients/' + str(recipient_id)
headers = {
    'Authorization': 'Bearer ' + token,
    'Content-Type': 'application/json'
}
r = requests.patch(url, data=json.dumps(recipient_params), headers=headers)
if r.status_code == requests.codes.ok:
    print('The recipient configuration has been updated.')
else:
    print('Could not update recipient #{}. The following error(s) occurred:'.format(recipient_id), *r.json()['errors'], sep='\n')

See Also

Alert Recipient Operations

Highlight search results