Our REST API is New Relic's original API for programmatically configuring New Relic alerting settings (learn about NerdGraph, our preferred API).
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 using alerts with our NerdGraph API document.
For infrastructure alerting, see REST API for infrastructure monitoring alerts
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:
|
Maintain account data | You may have an |
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.
Important
If your organization hosts data in the EU data center, ensure you're using the proper API endpoints for EU region accounts.
To add new policies, use your user key and include these two values in the API call:
Required values | Definition |
---|---|
| Determines how alerts will create incidents. This must be one of the following:
|
The policy |
API Explorer > Alerts Policies > POST > Create
$curl -X POST 'https://api.newrelic.com/v2/alerts_policies.json' \> -H "$API_KEY" -i \> -H 'Content-Type: application/json' \> -d \>'{$ "policy": {$ "incident_preference": "string",$ "name": "string"$ }$}'
Use this API to update an existing policy's name
and incident_preference
. You'll need your user key.
Required values | Definition |
---|---|
| To find a policy's ID, use either of these options:
|
| Determines how alerts will create incidents. Must be one of the following:
|
The policy To find a policy's exact name, use the List policies API. |
API Explorer > Alerts Policies > PUT > Update
$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:
API Explorer > Alerts Policies > DELETE
$curl -X DELETE 'https://api.newrelic.com/v2/alerts_policies/$POLICY_ID.json' \> -H "$API_KEY" -i
To view a list of existing policies for your account, use your user key, and include these optional values in the API call:
Optional policy
name
filterOptional pagination value
API Explorer > Alerts Policies > GET > List
bash$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)API Explorer > Alerts Conditions > POST > Create
bash$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": {$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#type">type</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#name">name</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#enabled">enabled</a>": boolean,$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#entities">entities</a>": [$integer$],$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#metric">metric</a>": "string",$"gc_metric": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#condition-scope">condition_scope</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#violation_close_timer">violation_close_timer</a>": integer,$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#runbook_url">runbook_url</a>": "string",$"terms": [${$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_duration">duration</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_operator">operator</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_priority">priority</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_threshold">threshold</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_time_function">time_function</a>": "string"$}$],$"user_defined": {$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#user_defined_metric">metric</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#user_defined_value_function">value_function</a>": "string"$}$}$}'The JSON response returns a condition
id
, which you will need to update or delete the condition. You can also view the conditionid
from API Explorer > Alerts Conditions > GET > List.
To update conditions for policies, include these values in the API call:
Your user key
The condition's
id
(available from API Explorer > Alerts Conditions > GET > List)The required
condition
values in the API call (described in the API Explorer page and in the alerts conditions API glossary)API Explorer > Alerts Conditions > PUT > Update
bash$curl -X PUT 'https://api.newrelic.com/v2/alerts_conditions/$CONDITION_ID.json' \>-H "$API_KEY" -i \>-H 'Content-Type: application/json' \>-d \>'{$"condition": {$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#type">type</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#name">name</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#enabled">enabled</a>": boolean,$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#entities">entities</a>": [$integer$],$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#metric">metric</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#metric">metric</a>": "string",$"gc_metric": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#condition-scope">condition_scope</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#violation_close_timer">violation_close_timer</a>": integer,$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#runbook_url">runbook_url</a>": "string",$"terms": [${$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_duration">duration</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_operator">operator</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_priority">priority</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_threshold">threshold</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_time_function">time_function</a>": "string"$}$],$"user_defined": {$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#user_defined_metric">metric</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#user_defined_value_function">value_function</a>": "string"$}$}$}'
To delete conditions from policies, include these values in the API call:
Your user key
The
condition_id
(available from API Explorer > Alerts Conditions > GET > List)API Explorer > Alerts Conditions > DELETE > Delete
bash$curl -X DELETE 'https://api.newrelic.com/v2/alerts_conditions/$CONDITION_ID.json' \>-H "$API_KEY" -i
To view a list of existing conditions for your policy, use your REST API key or user key, and the associated policy_id
in the API call.
API Explorer > Alerts Conditions > GET > List
$curl -X GET 'https://api.newrelic.com/v2/alerts_conditions.json?policy_id=$POLICY_ID' \> -H "$API_KEY" -i
Conditions for NRQL
These API functions include links to the API Explorer, where you can create, update, delete, or list NRQL conditions for your policies.
Exception: NRQL anomaly conditions are not available from this endpoint.
Important
If your organization hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.
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:
$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",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#name">name</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#runbook_url">runbook_url</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#enabled">enabled</a>": boolean,$ "terms": [$ {$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_duration">duration</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_operator">operator</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_priority">priority</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_threshold">threshold</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_time_function">time_function</a>": "string"$ }$ ],$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#user_defined_value_function">value_function</a>": "string",$ "nrql": {$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#nrql-query">query</a>": "string"$ },$ "signal": {$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#signal_aggregation_window">aggregation_window</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#signal_slide_by">slide_by</a>": "integer",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#signal_aggregation_method">aggregation_method</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#signal_aggregation_delay">aggregation_delay</a>": integer,$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#signal_aggregation_timer">aggregation_timer</a>": integer,$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#fill_option">fill_option</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#fill_value">fill_value</a>": "string"$ },$ "expiration": {$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#expiration_duration">expiration_duration</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#expiration_duration">open_violation_on_expiration</a>": boolean,$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#expiration_duration">close_violations_on_expiration</a>": 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:
Your user key
The condition's
id
(available from API Explorer Alerts NRQL Conditions > GET > List)The required
condition
values in the API call (described in the API Explorer page and in the alerts conditions API glossary)API Explorer > Alerts NRQL Conditions > PUT > Update
bash$curl -X PUT 'https://api.newrelic.com/v2/alerts_nrql_conditions/$CONDITION_ID.json' \>-H "$API_KEY" -i \>-H 'Content-Type: application/json' \>-d \>'{$"nrql_condition": {$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#name">name</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#runbook_url">runbook_url</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#enabled">enabled</a>": boolean,$"terms": [${$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_duration">duration</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_operator">operator</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_priority">priority</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_threshold">threshold</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_time_function">time_function</a>": "string"$}$],$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#user_defined_value_function">value_function</a>": "string",$"nrql": {$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#nrql-query">query</a>": "string"$}$}$}'
To delete NRQL conditions from policies, include these values in the API call:
Your user key
The condition's
id
(available from API Explorer Alerts NRQL Conditions > GET > List)API Explorer > Alerts NRQL Conditions > DELETE > Delete
bash$curl -X DELETE 'https://api.newrelic.com/v2/alerts_nrql_conditions/$CONDITION_ID.json' \>-H "$API_KEY" -i
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]https://api.newrelic.com/docs/#/Alerts%20NRQL%20Conditions/get_alerts_nrql_conditions_json) > Alerts NRQL Conditions > GET > List
$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.
Important
If your organization hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.
To add conditions for external services to policies that have APM or mobile monitoring apps, include these values in the API call:
Your user key
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": {$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#type">type</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#name">name</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#enabled">enabled</a>": boolean,$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#entities">entities</a>": [$integer$],$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#external_service_url">external_service_url</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#metric">metric</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#runbook_url">runbook_url</a>": "string",$"terms": [${$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_duration">duration</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_operator">operator</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_priority">priority</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_threshold">threshold</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_time_function">time_function</a>": "string"$}$]$}$}'The JSON response returns a condition
id
, which you will need to update or delete the condition. You can also view the conditionid
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:
Your user key
The external service condition's
id
(available from API Explorer > Alerts External Service Conditions > 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 > PUT > Update
bash$curl -X PUT 'https://api.newrelic.com/v2/alerts_external_service_conditions/$CONDITION_ID.json' \>-H "$API_KEY" -i \>-H 'Content-Type: application/json' \>-d \>'{$"external_service_condition": {$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#type">type</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#name">name</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#enabled">enabled</a>": boolean,$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#entities">entities</a>": [$integer$],$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#external_service_url">external_service_url</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#metric">metric</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#runbook_url">runbook_url</a>": "string",$"terms": [${$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_duration">duration</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_operator">operator</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_priority">priority</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_threshold">threshold</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_time_function">time_function</a>": "string"$}$]$}$}'
To delete conditions for external services from policies with APM or mobile monitoring apps, include these values in the API call:
Your user key
The
condition_id
(available from API Explorer > Alerts External Service Conditions > GET > List)API Explorer > Alerts External Service Conditions > DELETE
$curl -X DELETE 'https://api.newrelic.com/v2/alerts_external_service_conditions/$CONDITION_ID.json' \> -H "$API_KEY" -i
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
$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:
Your user key
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": {$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#name">name</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#monitor_id">monitor_id</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#runbook_url">runbook_url</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#enabled">enabled</a>": boolean$}$}'The JSON response returns a condition
id
, which you will need to update or delete the condition. You can also view the conditionid
from API Explorer > Alerts Synthetics Conditions > GET > List.
To update conditions for policies, include these values in the API call:
Your user key
The condition's
id
(available from API Explorer > Alerts Conditions > GET > List)The required
condition
values in the API call (described in the API Explorer page and in the alerts conditions API glossary)API Explorer > Alerts Conditions > PUT > Update
$curl -X PUT 'https://api.newrelic.com/v2/alerts_conditions/$CONDITION_ID.json' \> -H "X-Api-Key:<a href='/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key'>$API_KEY</a>" -i \> -H "$API_KEY" -i \> -H 'Content-Type: application/json' \> -d \>'{$ "condition": {$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#type">type</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#name">name</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#enabled">enabled</a>": boolean,$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#entities">entities</a>": [$ integer$ ],$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#metric">metric</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#metric">metric</a>": "string",$ "gc_metric": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#condition-scope">condition_scope</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#violation_close_timer">violation_close_timer</a>": integer,$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#runbook_url">runbook_url</a>": "string",$ "terms": [$ {$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_duration">duration</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_operator">operator</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_priority">priority</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_threshold">threshold</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_time_function">time_function</a>": "string"$ }$ ],$ "user_defined": {$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#user_defined_metric">metric</a>": "string",$ "<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#user_defined_value_function">value_function</a>": "string"$ }$ }$}'
To delete policy conditions for synthetic monitoring, include these values in the API call:
Your user key
The
condition_id
(available from API Explorer > Alerts Synthetics Conditions > GET > List)API Explorer > Alerts Synthetics Conditions > DELETE
bash$curl -X DELETE 'https://api.newrelic.com/v2/alerts_synthetics_conditions/$CONDITION_ID.json' \>-H "$API_KEY" -i
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
$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:
Your user key
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": {$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#name">name</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#runbook_url">runbook_url</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#enabled">enabled</a>": boolean,$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#entities">entities</a>":$[$"string"$],$"terms": [${$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#priority">priority</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#threshold">threshold</a>": integer,$}$],$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#violation_time_limit_seconds">violation_time_limit_seconds</a>": integer$}$}'The JSON response returns a condition
id
, which you will need to update or delete the condition. You can also view the conditionid
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:
Your user key
The condition
id
(available from API Explorer > Alerts Location Failure Conditions > 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 > PUT > Update
bash$curl -X PUT 'https://api.newrelic.com/v2/alerts_location_failure_conditions/$CONDITION_ID.json' \>-H "$API_KEY" -i \>-H 'Content-Type: application/json' \>-d \>'{$"location_failure_condition": {$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#name">name</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#runbook_url">runbook_url</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#enabled">enabled</a>": boolean,$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#entities">entities</a>":$[$"string"$],$"terms": [${$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#priority">priority</a>": "string",$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#threshold">threshold</a>": integer,$}$],$"<a href="/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/rest-api-alerts/alerts-conditions-api-field-names#violation_time_limit_seconds">violation_time_limit_seconds</a>": integer$}$}'
To delete policy conditions for multi-location synthetic monitoring, include these values in the API call:
Your user key
The
condition_id
(available from API Explorer > Alerts Location Failure Conditions > GET > List)API Explorer > Alerts Location Failure Conditions > DELETE
bash$curl -X DELETE 'https://api.newrelic.com/v2/alerts_location_failure_conditions/$CONDITION_ID.json' \>-H "$API_KEY" -i
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
$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.
Important
If your organization hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.
To view the conditions an entity that apply to an entity in APM, browser, mobile, or key transactions, include these values in the API call:
Your user key or REST API key
The
entity_id
This is the specific entity (alert target) to be monitored.The
entity_type
, which must be one of the following:- Application
- BrowserApplication
- MobileApplication
- KeyTransaction
API Explorer > Alerts Entity Conditions > GET > list
bash$curl -X GET 'https://api.newrelic.com/v2/alerts_entity_conditions/$ENTITY_ID.json' \>-H "$API_KEY" -i \>-G -d 'entity_type=$ENTITY_TYPE'
To add an entity to a condition, include these values in the API call:
Your user key
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' \>-H "$API_KEY" -i \>-H 'Content-Type: application/json' \>-G -d 'entity_type=$ENTITY_TYPE&condition_id=$CONDITION_ID'
To remove an entity being monitored from a condition, include these values in the API call:
Your user key
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
bash$curl -X DELETE 'https://api.newrelic.com/v2/alerts_entity_conditions/$ENTITY_ID.json' \>-H "$API_KEY" -i \>-G -d 'entity_type=$ENTITY_ID&condition_id=$CONDITION_ID'