REST API calls for alerts

Our REST API (v2) allows you to configure settings for alerts. The 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.

For infrastructure alerting, see REST API for infrastructure monitoring alerts.

Available data and functions via API

REST API functions Comments
View account data

In general, any role can use the account's 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 must have an Owner or Admin role in your account and an Admin user's API key in order to use any maintenance function, including POST > Create, PUT > Add, PUT > Update, and DELETE.

Conditions excluded from the REST API

These types of conditions do not have available endpoints in the API:

  • APM: Web transaction percentiles, conditions targeting labels, and baselines
  • NRQL: Baselines

Alert policies

These API functions include links to the API Explorer, where you can create, delete, or list policies.

If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.

Create new policies

To add new policies, use your Admin user's API key, and include these two values in the API call:

Required values Definition
Incident incident_preference

Determines how Alerts will create incidents and group violations. This must be one of the following:

Policy name The policy name is required. Leaving it unchanged will create a policy called string.

API Explorer: Alerts Policies > POST > Create

curl -X POST 'https://api.newrelic.com/v2/alerts_policies.json' \
     -H 'X-Api-Key:{admin_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 Admin user's API key.

Required values Definition
id Required. 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.
Incident incident_preference

Determines how alerts will create incidents and group violations. Must be one of the following:

Policy name

Required. 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.

API Explorer: Alerts Policies > PUT > Update

curl -X PUT 'https://api.newrelic.com/v2/alerts_policies/{id}.json' \
     -H 'X-Api-Key:{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 Admin user's API key, and include the policy_id (available from API Explorer: Alerts Policies > GET > List) in the API call:

API Explorer: Alerts Policies > DELETE > Delete

curl -X DELETE 'https://api.newrelic.com/v2/alerts_policies/{policy_id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i 
List existing policies

To view a list of existing policies for your account, use your API key, and include these optional values in the API call:

  • Optional policy name filter
  • Optional pagination value

API Explorer: Alerts Policies > GET > List

curl -X GET 'https://api.newrelic.com/v2/alerts_policies.json' \
     -H 'X-Api-Key:{api_key}' -i 

Notification channels

These API functions include links to the API Explorer, where you can create, delete, or list Alerts notification channels.

If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.

Create new notification channels

To add new notification channels, use your Admin user's API key and include these values in the API call:

The API Explorer shows the format for required configuration values for each type of notification channel.

API Explorer: Alerts Channels > POST > Create

curl -X POST 'https://api.newrelic.com/v2/alerts_channels.json' \
     -H 'X-Api-Key:{admin_api_key}' -i \
     -H 'Content-Type: application/json' \
     -d \
'{
  "channel": {
    "name": "string",
    "type": "string",
    "configuration": "hash"
  }
}'  

The "hash" place holder in this example must be replaced by one of the following JSON blocks with the appropriate values substituted:

Email channel
{
  "recipients" : "test@google.com",
  "include_json_attachment" : true
}
    
OpsGenie channel
{
  "api_key": "abc123",
  "teams": "team1",
  "tags": "tag1",
  "recipients": "me@me.com"
}
Slack channel
{
  "url": "http://test.com",
  "channel": "channel1"
}
VictorOps channel
{
  "key": "mykey",
  "route_key": "theroute"
}
PagerDuty channel
{
  "service_key": "myservicekey"
}
Webhook (json) channel

This example shows the default payload inserted. (The payload attribute is optional.)

The payload can be customized to have different keys than the ones shown and will be sent with the $ prefixed attributes interpolated prior to delivery.

The condition_id is deprecated. Instead, use condition_family_id.

{
  "base_url": "http://test.com",
  "auth_username": "username",
  "auth_password": "password",
  "payload_type": "application/json",
  "headers": {
    "header1": "test", 
    "header2": "test"
  }
  "payload": {
    "account_id": "$ACCOUNT_ID",
    "account_name": "$ACCOUNT_NAME",
    "closed_violations_count_critical": "$CLOSED_VIOLATIONS_COUNT_CRITICAL",
    "closed_violations_count_warning": "$CLOSED_VIOLATIONS_COUNT_WARNING",
    "condition_family_id": "$CONDITION_FAMILY_ID",
    "condition_id": "$CONDITION_ID",
    "condition_name": "$CONDITION_NAME",
    "current_state": "$EVENT_STATE",
    "details": "$EVENT_DETAILS",
    "duration": "$DURATION",
    "event_type": "$EVENT_TYPE",
    "incident_acknowledge_url": "$INCIDENT_ACKNOWLEDGE_URL",
    "incident_id": "$INCIDENT_ID",
    "incident_url": "$INCIDENT_URL",
    "open_violations_count_critical": "$OPEN_VIOLATIONS_COUNT_CRITICAL",
    "open_violations_count_warning": "$OPEN_VIOLATIONS_COUNT_WARNING",
    "owner": "$EVENT_OWNER",
    "policy_name": "$POLICY_NAME",
    "policy_url": "$POLICY_URL",
    "runbook_url": "$RUNBOOK_URL",
    "severity": "$SEVERITY",
    "targets": "$TARGETS",
    "timestamp": "$TIMESTAMP",
    "violation_callback_url": "$VIOLATION_CALLBACK_URL",
    "violation_chart_url": "$VIOLATION_CHART_URL"
  }
}
Webhook (x-www-form-urlencoded) channel

