---
title: Disable and enable alerts conditions using the API
source: https://docs.newrelic.com/docs/alerts/scale-automate/rest-api/disable-enable-alerts-conditions-using-api
---

In a policy, a [condition](https://docs.newrelic.com/docs/alerts/create-alert/create-alert-condition/alert-conditions) identifies what triggers an alert. You can use the REST API to disable and enable conditions. You can also [disable and enable conditions in the UI](https://docs.newrelic.com/docs/alerts/new-relic-alerts/updating-alert-policies/disable-or-delete-alert-policies-conditions#condition-on-off).

[Policies can't be enabled or disabled](https://docs.newrelic.com/docs/alerts/new-relic-alerts/updating-alert-policies/disable-or-delete-alert-policies-conditions#disable-policy), whether via the API or the UI. Policies can only be created, deleted, or have their conditions changed.

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

The REST API is no longer the preferred way to programmatically manage your alerts. For more context, read the [Intro to APIs for alerts](https://docs.newrelic.com/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/alerts-api/intro-alerts-api).

## Requirements

Modifying any attribute in a condition using the API requires:

-   An [API key](https://docs.newrelic.com/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key) and permissions to manage alerts
-   The condition's `id` (available from [API Explorer:](https://api.newrelic.com/docs/#/Alerts%20Conditions) **Alerts Conditions > GET > List**)
-   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).

## Enable and disable a condition

The process for disabling or enabling a condition is the same general process for changing any attribute in a condition. A more detailed example comes after this general procedure:

1.  Find the ID for the policy that contains the condition you want to change.

    If the policy's ID is unknown, use the policy's name or type to make an API call and find the policy's ID. For more on this process, see [List a single policy](https://docs.newrelic.com/docs/alerts/alert-policies/rest-api-alert-policies/list-policies-v2#single_policy).
2.  With the policy ID, make an API call that returns the conditions associated with that policy. There are four different condition categories. If you don't know the category, this may require making up to four API calls in order to find the condition.

    **Details on searching for condition ID**

    If you don't know the category of the condition you want to change, you must search for it by making API calls using the four condition categories. Here are the different API call formats for the various condition categories.

    -   [APM, browser monitoring, and mobile monitoring](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/rest-api-calls-new-relic-alerts#conditions-list)  
        Conditions available: `apm_app_metric`, `apm_kt_metric`, `browser_metric`, and `mobile_metric`  
        [API Explorer link Get>List](https://api.newrelic.com/docs/#/Alerts%20Conditions)
    -   [External services](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/rest-api-calls-new-relic-alerts#ext-conditions-list)  
        Conditions available: `apm_external_service`, `mobile_external_service`  
        [API Explorer link Get>List](https://api.newrelic.com/docs/#/Alerts%20External%20Service%20Conditions)
    -   [Synthetic monitoring](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/rest-api-calls-new-relic-alerts#synthetics-conditions-list)  
        [API Explorer link Get>List](https://api.newrelic.com/docs/#/Alerts%20Synthetics%20Conditions)
3.  For the returned JSON, find the JSON object of the condition you want to change.
4.  Copy and paste the condition's JSON in a text editor of your choice and edit the JSON. To enable the condition, set `"enabled"` to `true`. To disable the condition, set `"enabled"` to `false`.
5.  Update the condition by submitting your edited JSON via an Update API request. Our different products require different API requests.

    **Details on Update API requests**

    Use the Update API request that corresponds to the product in question:

    -   [Conditions for APM, browser, and mobile](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/rest-api-calls-new-relic-alerts#conditions-update)  
        Conditions available: `apm_app_metric`, `apm_kt_metric`, `browser_metric`, and `mobile_metric`  
        [API Explorer PUT>Update link](https://api.newrelic.com/docs/#/Alerts%20Conditions/put_alerts_conditions__condition_id__json)
    -   [Conditions for external services](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/rest-api-calls-new-relic-alerts#ext-conditions-update)  
        Conditions available: `apm_external_service`, `mobile_external_service`  
        [API Explorer PUT>Update](https://api.newrelic.com/docs/#/Alerts%20External%20Service%20Conditions/put_alerts_external_service_conditions__condition_id__json)
    -   [Conditions for Synthetic monitoring](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/rest-api-calls-new-relic-alerts#synthetics-conditions-update))  
          [API Explorer PUT>Update](https://api.newrelic.com/docs/#/Alerts%20Synthetics%20Conditions/put_alerts_synthetics_conditions__condition_id__json)

        > #### 💡 TIP
        >
        > An Update API request can only change one condition at a time, it cannot update a vector of objects. For example, to change three conditions, you will have to make three separate requests.

## Example: Disable an APM condition [#example]

The following example shows how to disable a condition for an `apm_app_metric` condition. With the exception of the types of API calls required, the process is similar to the process for changing other condition types.

1.  Obtain the `policy_id` of the policy you want to update. For an imaginary policy named `Logjam Alert`, the command would be:

    ```shell
    curl -X GET 'https://api.newrelic.com/v2/alerts_policies.json' \
        -H "X-Api-Key:$API_KEY" -i \
        -G --data-urlencode 'filter[name]= Logjam Alert'  # policy_name
    ```

    The output for this request might look like:

    ```json
    {
      "policies": [
        {
          "id": 85,                            // policy_id
          "incident_preference": "PER_POLICY",
          "name": "Logjam Alert",
          "created_at": 1461176510393,
          "updated_at": 1461176510393
        }
      ]
    }
    ```
2.  List all of this policy's conditions and locate the `condition_id`:

    ```shell
    curl -X GET 'https://api.newrelic.com/v2/alerts_conditions.json' \
         -H "X-Api-Key:$API_KEY" -i \
         -G -d 'policy_id=85'
    ```

    The output for this request might look like:

    ```json
    {
      "conditions": [
        {
          "id": 12345,               // condition_id
          "type": "apm_app_metric",
          "name": "Apdex (Low)",
          "enabled": true,           // Note the condition is enabled
          "entities": [
            "8288171"
          ],
          "metric": "apdex",
          "terms": [
            {
              "duration": "5",
              "operator": "below",
              "priority": "critical",
              "threshold": "1",
              "time_function": "any"
            }
          ]
        },
        {
          "id": 2468,                // another condition_id
          "type": "apm_app_metric",
          "name": "Throughput (Low)",
          ...
        }
      ]
    }
    ```
3.  Copy the JSON for only the condition in question and paste it in a text editor. Change `"enabled": true` to `"enabled": false`. The edited JSON would look like:

    ```shell lineHighlight=9
    curl -X PUT 'https://api.newrelic.com/v2/alerts_conditions/12345.json' \
         -H "X-Api-Key:$API_KEY" -i \
         -H 'Content-Type: application/json' \
         -d \
    '{
      "condition": {
        "type": "apm_app_metric",
        "name": "Apdex (Low)",
        "enabled": false,
        "entities": [
          "8288171"
        ],
        "metric": "apdex",
        "terms": [
          {
            "duration": "5",
            "operator": "below",
            "priority": "critical",
            "threshold": "1",
            "time_function": "any"
          }
        ]
      }
    }'
    ```
4.  Update the condition by submitting the edited condition JSON via an Update API request. For this specific condition, you would follow the steps in [Update conditions for APM policies](https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/rest-api-calls-new-relic-alerts#conditions-update). Other product conditions would have other API requests, as detailed in [Update API requests](#update-api-requests).
