The REST API Explorer also includes the curl request format, available parameters, potential response status codes, and JSON response structure for each of the available API calls. You can also create alert conditions in the UI.
Before using the REST API
Before using the REST API to manage alerting data, read the Intro to APIs for .
For infrastructure alerting, see [REST API for infrastructure monitoring alerts](/docs/infrastructure/new-relic-infrastructure/infrastructure-alert-conditions/
Available data and functions via REST API
REST API functions
Comments
View account data
In general, any role can use a or REST API key with GET > List functions to view alerts data. The account Owner and Admins may use their API key.
List output will be paginated. Available functions include:
You may have an Owner or Admin role in your account and a user keyor have a custom role that grants permissions to manage alerts and a user key in order to use any maintenance function, including POST > Create, PUT > Add, PUT > Update, and DELETE.
Conditions excluded from the REST API
These types of conditions do not have available endpoints in the API:
APM: Web transaction percentiles, conditions targeting labels, and anomalies
NRQL: Anomalies
Alert policies
These API functions include links to the API Explorer, where you can create, delete, or list policies.
curl-X PUT 'https://api.newrelic.com/v2/alerts_policies/{id}.json'\
>
-H"$API_KEY"-i\
>
-H'Content-Type: application/json'\
>
-d\
>
'{
$
"policy": {
$
"incident_preference": "string",
$
"name": "string"
$
}
$
}'
To delete an existing policy, use your user key, and include the policy_id (available from API Explorer > Alerts Policies > GET > List) in the API call:
curl-X GET 'https://api.newrelic.com/v2/alerts_policies.json'\
>
-H"$API_KEY"-i
Conditions for APM, browser, mobile
These API functions include links to the API Explorer, where you can create, update, delete, or list policy conditions. These calls are for conditions with these types of entities:
APM: Apps and key transactions
Browser: Apps and key transactions
Mobile: Mobile apps
Exception: The following APM conditions are not available from this API endpoint:
Conditions targeting labels (dynamic targeting)
Web transaction percentile conditions
Anomaly conditions
Important
The API Explorer provides information about other types of conditions using separate endpoints, including external services (APM and mobile), and synthetic monitoring. Consider all types of alert conditions when searching or updating. If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.
To add conditions to policies, include these values in the API call:
Your
The policy_id (available from API Explorer > Alerts Policies > GET > List)
The required condition values in the API call (described in the API Explorer page and in the alerts conditions API glossary)
The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer > Alerts Conditions > GET > List.
To update conditions for policies, include these values in the API call:
Recommendation: Due to the way NRQL data is streamed, set the aggregation_method to EVENT_FLOW and use the default settings of 60 for aggregation_window and 120 for aggregation_delay. EVENT_FLOW works in most use-cases, but for a discussion on which use cases work better with EVENT_TIMER, see Which aggregation method to use?.
API Explorer > Alerts NRQL Conditions > POST > Create
To view a list of existing conditions for your alert policy, use your user key or REST API key, and the associated policy_id in the API call.
API Explorer > Alerts NRQL Conditions > GET > List
bash
$
curl-X GET 'https://api.newrelic.com/v2/alerts_nrql_conditions.json'\
>
-H"$API_KEY"-i\
>
-d'policy_id=$POLICY_ID'
Conditions for external services
These API functions include links to the API Explorer, where you can create, update, delete, or list policy conditions. These calls are for conditions for external services. The API calls can be used with and mobile monitoring apps.
The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer > Alerts External Service Conditions > GET > List.
To update conditions for external services to policies that have APM or mobile monitoring apps, include these values in the API call:
To view a list of existing conditions for policies with external service apps (APM or mobile monitoring), use your user key or REST API key and the associated policy_id in the API call.
API Explorer > Alerts External Service Conditions > GET > List
bash
$
curl-X GET 'https://api.newrelic.com/v2/alerts_external_service_conditions.json'\
>
-H"$API_KEY"-i\
>
-d'policy_id=$POLICY_ID'
Conditions for synthetic monitoring
These API functions include links to the API Explorer, where you can create, update, delete, or list conditions for your alert policies. The API calls can be used with synthetic monitoring.
To add conditions to policies for synthetic monitoring, include these values in the API call:
The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer > Alerts Synthetics Conditions > GET > List.
To update policy conditions for synthetic monitoring, include these values in the API call:
To view a list of existing policy conditions for synthetic monitoring, use your user key or REST API key, and the associated policy_id in the API call.
API Explorer > Alerts Synthetics Conditions > GET > List
bash
$
curl-X GET 'https://api.newrelic.com/v2/alerts_synthetics_conditions.json'\
>
-H"$API_KEY"-i\
>
-d'policy_id=$POLICY_ID'
Multi-location conditions for synthetic monitoring
These API functions include links to the API Explorer, where you can create, update, delete, or list conditions for your alert policies. The API calls can be used for multi-location conditions with synthetic monitoring. Before creating or updating a condition, read the rules for multi-location alert conditions.
To add conditions to policies for multi-location synthetic monitoring, include these values in the API call:
The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer > Alerts Location Failure Conditions > GET > List.
To update policy conditions for multi-location synthetic monitoring, include these values in the API call:
To view a list of existing policy conditions for multi-location synthetic monitoring, use your user key or REST API key, and the associated policy_id in the API call.
API Explorer > Alerts Location Failure Conditions > GET > List
bash
$
curl-X GET 'https://api.newrelic.com/v2/alerts_location_failure_conditions/policies/$POLICY_ID.json'\
>
-H"$API_KEY"-i
Alert entity conditions
These API functions include links to the API Explorer, where you can list, add and remove entities in the conditions for your alert policies.
The entity_id This is the entity (alert target) to be monitored. It is the numeric ID for the APM application, browser app, key transaction, or mobile app.
The condition_id (available from API Explorer > Alerts Conditions > GET > List)
The entity_type, which must be one of the following:
Application
BrowserApplication
MobileApplication
KeyTransaction
API Explorer > Alerts Entity Conditions > PUT > Add
bash
$
curl-X PUT 'https://api.newrelic.com/v2/alerts_entity_conditions/$ENTITY_ID.json'\
The entity_id This is the specific monitored entity (alert target) to be removed. It is the numeric ID for the APM application, browser app, key transaction, or mobile app.
The condition_id (available from API Explorer > Alerts Conditions > GET > List)
The entity_type, which must be one of the following:
Application
BrowserApplication
MobileApplication
KeyTransaction
API Explorer > Alerts Entity Conditions > DELETE > Remove