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.
You may have an Owner or Admin role in your account and a user key or 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, and 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)
curl-X POST 'https://api.newrelic.com/v2/alerts_conditions/policies/$POLICY_ID.json'\
>
-H"$API_KEY"-i\
>
-H'Content-Type: application/json'\
>
-d\
>
'{
$
"condition": {
$
"type": "string",
$
"name": "string",
$
"enabled": boolean,
$
"entities": [
$
integer
$
],
$
"metric": "string",
$
"gc_metric": "string",
$
"condition_scope": "string",
$
"violation_close_timer": integer,
$
"runbook_url": "string",
$
"terms": [
$
{
$
"duration": "string",
$
"operator": "string",
$
"priority": "string",
$
"threshold": "string",
$
"time_function": "string"
$
}
$
],
$
"user_defined": {
$
"metric": "string",
$
"value_function": "string"
$
}
$
}
$
}'
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 Choose your aggregation method.
API Explorer > Alerts NRQL Conditions > POST > Create
To create NRQL conditions for policies:
bash
$
curl-X POST 'https://api.newrelic.com/v2/alerts_nrql_conditions/policies/$POLICY_ID.json'\
>
-H"$API_KEY"-i\
>
-H'Content-Type: application/json'\
>
-d\
>
'{
$
"nrql_condition": {
$
"type": "string",
$
"name": "string",
$
"runbook_url": "string",
$
"enabled": boolean,
$
"terms": [
$
{
$
"duration": "string",
$
"operator": "string",
$
"priority": "string",
$
"threshold": "string",
$
"time_function": "string"
$
}
$
],
$
"value_function": "string",
$
"nrql": {
$
"query": "string"
$
},
$
"signal": {
$
"aggregation_window": "string",
$
"slide_by": "integer",
$
"aggregation_method": "string",
$
"aggregation_delay": integer,
$
"aggregation_timer": integer,
$
"fill_option": "string",
$
"fill_value": "string"
$
},
$
"expiration": {
$
"expiration_duration": "string",
$
"open_violation_on_expiration": boolean,
$
"close_violations_on_expiration": boolean
$
}
$
}
$
}'
If you omit type or set it as static, it will default to standard NRQL alerting.
To update NRQL conditions for policies, include these values in the API call:
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 policy_id (available from API Explorer > Alerts Policies > GET > List)
The required external_service_condition values in the API call (described in the API Explorer page and in the Alerts conditions API glossary)
API Explorer > Alerts External Service Conditions > POST > Create
bash
$
curl-X POST 'https://api.newrelic.com/v2/alerts_external_service_conditions/policies/$POLICY_ID.json'\
>
-H"$API_KEY"-i\
>
-H'Content-Type: application/json'\
>
-d\
>
'{
$
"external_service_condition": {
$
"type": "string",
$
"name": "string",
$
"enabled": boolean,
$
"entities": [
$
integer
$
],
$
"external_service_url": "string",
$
"metric": "string",
$
"runbook_url": "string",
$
"terms": [
$
{
$
"duration": "string",
$
"operator": "string",
$
"priority": "string",
$
"threshold": "string",
$
"time_function": "string"
$
}
$
]
$
}
$
}'
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 policy_id (available from API Explorer > Alerts Policies > GET > List)
The required synthetics_condition values in the API call (described in the API Explorer page and in the alerts conditions API glossary)
API Explorer > Alerts Synthetics Conditions > POST > Create
bash
$
curl-X POST 'https://api.newrelic.com/v2/alerts_synthetics_conditions/policies/$POLICY_ID.json'\
>
-H"$API_KEY"-i\
>
-H'Content-Type: application/json'\
>
-d\
>
'{
$
"synthetics_condition": {
$
"name": "string",
$
"monitor_id": "string",
$
"runbook_url": "string",
$
"enabled": boolean
$
}
$
}'
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 conditions for policies, 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 policy_id (available from API Explorer > Alerts Policies > GET > List)
The required location_failure_condition values in the API call (described in the API Explorer page and in the alerts conditions API glossary)
API Explorer > Alerts Location Failure Conditions > POST > Create
bash
$
curl-X POST 'https://api.newrelic.com/v2/alerts_location_failure_conditions/policies/$POLICY_ID.json'\
>
-H"$API_KEY"-i\
>
-H'Content-Type: application/json'\
>
-d\
>
'{
$
"location_failure_condition": {
$
"name": "string",
$
"runbook_url": "string",
$
"enabled": boolean,
$
"entities":
$
[
$
"string"
$
],
$
"terms": [
$
{
$
"priority": "string",
$
"threshold": integer,
$
}
$
],
$
"violation_time_limit_seconds": integer
$
}
$
}'
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