This example shows the default payload inserted. (The payload attribute is optional.)

The payload can be customized to have different keys than the ones shown and will be sent with the $ prefixed attributes interpolated prior to delivery.

The condition_id is deprecated. Instead, use condition_family_id.

{
  "base_url": "http://test.com",
  "auth_username": "username",
  "auth_password": "password",
  "payload_type": "application/x-www-form-urlencoded",
  "headers": {
    "header1": "test", 
    "header2": "test"
  },
  "payload": { 
    "account_id": "$ACCOUNT_ID", 
    "account_name": "$ACCOUNT_NAME", 
    "closed_violations_count_critical": "$CLOSED_VIOLATIONS_COUNT_CRITICAL", 
    "closed_violations_count_warning": "$CLOSED_VIOLATIONS_COUNT_WARNING", 
    "condition_family_id": "$CONDITION_FAMILY_ID", 
    "condition_id": "$CONDITION_ID", 
    "condition_name": "$CONDITION_NAME", 
    "current_state": "$EVENT_STATE", 
    "details": "$EVENT_DETAILS", 
    "duration": "$DURATION", 
    "event_type": "$EVENT_TYPE", 
    "incident_acknowledge_url": "$INCIDENT_ACKNOWLEDGE_URL", 
    "incident_id": "$INCIDENT_ID", 
    "incident_url": "$INCIDENT_URL", 
    "open_violations_count_critical": "$OPEN_VIOLATIONS_COUNT_CRITICAL", 
    "open_violations_count_warning": "$OPEN_VIOLATIONS_COUNT_WARNING", 
    "owner": "$EVENT_OWNER", 
    "policy_name": "$POLICY_NAME", 
    "policy_url": "$POLICY_URL", 
    "runbook_url": "$RUNBOOK_URL", 
    "severity": "$SEVERITY", 
    "targets": "$TARGETS", 
    "timestamp": "$TIMESTAMP", 
    "violation_callback_url": "$VIOLATION_CALLBACK_URL", 
    "violation_chart_url": "$VIOLATION_CHART_URL" 
  }
}
Delete existing notification channels

To delete an existing notification channels, use your Admin user's API key, and include the channel_id (available from API Explorer: Alerts Channels > GET > List) in the API call:

API Explorer: Alerts Channels > DELETE > Delete

curl -X DELETE 'https://api.newrelic.com/v2/alerts_channels/{channel_id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i 
List existing notification channels

To view a list of existing notification channels for your account, use your REST API key or Admin user's API key and an optional pagination value in the API call.

API Explorer: Alerts Channels > GET > List

curl -X GET 'https://api.newrelic.com/v2/alerts_channels.json' \
     -H 'X-Api-Key:{api_key}' -i 
Update notification channels associated with policies

You can associate a policy with one or more notification channels. You can also associate a notification channel with one or more policies. To add notification channels to policies, use your Admin user's API key and these values in the API call:

  • A policy_id value (available from API Explorer: Alerts Policies > GET > List)
  • One or more channel_id values in an array, separated by commas or a new line (available from API Explorer: Alerts Channels > GET > List)

API Explorer: Alerts Policy Channels > PUT > Update

curl -X PUT 'https://api.newrelic.com/v2/alerts_policy_channels.json' \
     -H 'X-Api-Key:{admin_api_key}' -i \
     -H 'Content-Type: application/json' \
     -G -d 'policy_id=policy_id&channel_ids=channel_id' 
Delete notification channels associated with policies

You can associate a policy with one or more notification channels. You can also associate a notification channel with one or more alert policies.

To remove a policy from a channel, or to remove a channel from a policy, use your Admin user's API key and these values in the API call:

  • The policy_id (available from API Explorer: Alerts Policies > GET > List)
  • The channel_id (available from API Explorer: Alerts Channels > GET > List)

