---
title: "Create"
method: POST
path: "/alerts_external_service_conditions/policies/{policy_id}.json"
tags: ["Alerts External Service Conditions"]
---

# Create

`POST /alerts_external_service_conditions/policies/{policy_id}.json`

## Request

- Base URL: `https://api.newrelic.com/v2`
- URL: `https://api.newrelic.com/v2/alerts_external_service_conditions/policies/{policy_id}.json`
- Auth: API key in header `Api-Key`
- TypeScript: <https://skmtc.dev/newrelic/apis/new-relic-rest-api-v2/docs/alerts_external_service_conditions/policies/:policy_id.json/post.ts> (a function with typed inputs; its response is checked against the schema)

🔥🔥 New users should use NRQL Alert Conditions, refer to <a href="https://docs.newrelic.com/docs/alerts-applied-intelligence/new-relic-alerts/advanced-alerts/alerts-nerdgraph/nerdgraph-api-examples/">these docs about managing alerts via NerdGraph.</a>

<p>This API endpoint allows you to create external service conditions for your alert policies.</p>

<p>Note: <a href="https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/rest-api-key">Admin User’s API Key</a> is required.</p>

<p>See our documentation for a discussion on <a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/rest-api-calls-new-relic-alerts#ext-conditions-create" target="_blank">creating conditions for external services</a>.</p>

<p>All fields are required except for “runbook_url”, “enabled” (defaults to false).</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#type" target="_blank">type</a>: apm_external_service, mobile_external_service.</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#name" target="_blank">name</a>: A title for your condition.</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#enabled" target="_blank">enabled</a>: The status of your condition (optional).</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#entities" target="_blank">entities</a>: An array of instance IDs associated with your condition.</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#external_service_url" target="_blank">external_service_url</a>: The URL of the external service. Must not include protocol (“example.com”, not “https://example.com”)</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#metric" target="_blank">metric</a>: The metric field accepts parameters based on the condition <b>type</b> selected as follows:</p>

<p>  When <b>apm_external_service</b>: response_time_average, response_time_minimum, response_time_maximum, throughput.</p>

<p>  When <b>mobile_external_service</b>: response_time_average, response_time_minimum, response_time_maximum, throughput, network_failure_percentage, http_status_error_percentage.</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#runbook_url" target="_blank">runbook_url</a>: Runbook URL to display in notifications (optional).</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_duration" target="_blank">terms[duration]</a> (in minutes): 5, 10, 15, 30, 60, 120.</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_operator" target="_blank">terms[operator]</a>: above, below, equal.</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_priority" target="_blank">terms[priority]</a>: critical, warning.</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_threshold" target="_blank">terms[threshold]</a>: Must be 0 or greater.</p>

<p><a href="https://docs.newrelic.com/docs/alerts/new-relic-alerts/rest-api-alerts/alerts-conditions-api-field-names#terms_time_function" target="_blank">terms[time_function]</a>: all, any.</p>

## Path parameters

- `policy_id` integer, required

## Request body

- ExternalServiceCondition
  - `external_service_condition` ExternalServiceConditionBody
    - `enabled` boolean
    - `entities` integer[]
    - `external_service_url` string
    - `metric` string
    - `name` string
    - `runbook_url` string
    - `terms` IJKTermsType[]
      - `duration` string
      - `operator` string
      - `priority` string
      - `threshold` string
      - `time_function` string
    - `type` string

## Response `200`

No response was specified

- ExternalServiceConditionResponse
  - `external_service_condition` ExternalServiceConditionResponseType
    - `enabled` boolean
    - `entities` integer[]
    - `external_service_url` string
    - `id` integer
    - `metric` string
    - `name` string
    - `runbook_url` string
    - `terms` IJKTermsType[]
      - `duration` string
      - `operator` string
      - `priority` string
      - `threshold` string
      - `time_function` string
    - `type` string

---

[API](https://skmtc.dev/newrelic/apis/new-relic-rest-api-v2.md) - [All operations](https://skmtc.dev/newrelic/apis/new-relic-rest-api-v2/llms.txt) - [OpenAPI document](https://skmtc.dev/newrelic/apis/new-relic-rest-api-v2/revisions/cf1843ad0a45?raw)
