---
title: Search alert policies
source: https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/newrelic/alerts/newrelic-alerts-search-policies
---

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

Searches alert policies with optional filtering by ID or name. Supports cursor-based pagination. Omitting all filters returns all policies in the account.

## Inputs

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

| Input         | Type   | Description                                                                                             | Example                                                                                                                                                                                                    |
| ------------- | ------ | ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **accountId** | Int    | **Required.** The New Relic account to search policies in.                                              | `123456`                                                                                                                                                                                                   |
| **ids**       | List   | **Optional.** Filter to policies with these IDs.                                                        | `["2000002"]`                                                                                                                                                                                              |
| **name**      | String | **Optional.** Filter to policies with this exact name.                                                  | `"Production Services"`                                                                                                                                                                                    |
| **nameLike**  | String | **Optional.** Filter to policies whose name contains this substring.                                    | `"Production"`                                                                                                                                                                                             |
| **cursor**    | String | **Optional.** Pagination cursor from a prior call's `nextCursor` output. Leave blank on the first call. | `"eyJsYXN0SWQiOiIxMjM0NTYifQ=="`                                                                                                                                                                           |
| **selectors** | List   | **Optional.** JQ selectors to extract values from the response.                                         | ```yaml selectors:   - name: policies     expression: ".data.actor.account.alerts.policiesSearch.policies"   - name: nextCursor     expression: ".data.actor.account.alerts.policiesSearch.nextCursor" ``` |

## 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 `policies`, `nextCursor`, or `totalCount`. `nextCursor` is `null` when there are no further pages. ```json {   "data": {     "actor": {       "account": {         "alerts": {           "policiesSearch": {             "nextCursor": null,             "totalCount": 1,             "policies": [               {                 "id": "2000002",                 "name": "Production Services",                 "incidentPreference": "PER_CONDITION",                 "accountId": 123456               }             ]           }         }       }     }   } } ``` |

## Example

The following example finds all policies whose names contain "Production".

| Workflow example                                                                                                                                                                                                                                                                                                                                                                                                            |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ```yaml name: search_alert_policies description: Search alert policies by name steps:   - name: searchPolicies     type: action     action: newrelic.alerts.searchPolicies     version: 1     inputs:       accountId: ${{ .workflowInputs.accountId }}       nameLike: "Production"       selectors:         - name: policies           expression: ".data.actor.account.alerts.policiesSearch.policies"     next: end ``` |
