Manage Synthetics alert notifications via the REST API

Owner or Admins

Paid subscription required

This document applies only to New Relic Synthetics customers that do not use New Relic Alerts.

If your account does not use New Relic Alerts, do not use the Synthetics API. Instead, use New Relic's REST API for New Relic Alerts for alert policies, notification channels, conditions, and alert activity.

Requirements

To use the REST API with alert notifications for New Relic Synthetics, you must activate API access and generate your Admin User's API key from your account settings. Then you can make standard API calls via the command line. These examples show cURL commands.

You must use your Admin User's API key to make Synthetics REST API calls. The account's REST API key will not work.

Also, you cannot use New Relic Alerts to specify email addresses for alert notifications. Instead, you must either use the New Relic Synthetics user interface, or you can use the REST API.

Email alerts for New Relic Synthetics

Add email notifications to a monitor

To add one or more email addresses for a specific monitor's alert notifications in New Relic Synthetics, send a POST request. Replace the {id} in the following example with the specific monitor ID, and include the following in the body of the request:

{
	"count": integer,
	"emails": array of strings
}

For example:

curl -v \
     -X POST https://synthetics.newrelic.com/synthetics/api/v1/monitors/{id}/notifications \
     -H 'X-Api-Key:{Admin_User_Key}' \
     -H 'content-type: application/json' \
     -d '{ "count": 1, "emails": [ "name@email.com" ] }'

A successful request will return a 204 No Content response with an empty body. An invalid request will return any of the following error codes:

  • 400 Bad Request: The email list is zero length or otherwise null; count does not equal the quanity of items in the emails array.
  • 404 Not Found: The specified monitor does not exist.
  • 409 Conflict: One or more of the email addresses listed is already associated with the specified monitor.
Get email addresses for a monitor

To get a list of all email addresses associated with a specific monitor's alert notifications in New Relic Synthetics, send a GET request. Replace the {id} in the following example with the specific monitor ID.

curl -v \
     -H 'X-Api-Key:{Admin_User_Key}' -H GET https://synthetics.newrelic.com/synthetics/api/v1/monitors/{id}/notifications

A successful request will return a 200 OK response. The data returned will have the following format:

{
  "count": integer,
  "emails": array of strings
}

An invalid monitor ID will return the error 404 Not Found: The specified monitor does not exist.

Delete email addresses for a monitor

To delete one or more existing email addresses for a specific monitor's alert notifications in New Relic Synthetics, send a DELETE request. Replace the {id} in the following example with the specific monitor ID, and replace {email} with the email addresses.

For example:

curl -v \
     -H 'X-Api-Key:{Admin_User_Key}' \
     -X DELETE https://synthetics.newrelic.com/synthetics/api/v1/monitors/{id}/notifications/{email}

A successful request will return a 204 No Content response with an empty body. An invalid request will return the error 404 Not Found: The specified monitor does not exist.

For more help

Additional documentation resources include:

Recommendations for learning more: