To add a new Perfecto monitor, send a POST request to /monitors/perfecto
with a JSON body containing the monitor configuration.
Request URL
POST https://api.alertsite.com/api/v3/monitors/perfecto
Authentication
The request must include the Authorization
header containing a user’s access token:
Authorization: Bearer ACCESS_TOKEN
See Authentication for more information.
The authenticating user must have permissions to create monitors.
Request body
The request body is a JSON object containing the monitor configuration parameters (see Monitor Object). The minimum required fields are:
-
billing_plancode
-
name
-
perfecto_username
-
perfecto_password
{
"billing_plancode":"AS-PM",
"name":"Sample Perfecto Monitor",
"perfecto_password":"SuperSecret",
"perfecto_username":"demo.user@example.com"
}
Here is an example with all supported fields (see Monitor Object for a description of these fields):
{
"alert_note":"Optional alert note",
"allow_internal_testing":true,
"billing_plancode":"AS-PM",
"blackout_ids":null,
"custom_properties":[
{
"id":228,
"name":"Environment",
"value":"development",
"value_id":550
}
],
"enabled":true,
"has_active_performance_alerts":false,
"has_performance_alerts":false,
"has_sla":false,
"home_location":10,
"id":123456,
"interval":5,
"locations":[
],
"mode":"All Handsets Simultaneously",
"monitor_location_count":1,
"monitor_offset":5,
"monitor_uses_own_locations":false,
"name":"Sample Perfecto Monitor",
"note":"Optional monitor note",
"notify_on_error":true,
"perfecto_hostname":"mylab.perfectomobile.com",
"perfecto_password":"SuperSecret",
"perfecto_script_name":"Public/Monitoring Script",
"perfecto_script_value":"PUBLIC:Monitoring Script.xml",
"perfecto_username":"demo.user@example.com",
"rotate_locations":true,
"sla_id":null,
"type":"perfecto"
}
Parameters that are not specified in the request body will take the values specified in AlertSite defaults and your account defaults. For example, if you do not specify locations for the monitor, it will use your account's default monitoring locations.
Response body
On success, the operation returns the ID of the created 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 creates a 15-minute Perfecto monitor.
cURL (Windows)
curl -X POST https://api.alertsite.com/api/v3/monitors/perfecto
-H "Authorization: Bearer ACCESS_TOKEN"
-H "Content-Type: application/json"
-d '{\"billing_plancode\":\"AS-PM\", \"name\":\"Sample Perfecto Monitor\", \"perfecto_username\":\"demo.user@example.com\", \"perfecto_password\":\"SuperSecret\", \"perfecto_hostname\":\"mylab.perfectomobile.com\"}'
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/perfecto \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-type: application/json" \
-d '{"billing_plancode":"AS-PM", "name":"Sample Perfecto Monitor", "perfecto_username":"demo.user@example.com", "perfecto_password":"SuperSecret", "perfecto_hostname":"mylab.perfectomobile.com"}'
Python
import requests # Requests library http://docs.python-requests.org
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 = {
'billing_plancode': 'AS-PM',
'name': 'Sample Perfecto Monitor',
'perfecto_username': 'demo.user@example.com',
'perfecto_password': 'SuperSecret',
'perfecto_hostname': 'mylab.perfectomobile.com',
'interval': 15
}
# 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.post(baseUrl+'/monitors/perfecto', data=json.dumps(monitor_params), headers=headers)
result = r.json()
if r.status_code == requests.codes.ok:
monitor_id = result['id']
print('Successfully created the monitor. ID:{}'.format(monitor_id))
else:
print('Could not create a monitor. The following error(s) occurred:', *result['errors'], sep='\n')