To create a new recipient group, send a POST request to /notifier-groups
with a JSON body containing the recipient group configuration: name, monitor IDs, recipient IDs, and (optionally) error types and the IDs of custom alert templates.
Request URL
POST https://api.alertsite.com/api/v3/notifier-groups
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 configuration for the recipient group. Here is an example with all 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}
]
}
The required fields are:
name
monitors
recipients
The monitors
and recipients
arrays must contain at least one item. monitors
can include monitor IDs, ContentView IDs, and individual monitor steps (as a combination of a monitor id
and step_number
).
The errortypes
array uses 3-digit (not 4-digit) codes – exactly as they appear in the recipient group editor in AlertSite. If the errortypes
array is empty or not specified, it means “all errors”.
Response body
On success, the operation returns HTTP status 200 with the ID of the created recipient group:
{
"id": "123456"
}
Error responses have a non-200 status code and contain the errors
list, such as:
{
"errors": [
{
"code": 400,
"fields": [
"monitors"
],
"message": "required and is empty"
}
]
}
Try it out
Click here to test this operation in AlertSite’s interactive API console.
Code examples
This code creates a recipient group containing two monitors (123456 and 304276) and three recipients (176492, 298126, 371554).
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 group configuration
group = {
'name': 'LuciernaBank notifications',
'monitors': [
{'id': 123456},
{'id': 304276}
],
'recipients': [
{'id': 176492},
{'id': 298126},
{'id': 371554}
]
}
# 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']
# Create a recipient group
headers = {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json'
}
r = requests.post(baseUrl + '/notifier-groups', data=json.dumps(group), headers=headers)
result = r.json()
if r.status_code == requests.codes.ok:
print('A new recipient group has been created with ID', result['id'])
else:
print('Could not create a recipient group. The following error(s) occurred:', *result['errors'], sep='\n')