---
title: REST API calls for alerts
source: https://docs.newrelic.com/docs/alerts/scale-automate/rest-api/rest-api-calls-alerts
---

Our REST API is New Relic's original API for programmatically configuring New Relic alerting settings ([learn about NerdGraph, our preferred API](https://docs.newrelic.com/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/alerts-nerdgraph/nerdgraph-api-examples)).

The [REST API Explorer](https://docs.newrelic.com/docs/apm/apis/api-explorer-v2/getting-started-new-relics-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](https://docs.newrelic.com/docs/alerts/create-alert/create-alert-condition/alert-conditions/).

## Before using the REST API [#before-start]

Before using the REST API to manage alerting data, read the [Intro to using alerts with our NerdGraph API](https://docs.newrelic.com/docs/alerts/scale-automate/nerdgraph/nerdgraph-api-examples/) document.

For infrastructure alerting, see [REST API for infrastructure monitoring alerts](https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/infrastructure-alert-conditions/rest-api-calls-new-relic-infrastructure-alerts/)

## Available data and functions via REST API [#data]

| **REST API functions** | **Comments**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| View account data      | In general, any [role](https://docs.newrelic.com/docs/accounts-partnerships/accounts/account-setup/users-roles) can use a user key with **GET > List** functions to **view** alerts data. The account Owner and Admins may use their API key. List output will be [paginated](https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/pagination-api-output). Available functions include: - [Alert policies](#policies-list) - Conditions for [APM, browser monitoring, and mobile monitoring](#conditions-list) ([Some limitations apply.](#excluded)) - Conditions for [external services](#ext-conditions-list) - Conditions for [synthetic monitoring](#synthetics-conditions) - Conditions for [Multi-location synthetic monitoring](#multilocation-synthetics-conditions) - Conditions for NRQL ([Some limitations apply.](#excluded)) - [Events](#events) - [Alert events](https://docs.newrelic.com/docs/alerts/organize-alerts/specify-when-alerts-create-events/) |
| Maintain account data  | You may have an `Owner` or `Admin` role in your account **and** a [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-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 [#excluded]

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 [#alert-policies]

These API functions include links to the API Explorer, where you can create, delete, or list [policies](https://api.newrelic.com/docs/#/Alerts%20Policies).

> #### ⚠️ IMPORTANT
>
> By default, this endpoint uses the US data center. If your organization hosts data in the EU data center, ensure you're using the proper [API endpoints for EU region accounts](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/getting-started/introduction-eu-region-data-center#endpoints). For [JP data center](https://docs.newrelic.com/docs/accounts/accounts-billing/account-setup/choose-your-data-center) accounts, ensure you are using the proper JP region API endpoints.

**Create new policies**

To add new policies, use your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key) and include these two values in the API call:

| **Required values**                                                                                      | **Definition**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `incident_preference`                                                                                    | Determines how alerts will [create alert events](https://docs.newrelic.com/docs/alerts/organize-alerts/specify-when-alerts-create-events/). This must be one of the following: - `PER_POLICY` (default): Roll up by [policy](https://docs.newrelic.com/docs/alerts/organize-alerts/specify-when-alerts-create-events/#preference-policy). - `PER_CONDITION`: Roll up by [condition](https://docs.newrelic.com/docs/alerts/organize-alerts/specify-when-alerts-create-events/#preference-condition). - `PER_CONDITION_AND_TARGET`: Roll up by [target and condition](https://docs.newrelic.com/docs/alerts/organize-alerts/specify-when-alerts-create-events/#preference-target). |
| [Policy `name`](https://docs.newrelic.com/docs/alerts/organize-alerts/create-edit-or-find-alert-policy/) | The policy `name` is required. Leaving it unchanged will create a policy called `string`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

**[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Policies/post_alerts_policies_json) > Alerts Policies > POST > Create**

````shell
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"
  }
}'
```

````

**Update policies**

Use this API to update an existing policy's `name` and `incident_preference`. You'll need your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key).

| **Required values**                                                                                      | **Definition**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                                                                                                     | To find a policy's ID, use either of these options: - From the UI: On a policy's UI page, find the ID under the policy name. - With the API: Use the [List policies API](https://docs.newrelic.com/docs/alerts/rest-api-alerts/new-relic-alerts-rest-api/rest-api-calls-new-relic-alerts#policies-list).                                                                                                                                                                                                                                                                                                                                                                    |
| `incident_preference`                                                                                    | Determines how alerts will [create alert events](https://docs.newrelic.com/docs/alerts/organize-alerts/specify-when-alerts-create-events/). Must be one of the following: - `PER_POLICY` (default): Roll up by [policy](https://docs.newrelic.com/docs/alerts/organize-alerts/specify-when-alerts-create-events/#preference-policy). - `PER_CONDITION`: Roll up by [condition](https://docs.newrelic.com/docs/alerts/organize-alerts/specify-when-alerts-create-events/#preference-condition). - `PER_CONDITION_AND_TARGET`: Roll up by [condition and signal](https://docs.newrelic.com/docs/alerts/organize-alerts/specify-when-alerts-create-events/#preference-signal). |
| [Policy `name`](https://docs.newrelic.com/docs/alerts/organize-alerts/create-edit-or-find-alert-policy/) | The policy `name`, if you do not change the `name` it defaults to a policy called `string`. To find a policy's exact name, use the [List policies API](https://docs.newrelic.com/docs/alerts/rest-api-alerts/new-relic-alerts-rest-api/rest-api-calls-new-relic-alerts#policies-list).                                                                                                                                                                                                                                                                                                                                                                                      |

**[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Policies/put_alerts_policies__policy_id__json) > Alerts Policies > PUT > Update**

````shell
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"
  }
}'
```

````

**Delete existing policies**

To delete an existing policy, use your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key), and include the `policy_id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Policies/get_alerts_policies_json) > Alerts Policies > GET > List**) in the API call:

**[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Policies/delete_alerts_policies__policy_id__json) > Alerts Policies > DELETE**

````shell
curl -X DELETE 'https://api.newrelic.com/v2/alerts_policies/$POLICY_ID.json' \
     -H "$API_KEY" -i
```

````

**List existing policies**

To view a list of existing policies for your account, use your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key), and include these optional values in the API call:

-   Optional policy `name` filter
-   Optional [pagination](https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/pagination-api-output) value

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Policies/get_alerts_policies_json) > Alerts Policies > GET > List**

    ```shell
    curl -X GET 'https://api.newrelic.com/v2/alerts_policies.json' \
         -H "$API_KEY" -i
    ```

## Conditions for APM, browser, and mobile [#conditions]

These API functions include links to the API Explorer, where you can create, update, delete, or list policy [conditions](https://docs.newrelic.com/docs/alerts/create-alert/create-alert-condition/alert-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](#ext-services-conditions) (APM and mobile), and [synthetic monitoring](#synthetics-conditions). Consider all types of alert conditions when searching or updating. By default, this endpoint uses the US data center. If your account hosts data in the EU data center, ensure you are using the proper [API endpoints for EU region accounts](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/getting-started/introduction-eu-region-data-center#endpoints).

**Create conditions for policies**

To add conditions to policies, include these values in the API call:

-   Your user key
-   The `policy_id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Policies/get_alerts_policies_json) > 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](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names))

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Conditions/post_alerts_conditions_policies__policy_id__json) > Alerts Conditions > POST > Create**

    ```shell
    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](https://api.newrelic.com/docs/#/Alerts%20Conditions/get_alerts_conditions_json) > Alerts Conditions > GET > List**.

**Update conditions for policies**

To update conditions for policies, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The condition's `id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Conditions/get_alerts_conditions_json) > 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](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names))

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Conditions/put_alerts_conditions__condition_id__json) > Alerts Conditions > PUT > Update**

    ```shell
    curl -X PUT 'https://api.newrelic.com/v2/alerts_conditions/$CONDITION_ID.json' \
         -H "$API_KEY" -i \
         -H 'Content-Type: application/json' \
         -d \
    '{
      "condition": {
        "type": "string",
        "name": "string",
        "enabled": boolean,
        "entities": [
          integer
        ],
        "metric": "string",
        "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"
        }
      }
    }'
    ```

**Delete conditions from policies**

To delete conditions from policies, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The `condition_id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Conditions/get_alerts_conditions_json) > Alerts Conditions > GET > List**)

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Conditions/delete_alerts_conditions__condition_id__json) > Alerts Conditions > DELETE > Delete**

    ```shell
    curl -X DELETE 'https://api.newrelic.com/v2/alerts_conditions/$CONDITION_ID.json' \
         -H "$API_KEY" -i
    ```

**List existing conditions for policies**

To view a list of existing conditions for your policy, use your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key), and the associated [`policy_id`](#policies-list) in the API call.

**[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Conditions/get_alerts_conditions_json) > Alerts Conditions > GET > List**

````shell
curl -X GET 'https://api.newrelic.com/v2/alerts_conditions.json?policy_id=$POLICY_ID' \
     -H "$API_KEY" -i
```

````

## Conditions for NRQL [#conditions-nrql]

These API functions include links to the API Explorer, where you can create, update, delete, or list NRQL [conditions](https://docs.newrelic.com/docs/alerts/create-alert/create-alert-condition/alert-conditions) for your policies.

**Exception:** NRQL anomaly conditions are **not available** from this endpoint.

> #### ⚠️ IMPORTANT
>
> By default, this endpoint uses the US data center. If your organization hosts data in the EU data center, ensure you are using the proper [API endpoints for EU region accounts](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/getting-started/introduction-eu-region-data-center#endpoints). For [JP data center](https://docs.newrelic.com/docs/accounts/accounts-billing/account-setup/choose-your-data-center) accounts, ensure you are using the proper JP region API endpoints.

**Create NRQL conditions for policies**

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](https://docs.newrelic.com/docs/alerts/create-alert/fine-tune/streaming-alerts-key-terms-concepts/#aggregation-methods).

**[API Explorer](https://api.newrelic.com/docs/#/Alerts%20NRQL%20Conditions/post_alerts_nrql_conditions_policies__policy_id__json) > Alerts NRQL Conditions > POST > Create**

To create NRQL conditions for policies:

````shell
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.

<Callout variant="important">
Customers on [Advanced and Core Compute pricing plans](https://newrelic.com/pricing/compute#pricing_plan-compute) may incur additional CCU charges when utilizing sliding window aggregation. While this method enhances data analysis by smoothing out fluctuations, its use may lead to increased costs over other methods. For details, refer the [pricing section for sliding windows](/docs/nrql/using-nrql/create-smoother-charts-sliding-windows/#pricing). To determine whether you are on Advanced or Core Compute pricing plans, refer to your Order.
</Callout>

````

**Update NRQL conditions for policies**

To update NRQL conditions for policies, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The condition's `id` (available from [API Explorer ](https://api.newrelic.com/docs/#/Alerts%20NRQL%20Conditions/get_alerts_nrql_conditions_json) **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](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names))

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20NRQL%20Conditions/put_alerts_nrql_conditions__condition_id__json) > Alerts NRQL Conditions > PUT > Update**

    ```shell
    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": {
        "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"
        }
      }
    }'
    ```

**Delete NRQL conditions for policies**

To delete NRQL conditions from policies, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The condition's `id` (available from [API Explorer ](https://api.newrelic.com/docs/#/Alerts%20NRQL%20Conditions/get_alerts_nrql_conditions_json) **Alerts NRQL Conditions > GET > List**)

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20NRQL%20Conditions/delete_alerts_nrql_conditions__condition_id__json) > Alerts NRQL Conditions > DELETE > Delete**

    ```shell
    curl -X DELETE 'https://api.newrelic.com/v2/alerts_nrql_conditions/$CONDITION_ID.json' \
         -H "$API_KEY" -i
    ```

**List existing NRQL conditions for policies**

To view a list of existing conditions for your alert policy, use your user key and the associated [`policy_id`](#policies-list) in the API call.

**[API Explorer]<https://api.newrelic.com/docs/#/Alerts%20NRQL%20Conditions/get_alerts_nrql_conditions_json>) > Alerts NRQL Conditions > GET > List**

````shell
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 [#ext-services-conditions]

These API functions include links to the API Explorer, where you can create, update, delete, or list policy [conditions](https://docs.newrelic.com/docs/alerts/create-alert/create-alert-condition/alert-conditions). These calls are for conditions for external services. The API calls can be used with APM and mobile monitoring apps.

> #### ⚠️ IMPORTANT
>
> By default, this endpoint uses the US data center. If your organization hosts data in the EU data center, ensure you are using the proper [API endpoints for EU region accounts](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/getting-started/introduction-eu-region-data-center#endpoints). For [JP data center](https://docs.newrelic.com/docs/accounts/accounts-billing/account-setup/choose-your-data-center) accounts, ensure you are using the proper JP region API endpoints.

**External services: Create conditions for policies**

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](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The `policy_id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Policies/get_alerts_policies_json) > 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](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names))

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20External%20Service%20Conditions/post_alerts_external_service_conditions_policies__policy_id__json) > Alerts External Service Conditions > POST > Create**

    ```shell
    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](https://api.newrelic.com/docs/#/Alerts%20External%20Service%20Conditions/get_alerts_external_service_conditions_json) > Alerts External Service Conditions > GET > List**.

**External services: Update conditions for policies**

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](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The external service condition's `id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20External%20Service%20Conditions/get_alerts_external_service_conditions_json) > 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](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names))

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20External%20Service%20Conditions/put_alerts_external_service_conditions__condition_id__json) > Alerts External Service Conditions > PUT > Update**

    ```shell
    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": {
        "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"
          }
        ]
      }
    }'
    ```

**External services: Delete conditions from policies**

To delete conditions for external services from policies with APM or mobile monitoring apps, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The `condition_id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20External%20Service%20Conditions/get_alerts_external_service_conditions_json) > Alerts External Service Conditions > GET > List**)

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20External%20Service%20Conditions/delete_alerts_external_service_conditions__condition_id__json) > Alerts External Service Conditions > DELETE**

````shell
curl -X DELETE 'https://api.newrelic.com/v2/alerts_external_service_conditions/$CONDITION_ID.json' \
     -H "$API_KEY" -i
```

````

**External services: List existing conditions for policies**

To view a list of existing conditions for policies with external service apps (APM or mobile monitoring), use your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key) and the associated [`policy_id`](#policies-list) in the API call.

**[API Explorer](https://api.newrelic.com/docs/#/Alerts%20External%20Service%20Conditions/get_alerts_external_service_conditions_json) > Alerts External Service Conditions > GET > List**

````shell
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 [#synthetics-conditions]

These API functions include links to the API Explorer, where you can create, update, delete, or list [conditions](https://docs.newrelic.com/docs/alerts/create-alert/create-alert-condition/alert-conditions) for your alert policies. The API calls can be used with synthetic monitoring.

**Synthetic monitoring: Create conditions for policies**

To add conditions to policies for synthetic monitoring, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The `policy_id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Policies/get_alerts_policies_json) > 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](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names))

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Synthetics%20Conditions/post_alerts_synthetics_conditions_policies__policy_id__json) > Alerts Synthetics Conditions > POST > Create**

    ```shell
    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](https://api.newrelic.com/docs/#/Alerts%20Synthetics%20Conditions/get_alerts_synthetics_conditions_json) > Alerts Synthetics Conditions > GET > List**.

**Update conditions for policies**

To update conditions for policies, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The condition's `id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Conditions/get_alerts_conditions_json) > 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](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names))

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Conditions/put_alerts_conditions__condition_id__json) > Alerts Conditions > PUT > Update**

````shell
curl -X PUT 'https://api.newrelic.com/v2/alerts_conditions/$CONDITION_ID.json' \
     -H "X-Api-Key:$API_KEY" -i \
     -H "$API_KEY" -i \
     -H 'Content-Type: application/json' \
     -d \
'{
  "condition": {
    "type": "string",
    "name": "string",
    "enabled": boolean,
    "entities": [
      integer
    ],
    "metric": "string",
    "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"
    }
  }
}'
```

````

**Synthetic monitoring: Delete conditions from policies**

To delete policy conditions for synthetic monitoring, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The `condition_id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Synthetics%20Conditions/get_alerts_synthetics_conditions_json) > Alerts Synthetics Conditions > GET > List**)

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Synthetics%20Conditions/delete_alerts_synthetics_conditions__condition_id__json) > Alerts Synthetics Conditions > DELETE**

    ```shell
    curl -X DELETE 'https://api.newrelic.com/v2/alerts_synthetics_conditions/$CONDITION_ID.json' \
         -H "$API_KEY" -i
    ```

**Synthetic monitoring: List existing conditions for policies**

To view a list of existing policy conditions for synthetic monitoring, use your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key) and the associated [`policy_id`](#policies-list) in the API call.

**[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Synthetics%20Conditions/get_alerts_synthetics_conditions_json) > Alerts Synthetics Conditions > GET > List**

````shell
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 [#multilocation-synthetics-conditions]

These API functions include links to the API Explorer, where you can create, update, delete, or list [conditions](https://docs.newrelic.com/docs/alerts/create-alert/create-alert-condition/alert-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](https://docs.newrelic.com/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/advanced-techniques/multi-location-synthetic-monitoring-alert-conditions/#rules).

**Multi-location synthetics: Create conditions for policies**

To add conditions to policies for multi-location synthetic monitoring, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The `policy_id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Policies/get_alerts_policies_json) > 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](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names))

    **[API Explorer](https://api.newrelic.com/docs/#/Deprecation%20Notice%20-%20Alerts%20Location%20Failure%20Conditions/post_alerts_location_failure_conditions_policies__policy_id__json) > Alerts Location Failure Conditions > POST > Create**

    ```shell
    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](https://api.newrelic.com/docs/#/Deprecation%20Notice%20-%20Alerts%20Location%20Failure%20Conditions/get_alerts_location_failure_conditions_policies__policy_id__json) > Alerts Location Failure Conditions > GET > List**.

**Multi-location synthetics: Update conditions for policies**

To update policy conditions for multi-location synthetic monitoring, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The condition `id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Deprecation%20Notice%20-%20Alerts%20Location%20Failure%20Conditions/get_alerts_location_failure_conditions_policies__policy_id__json) > 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](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names))

    **[API Explorer](https://api.newrelic.com/docs/#/Deprecation%20Notice%20-%20Alerts%20Location%20Failure%20Conditions/put_alerts_location_failure_conditions__condition_id__json) > Alerts Location Failure Conditions > PUT > Update**

    ```shell
    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": {
        "name": "string",
        "runbook_url": "string",
        "enabled": boolean,
        "entities":
        [
          "string"
        ],
        "terms": [
          {
            "priority": "string",
            "threshold": integer,
          }
        ],
        "violation_time_limit_seconds": integer
      }
    }'
    ```

**Multi-location synthetics: Delete conditions for policies**

To delete policy conditions for multi-location synthetic monitoring, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The `condition_id` (available from **[API Explorer](https://api.newrelic.com/docs/#/Deprecation%20Notice%20-%20Alerts%20Location%20Failure%20Conditions/get_alerts_location_failure_conditions_policies__policy_id__json) > Alerts Location Failure Conditions > GET > List**)

    **[API Explorer](https://api.newrelic.com/docs/#/Deprecation%20Notice%20-%20Alerts%20Location%20Failure%20Conditions/delete_alerts_location_failure_conditions__condition_id__json) > Alerts Location Failure Conditions > DELETE**

    ```shell
    curl -X DELETE 'https://api.newrelic.com/v2/alerts_location_failure_conditions/$CONDITION_ID.json' \
         -H "$API_KEY" -i
    ```

**Multi-location synthetics: List existing conditions for policies**

To view a list of existing policy conditions for multi-location synthetic monitoring, use your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key) and the associated [`policy_id`](#policies-list) in the API call.

**[API Explorer](https://api.newrelic.com/docs/#/Deprecation%20Notice%20-%20Alerts%20Location%20Failure%20Conditions/get_alerts_location_failure_conditions_policies__policy_id__json) > Alerts Location Failure Conditions > GET > List**

````shell
curl -X GET 'https://api.newrelic.com/v2/alerts_location_failure_conditions/policies/$POLICY_ID.json' \
     -H "$API_KEY" -i
```

````

## Alert entity conditions [#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
>
> By default, this endpoint uses the US data center. If your organization hosts data in the EU data center, ensure you are using the proper [API endpoints for EU region accounts](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/getting-started/introduction-eu-region-data-center#endpoints). For [JP data center](https://docs.newrelic.com/docs/accounts/accounts-billing/account-setup/choose-your-data-center) accounts, ensure you are using the proper JP region API endpoints.

**List condition by entity**

To view the [conditions](https://docs.newrelic.com/docs/alerts/overview#alert-condition) an [entity](https://docs.newrelic.com/docs/alerts/overview#alert-entity) that apply to an entity in APM, browser, mobile, or key transactions, include these values in the API call:

-   Your [user key.](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The `entity_id` This is the specific [entity (alert target)](https://docs.newrelic.com/docs/alerts/overview#alert-entity) to be monitored.
-   The `entity_type`, which must be one of the following:

    -   `Application`
    -   `BrowserApplication`
    -   `MobileApplication`
    -   `KeyTransaction`

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Entity%20Conditions/get_alerts_entity_conditions__entity_id__json) > Alerts Entity Conditions > GET > list**

    ```shell
    curl -X GET 'https://api.newrelic.com/v2/alerts_entity_conditions/$ENTITY_ID.json' \
         -H "$API_KEY" -i \
         -G -d 'entity_type=$ENTITY_TYPE'
    ```

**Add an entity to a condition**

To add an [entity](https://docs.newrelic.com/docs/alerts/overview#alert-entity) to a condition, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The `entity_id` This is the [entity (alert target)](https://docs.newrelic.com/docs/alerts/overview#alert-entity) 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](https://api.newrelic.com/docs/#/Alerts%20Conditions/get_alerts_conditions_json) > Alerts Conditions > GET > List**)
-   The `entity_type`, which must be one of the following:

    -   `Application`
    -   `BrowserApplication`
    -   `MobileApplication`
    -   `KeyTransaction`

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Conditions/get_alerts_conditions_json) > Alerts Entity Conditions > PUT > Add**

    ```shell
    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'
    ```

**Remove an entity from a condition**

To remove an [entity](https://docs.newrelic.com/docs/alerts/overview#alert-entity) being monitored from a condition, include these values in the API call:

-   Your [user key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
-   The `entity_id` This is the specific monitored [entity (alert target)](https://docs.newrelic.com/docs/alerts/overview#alert-entity) 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](https://api.newrelic.com/docs/#/Alerts%20Conditions/get_alerts_conditions_json) > Alerts Conditions > GET > List**)
-   The `entity_type`, which must be one of the following:

    -   `Application`
    -   `BrowserApplication`
    -   `MobileApplication`
    -   `KeyTransaction`

    **[API Explorer](https://api.newrelic.com/docs/#/Alerts%20Entity%20Conditions/delete_alerts_entity_conditions__entity_id__json) > Alerts Entity Conditions > DELETE > Remove**

    ```shell
    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'
    ```