API Explorer: Alerts Policy Channels > DELETE > Delete

curl -X DELETE 'https://api.newrelic.com/v2/alerts_policy_channels.json' \
     -H 'X-Api-Key:{admin_api_key}' -i \
     -d 'channel_id={channel_id}&policy_id={policy_id}'  

Conditions for APM, Browser, Mobile

These API functions include links to the API Explorer, where you can create, update, delete, or list policy conditions. These calls are for conditions with these types of entities:

  • APM: Apps and key transactions
  • Browser: Apps and key transactions
  • Mobile: Mobile apps

Exception: The following APM conditions are not available from this API endpoint:

  • Conditions targeting labels (dynamic targeting)
  • Web transaction percentile conditions
  • Baseline conditions

The API Explorer provides information about other types of conditions using separate endpoints, including external services (APM and Mobile), plugins, 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.

Create conditions for policies

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

API Explorer: Alerts Conditions > POST > Create

curl -X POST 'https://api.newrelic.com/v2/alerts_conditions/policies/{policy_id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i \
     -H 'Content-Type: application/json' \
     -d \
'{
  "condition": {
    "type": "string",
    "name": "string",
    "enabled": boolean,
    "entities": [
      integer
    ],
    "metric": "string",
    "gc_metric": "string",
    "condition_scope": "string",
    "violation_close_timer": integer,
    "runbook_url": "string",
    "terms": [
      {
        "duration": "string",
        "operator": "string",
        "priority": "string",
        "threshold": "string",
        "time_function": "string"
      }
    ],
    "user_defined": {
      "metric": "string",
      "value_function": "string"
    }
  }
}' 

The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer: Alerts Conditions > GET > List.

Update conditions for policies

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

API Explorer: Alerts Conditions > PUT > Update

curl -X PUT 'https://api.newrelic.com/v2/alerts_conditions/{id}.json' \
     -H 'X-Api-Key:{admin_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:

API Explorer: Alerts Conditions > DELETE > Delete

curl -X DELETE 'https://api.newrelic.com/v2/alerts_conditions/{condition_id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i 
List existing conditions for policies

To view a list of existing conditions for your policy, use your REST API key or Admin user's API 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' \
     -H 'X-Api-Key:{api_key}' -i \
     -d 'policy_id={policy_id}' 

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 baseline conditions are not available from this endpoint.

If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.

Create NRQL conditions for policies

Recommendation: Due to the way NRQL data is aggregated, set the nrql[since_value] to 3 or higher to prevent false positives. This equates to the Evaluation Offset value in the Alerts Condition UI.

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 'X-Api-Key:{admin_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",
        "since_value": "string"
    }
  }
}' 

If you set nrql[since_value] to 3 and nrql[query] to SELECT count FROM myEvent, New Relic evaluates the following query against the terms[threshold] value once per minute:

SELECT count FROM myEvent SINCE 3 minutes ago UNTIL 2 minutes ago

If you set type as outlier, you can omit the value_function. However, two additional fields are required: expected_groups and ignore_overlap. For more information, see Alerts Conditions API field names.

If you omit type or set it as static, it will default to standard NRQL alerting.

Update NRQL conditions for policies

Recommendation: Due to the way NRQL data is aggregated, set the nrql[since_value] to 3 or higher to prevent false positives. This allows three minutes to aggregate data, and equates to the Evaluation Offset value in the Alerts Condition UI.

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

API Explorer: Alerts Nrql Conditions > PUT > Update

curl -X PUT 'https://api.newrelic.com/v2/alerts_nrql_conditions/{id}.json' \
     -H 'X-Api-Key:{admin_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",
        "since_value": "string"
    }
  }
}' 
Delete NRQL conditions for policies

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

API Explorer: Alerts Nrql Conditions > DELETE > Delete

curl -X DELETE 'https://api.newrelic.com/v2/alerts_nrql_conditions/{condition_id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i 
List existing NRQL conditions for policies

To view a list of existing conditions for your alert policy, use your REST API key or Admin user's API key and the associated policy_id in the API call.

API Explorer: Alerts Nrql Conditions > GET > List

curl -X GET 'https://api.newrelic.com/v2/alerts_nrql_conditions.json' \
     -H 'X-Api-Key:{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 APM and Mobile apps.

If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.

External services: Create conditions for policies

To add conditions for external services to policies that have APM or Mobile apps, include these values in the API call:

API Explorer: Alerts External Service Conditions > POST > Create

