---
title: Create an alert policy
source: https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/newrelic/alerts/newrelic-alerts-create-policy
---

The action identifier is `newrelic.alerts.createPolicy`.

Creates a new alert policy. A policy groups related alert conditions and controls how violations create incidents.

## Inputs

The following table describes all available input fields for this action.

| Input                  | Type   | Description                                                                                                                                                                                                                   | Example                                                                                 |
| ---------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| **accountId**          | Int    | **Required.** The New Relic account in which to create the policy. Must be a positive integer.                                                                                                                                | `123456`                                                                                |
| **name**               | String | **Required.** The name of the policy.                                                                                                                                                                                         | `"Production Services"`                                                                 |
| **incidentPreference** | String | **Required.** Determines how incidents are created for violations. One of `PER_CONDITION` (one issue per condition), `PER_CONDITION_AND_TARGET` (one issue per condition per signal), or `PER_POLICY` (one issue per policy). | `"PER_CONDITION"`                                                                       |
| **selectors**          | List   | **Optional.** JQ selectors to extract values from the response.                                                                                                                                                               | ```yaml selectors:   - name: policyId     expression: ".data.alertsPolicyCreate.id" ``` |

## Outputs

The following table describes all output fields returned by this action.

| Output           | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                       |
| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **success**      | Boolean | `true` when the step executed without error.                                                                                                                                                                                                                                                                                                                                                      |
| **errorMessage** | String  | Error message on failure. `null` on success.                                                                                                                                                                                                                                                                                                                                                      |
| **data**         | Map     | NerdGraph response. Use `selectors` to extract `id`, `name`, `incidentPreference`, `accountId`, or `entityGuid` from `data`. ```json {   "data": {     "alertsPolicyCreate": {       "id": "2000002",       "name": "Production Services",       "incidentPreference": "PER_CONDITION",       "accountId": 123456,       "entityGuid": "MTIzNDU2fEFJT1BTfE9QVFxfUE9MSUNZfDc4OTA="     }   } } ``` |

## Example

The following example creates an alert policy and captures the new policy ID for use in subsequent steps.

| Workflow example                                                                                                                                                                                                                                                                                                                                                                                                                       |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ```yaml name: create_alert_policy description: Create an alert policy steps:   - name: createPolicy     type: action     action: newrelic.alerts.createPolicy     version: 1     inputs:       accountId: ${{ .workflowInputs.accountId }}       name: "Production Services"       incidentPreference: "PER_CONDITION"       selectors:         - name: policyId           expression: ".data.alertsPolicyCreate.id"     next: end ``` |
