Edit Recipient Group

Last modified on March 27, 2024

Use this operation to modify the recipient group configuration – the included monitors, recipients, error types and custom alert templates; the group name; or the "default group" setting.

The typical flow is to first call GET /notifier-groups/{id} to get the recipient group configuration, then update some values, and send the updated configuration back to the API.

Request URL

PATCH https://api.alertsite.com/api/v3/notifier-groups/{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 group fields you want to update. Read-only fields are ignored.

When updating the monitors, recipients, errortypes and templates arrays, note that you must send back the whole array. That is, the specified array will replace the previous values, but not get added on top of them.

Examples

Rename the group:

{
  "name": "LuciernaBank notifications"
}

Make it the default group:

{
  "is_default": true
}

Change the list of monitors and recipients in the group:

{
  "monitors": [
    {"id": 123456},
    {"id": 304276, "step_number": 2},
  ],
  "recipients": [
    {"id": 176492},
    {"id": 298126},
    {"id": 371554}
  ]
}

See the list of all editable fields:

{
  "name": "LuciernaBank notifications",
  "is_default": false,
  "monitors": [
    {"id": 123456}
    {"id": 304276, "step_number": 2}
  ],
  "recipients": [
    {"id": 176492},
    {"id": 298126},
    {"id": 371554}
  ],
  "errortypes": [
    {"id": 1},
    {"id": 2}
  ],
  "templates": [
    {"id": 14},
    {"id": 27}
  ]
}

Response body

On success, the operation returns HTTP status 200 with the recipient group 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 example adds a new monitor to an existing recipient group.

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

group_id = 2958
monitor_id = 123456  # Monitor ID to add to the group

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

# Get the recipient group configuration
group_url = baseUrl + '/notifier-groups/' + str(group_id)
r = requests.get(group_url, headers={'Authorization': 'Bearer ' + token})
group = r.json()

# Add a new monitor to the group
group['monitors'].append({'id': monitor_id})
headers = {
    'Authorization': 'Bearer ' + token,
    'Content-Type': 'application/json'
}
r = requests.patch(group_url, data=json.dumps(group), headers=headers)

result = r.json()
if r.status_code == requests.codes.ok:
    print('Recipient group {} has been updated.'.format(group_id))
else:
    print('Could not update the recipient group. The following error(s) occurred:', *result['errors'], sep='\n')

See Also

Recipient Group Operations

Highlight search results