curl -X POST 'https://api.newrelic.com/v2/alerts_external_service_conditions/policies/{policy_id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i \
     -H 'Content-Type: application/json' \
     -d \
'{
  "external_service_condition": {
    "type": "string",
    "name": "string",
    "enabled": boolean,
    "entities": [
      integer
    ],
    "external_service_url": "string",
    "metric": "string",
    "runbook_url": "string",
    "terms": [
      {
        "duration": "string",
        "operator": "string",
        "priority": "string",
        "threshold": "string",
        "time_function": "string"
      }
    ]
  }
}' 

The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer: Alerts External Service Conditions > GET > List.

External services: Update conditions for policies

To update conditions for external services to policies that have APM or Mobile apps, include these values in the API call:

API Explorer: Alerts External Service Conditions > PUT > Update

curl -X PUT 'https://api.newrelic.com/v2/alerts_external_service_conditions/{id}.json' \
     -H 'X-Api-Key:{admin_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 apps, include these values in the API call:

API Explorer: Alerts External Service Conditions > DELETE > Delete

curl -X DELETE 'https://api.newrelic.com/v2/alerts_external_service_conditions/{condition_id}.json' \
     -H 'X-Api-Key:{admin_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), use your REST API key or Admin user's 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 'X-Api-Key:{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.

Synthetics: Create conditions for policies

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

API Explorer: Alerts Synthetics Conditions > POST > Create

curl -X POST 'https://api.newrelic.com/v2/alerts_synthetics_conditions/policies/{policy_id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i \
     -H 'Content-Type: application/json' \
     -d \
'{
  "synthetics_condition": {
    "name": "string",
    "monitor_id": "string",
    "runbook_url": "string",
    "enabled": boolean
  }
}' 
 

The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer: Alerts Synthetics Conditions > GET > List.

Synthetic monitoring: Update conditions for policies

To update policy conditions for Synthetic monitoring, include these values in the API call:

API Explorer: Alerts Synthetics Conditions > PUT > Update

curl -X PUT 'https://api.newrelic.com/v2/alerts_synthetics_conditions/{id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i \
     -H 'Content-Type: application/json' \
     -d \
'{
  "synthetics_condition": {
    "name": "string",
    "monitor_id": "string",
    "runbook_url": "string",
    "enabled": boolean
  }
}' 
Synthetic monitoring: Delete conditions from policies

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

API Explorer: Alerts Synthetics Conditions > DELETE > Delete

curl -X DELETE 'https://api.newrelic.com/v2/alerts_synthetics_conditions/{condition_id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i 
Synthetic monitoring: List existing conditions for policies

To view a list of existing policy conditions for Synthetic monitoring, use your REST API key or Admin user's 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 'X-Api-Key:{api_key}' -i \
     -d 'policy_id=policy_id' 

Conditions for plugins

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 plugins from New Relic's Plugin Central.

Plugins: Create conditions for policies

To add conditions to policies for plugin components or instances, include these values in the API call:

API Explorer: Alerts Plugins Conditions > POST > Create

curl -X POST 'https://api.newrelic.com/v2/alerts_plugins_conditions/policies/{policy_id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i \
     -H 'Content-Type: application/json' \
     -d \
'{
  "plugins_condition": {
    "name": "string",
    "enabled": boolean,
    "entities": [
      integer
    ],
    "metric_description": "string",
    "metric": "string",
    "value_function": "string",
    "runbook_url": "string",
    "terms": [
      {
        "duration": "string",
        "operator": "string",
        "priority": "string",
        "threshold": "string",
        "time_function": "string"
      }
    ],
    "plugin": {
      "id": "string",
      "guid": "string"
    }
  }
}' 

The JSON response returns a condition id, which you will need to update or delete the condition. You can also view the condition id from API Explorer: Alerts Plugins Conditions > GET > List.

Plugins: Update conditions for policies

To update policy conditions for plugin components or instances, include these values in the API call:

API Explorer: Alerts Plugins Conditions > PUT > Update

curl -X PUT 'https://api.newrelic.com/v2/alerts_plugins_conditions/{id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i \
     -H 'Content-Type: application/json' \
     -d \
'{
  "plugins_condition": {
    "name": "string",
    "enabled": boolean,
    "entities": [
      integer
    ],
    "metric_description": "string",
    "metric": "string",
    "value_function": "string",
    "runbook_url": "string",
    "terms": [
      {
        "duration": "string",
        "operator": "string",
        "priority": "string",
        "threshold": "string",
        "time_function": "string"
      }
    ],
    "plugin": {
      "id": "string",
      "guid": "string"
    }
  }
}'  
Plugins: Delete conditions from policies

