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

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

Retrieves the details of a single alert policy.

## Inputs

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

| Input         | Type   | Description                                                     | Example                                                                                              |
| ------------- | ------ | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| **accountId** | Int    | **Required.** The New Relic account that owns the policy.       | `123456`                                                                                             |
| **id**        | String | **Required.** The ID of the policy to retrieve.                 | `"2000002"`                                                                                          |
| **selectors** | List   | **Optional.** JQ selectors to extract values from the response. | ```yaml selectors:   - name: policyName     expression: ".data.actor.account.alerts.policy.name" ``` |

## 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 fields from `.data.actor.account.alerts.policy`. ```json {   "data": {     "actor": {       "account": {         "alerts": {           "policy": {             "id": "2000002",             "name": "Production Services",             "incidentPreference": "PER_CONDITION",             "accountId": 123456,             "entityGuid": "MjAwMDAwMnxBTEVSVFN8UE9MSUNZfDIwMDAwMDI"           }         }       }     }   } } ``` |

## Example

The following example fetches a policy's current name before deciding whether to update it.

| Workflow example                                                                                                                                                                                                                                                                                                                                                                                      |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ```yaml name: get_alert_policy description: Get an alert policy steps:   - name: getPolicy     type: action     action: newrelic.alerts.getPolicy     version: 1     inputs:       accountId: ${{ .workflowInputs.accountId }}       id: ${{ .workflowInputs.policyId }}       selectors:         - name: policyName           expression: ".data.actor.account.alerts.policy.name"     next: end ``` |