To delete conditions from policies for plugin components or instances, include these values in the API call:

API Explorer: Alerts Plugins Conditions > DELETE > Delete

curl -X DELETE 'https://api.newrelic.com/v2/alerts_plugins_conditions/{condition_id}.json' \
     -H 'X-Api-Key:{admin_api_key}' -i 
Plugins: List existing conditions for policies

To view a list of existing conditions for policies with plugin components or instances, use your REST API key or Admin user's API key and the associated policy_id in the API call.

API Explorer: Alerts Plugins Conditions > GET > List

curl -X GET 'https://api.newrelic.com/v2/alerts_plugins_conditions.json' \
     -H 'X-Api-Key:{api_key}' -i \
     -d 'policy_id={policy_id}' 

Alert activity: Events, violations, incidents

These API functions include links to the API Explorer, where you can view information about events, violations, and incidents for your alert policies.

If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.

List Events

To view events for entities monitored by APM, Browser, Mobile, Plugins, Synthetic monitoring, and Alerts, include these values in the API call:

  • Your REST API key or Admin user's API key
  • Other optional values to use as filters (described in the API Explorer page) that depend on the type of product (browser monitoring, mobile monitoring, etc.), entity (as apps or key transactions for APM, synthetic monitoring, etc.), and type of event (notification, deployment, instrumentation, etc.)
  • An optional pagination value

API Explorer: Alerts Events > GET > List

curl -X GET 'https://api.newrelic.com/v2/alerts_events.json' \
     -H 'X-Api-Key:{api_key}' -i 
List Violations

To view violations for any entity monitored for your account, include these values in the API call:

API Explorer: Alerts Violations > GET > List

curl -X GET 'https://api.newrelic.com/v2/alerts_violations.json' \
     -H 'X-Api-Key:{api_key}' -i 

To find policy, condition, and incident information: take the IDs found in the links section in the violations property and place them into the URLs contained in the outer links property of the payload.

List Incidents

To view incidents for any entity monitored for your account, include these values in the API call:

API Explorer: Alerts Incidents > GET > List

curl -X GET 'https://api.newrelic.com/v2/alerts_incidents.json' \
     -H 'X-Api-Key:{api_key}' -i 
Show Incident

To show a single incident associated with your account, include these values in the API call:

API Explorer: Alerts Incidents > GET > Show

curl -X GET 'https://api.newrelic.com/v2/alerts_incidents/{id}.json' \
     -H 'X-Api-Key:{api_key}' -i 
Acknowledge Incident

To acknowledge an incident associated with your account, include these values in the API call:

API Explorer: Alerts Incidents > PUT > Acknowledge

curl -X PUT 'https://api.newrelic.com/v2/alerts_incidents/{id}/acknowledge.json' \
     -H 'X-Api-Key:{api_key}' -i \
     -H 'Content-Type: application/json' 
Close Incident

To close an incident associated with your account, include these values in the API call:

API Explorer: Alerts Incidents > PUT > Close

curl -X PUT 'https://api.newrelic.com/v2/alerts_incidents/{id}/close.json' \
     -H 'X-Api-Key:{api_key}' -i \
     -H 'Content-Type: application/json'

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.

If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts.

List condition by entity

To view the conditions an entity is part of for APM, Browser, Mobile, key transactions, and Plugins, include these values in the API call:

API Explorer: Alerts Entity Conditions > GET > list

curl -X GET 'https://api.newrelic.com/v2/alerts_entity_conditions/{entity_id}.json' \
     -H 'X-Api-Key:{api_key}' -i \
     -G -d 'entity_type={entity_type}' 
     
Add an entity to a condition

To add an entity to a condition, include these values in the API call:

  • Your Admin user's API key
  • The entity_id This is the entity (alert target) to be monitored. It is the numeric ID for the APM application, browser app, plugin, 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
    • Plugin

API Explorer: Alerts Entity Conditions > PUT > Add

curl -X PUT 'https://api.newrelic.com/v2/alerts_entity_conditions/{entity_id}.json' \
     -H 'X-Api-Key:{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 being monitored from a condition, include these values in the API call:

  • Your Admin user's API 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, plugin, 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
    • Plugin

API Explorer: Alerts Entity Conditions > DELETE > Remove

curl -X DELETE 'https://api.newrelic.com/v2/alerts_entity_conditions/{entity_id}.json' \
     -H 'X-Api-Key:{api_key}' -i \
     -G -d 'entity_type={entity_type}&condition_id={condition_id}' 

For more help

If you need more help, check out these support and learning resources: