---
title: Manage cross account destinations
source: https://docs.newrelic.com/docs/apis/nerdgraph/examples/cross-account-destinations/manage-cross-account-destinations
---

Use the NerdGraph API to create, test, list, update, and delete cross account destinations. Cross account destinations allow you to centralize notification management at the organization level.

## Create a destination [#create-destination]

In order to create a destination, different inputs must be provided for each destination type.

> #### ⚠️ IMPORTANT
>
> You must provide a scope object identifying where the destination will be created. The scope object requires:
>
> -   id: The ID of the Account or Organization.
> -   type: The type of scope (Account or Organization).
>
> An optional two_way_integration property is available for integrations that allow two-way integration.

**Create Atlassian Jira destination**

Use `aiNotificationsCreateDestination` mutation to create a Jira destination that integrates with your Atlassian Jira instance for creating and managing issues from New Relic alerts.

#### Input parameters

| **Parameter name**                                    | **Data type**    | **Description**                                                                                                                                                                |
| ----------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `scope`                                               | Object           | (Required) Defines the scope where the destination will be created. Use `type: ORGANIZATION` for cross account destinations or `type: ACCOUNT` for account-level destinations. |
| `scope.id`                                            | String           | (Required) The organization ID for cross account destinations or account ID for account-level destinations.                                                                    |
| `scope.type`                                          | Enum             | (Required) Must be `ORGANIZATION` for cross account destinations or `ACCOUNT` for account-level destinations.                                                                  |
| `destination.type`                                    | Enum             | (Required) Must be `JIRA` for Atlassian Jira destinations.                                                                                                                     |
| `destination.name`                                    | String           | (Required) A descriptive name for the Jira destination.                                                                                                                        |
| `destination.auth`                                    | Object           | (Required) Authentication configuration for connecting to your Jira instance.                                                                                                  |
| `destination.auth.type`                               | Enum             | (Required) Must be `BASIC` for Jira integrations using username and password/API token authentication.                                                                         |
| `destination.auth.basic`                              | Object           | (Required) Contains the Jira authentication credentials (email and password/API token).                                                                                        |
| `destination.auth.basic.user`                         | String           | (Required) Your Jira account email address.                                                                                                                                    |
| `destination.auth.basic.password`                     | String           | (Required) Your Jira account password or API token. For security, use an API token instead of your account password.                                                           |
| `destination.properties`                              | Array of Objects | (Required) Configuration properties including the Jira instance URL and integration options.                                                                                   |
| `destination.properties[].key: "url"`                 | String           | (Required) Must include a property with key "url" and value set to your Jira instance URL (e.g., "<https://yourcompany.atlassian.net">).                                       |
| `destination.properties[].key: "two_way_integration"` | String           | (Optional) Set to "true" to enable bidirectional integration between New Relic and Jira.                                                                                       |

#### Sample query for an account and organization:

````graphql
mutation {
  aiNotificationsCreateDestination(
    scope: { id: YOUR_ACCOUNT_ID, type: ACCOUNT }
    destination: {
      type: JIRA
      name: "Destination Name"
      auth: {
        type: BASIC
        basic: { user: YOUR_EMAIL, password: YOUR_PASSWORD }
      }
      properties: [
        { key: "url", value: "https://YOUR_INSTANCE.atlassian.net" }
        { key: "two_way_integration", value: "true" }
      ]
    }
  ) {
    destination {
      id
      name
      scope {
        id
        type
      }
    }
  }
}
```

#### Sample query for an organization:

```graphql
mutation {
  aiNotificationsCreateDestination(
    scope: { id: YOUR_ORGANIZATION_ID, type: ORGANIZATION }
    destination: {
      type: JIRA
      name: "Destination Name"
      auth: {
        type: BASIC
        basic: { user: YOUR_EMAIL, password: YOUR_PASSWORD }
      }
      properties: [
        { key: "url", value: "https://YOUR_INSTANCE.atlassian.net" }
        { key: "two_way_integration", value: "true" }
      ]
    }
  ) {
    destination {
      id
      name
      scope {
        id
        type
      }
    }
  }
}
```


````

**Create email destination**

Use `aiNotificationsCreateDestination` mutation to create an email destination for sending notification alerts to email addresses.

#### Input parameters

| **Parameter name**       | **Data type**    | **Description**                                                                                                                                                                |
| ------------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `scope`                  | Object           | (Required) Defines the scope where the destination will be created. Use `type: ORGANIZATION` for cross account destinations or `type: ACCOUNT` for account-level destinations. |
| `scope.id`               | String           | (Required) The organization ID for cross account destinations or account ID for account-level destinations.                                                                    |
| `scope.type`             | Enum             | (Required) Must be `ORGANIZATION` for cross account destinations or `ACCOUNT` for account-level destinations.                                                                  |
| `destination.type`       | Enum             | (Required) Must be `EMAIL` for email destinations.                                                                                                                             |
| `destination.name`       | String           | (Required) A descriptive name for the email destination.                                                                                                                       |
| `destination.properties` | Array of Objects | (Required) Key-value pairs containing the email configuration. Must include an `email` key with the target email address as the value.                                         |

#### Sample query:

````graphql
mutation {
  aiNotificationsCreateDestination(
    scope: { id: YOUR_ACCOUNT_ID, type: ACCOUNT }
    destination: {
      type: EMAIL
      name: "Destination Name"
      properties: [{ key: "email", value: YOUR_EMAIL }]
    }
  ) {
    destination {
      id
      name
      scope {
        id
        type
      }
    }
  }
}
```

````

**Create webhook destination**

Use `aiNotificationsCreateDestination` mutation to create a webhook destination for sending HTTP POST requests to external endpoints when alerts are triggered.

#### Input parameters

| **Parameter name**       | **Data type**    | **Description**                                                                                                                                                                    |
| ------------------------ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `scope`                  | Object           | (Required) Defines the scope where the destination will be created. Use `type: ORGANIZATION` for cross account destinations or `type: ACCOUNT` for account-level destinations.     |
| `scope.id`               | String           | (Required) The organization ID for cross account destinations or account ID for account-level destinations.                                                                        |
| `scope.type`             | Enum             | (Required) Must be `ORGANIZATION` for cross account destinations or `ACCOUNT` for account-level destinations.                                                                      |
| `destination.type`       | Enum             | (Required) Must be `WEBHOOK` for webhook destinations.                                                                                                                             |
| `destination.name`       | String           | (Required) A descriptive name for the webhook destination.                                                                                                                         |
| `destination.auth`       | Object           | (Optional) Authentication configuration. Required only when the webhook endpoint requires authentication.                                                                          |
| `destination.auth.type`  | Enum             | (Required when auth is provided) Authentication method. Options: `BASIC`, `TOKEN`.                                                                                                 |
| `destination.auth.basic` | Object           | (Required for BASIC and TOKEN auth) Contains authentication credentials such as username/password or token information.                                                            |
| `destination.properties` | Array of Objects | (Required) Key-value pairs containing webhook configuration. Must include `url` key with the webhook endpoint URL. Optional `two_way_integration` for bidirectional communication. |

#### Sample query:

````graphql
mutation {
  aiNotificationsCreateDestination(
    scope: { id: YOUR_ACCOUNT_ID, type: ACCOUNT }
    destination: {
      type: WEBHOOK
      name: "Destination Name"
      auth: {
        type: BASIC
        basic: { user: YOUR_EMAIL, password: YOUR_PASSWORD }
      }
      properties: [
        { key: "url", value: YOUR_WEBHOOK }
        { key: "two_way_integration", value: "true" }
      ]
    }
  ) {
    destination {
      id
      name
      scope {
        id
        type
      }
    }
  }
}
```

````

**Create PagerDuty service level destination**

Use `aiNotificationsCreateDestination` mutation to create a PagerDuty service-level destination that integrates with a specific PagerDuty service using an integration key.

#### Input parameters

| **Parameter name**              | **Data type**    | **Description**                                                                                                                                                                |
| ------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `scope`                         | Object           | (Required) Defines the scope where the destination will be created. Use `type: ORGANIZATION` for cross account destinations or `type: ACCOUNT` for account-level destinations. |
| `scope.id`                      | String           | (Required) The organization ID for cross account destinations or account ID for account-level destinations.                                                                    |
| `scope.type`                    | Enum             | (Required) Must be `ORGANIZATION` for cross account destinations or `ACCOUNT` for account-level destinations.                                                                  |
| `destination.type`              | Enum             | (Required) Must be `PAGERDUTY_SERVICE_INTEGRATION` for PagerDuty service-level destinations.                                                                                   |
| `destination.name`              | String           | (Required) A descriptive name for the PagerDuty service destination.                                                                                                           |
| `destination.auth`              | Object           | (Required) Authentication configuration containing the PagerDuty integration key.                                                                                              |
| `destination.auth.type`         | Enum             | (Required) Must be `TOKEN` for PagerDuty service integrations.                                                                                                                 |
| `destination.auth.basic`        | Object           | (Required) Contains the integration token and prefix for PagerDuty authentication.                                                                                             |
| `destination.auth.basic.token`  | String           | (Required) The PagerDuty integration key obtained from your PagerDuty service configuration.                                                                                   |
| `destination.auth.basic.prefix` | String           | (Required) Must be `"Token token="` for PagerDuty service integrations.                                                                                                        |
| `destination.properties`        | Array of Objects | (Optional) Additional configuration properties. Can be empty array for basic service integration.                                                                              |

#### Sample query:

````graphql
mutation {
  aiNotificationsCreateDestination(
    scope: { id: YOUR_ACCOUNT_ID, type: ACCOUNT }
    destination: {
      type: PAGERDUTY_SERVICE_INTEGRATION
      name: "Destination Name"
      auth: {
        type: TOKEN
        basic: { token: YOUR_INTEGRATION_TOKEN, prefix: "Token token=" }
      }
      properties: []
    }
  ) {
    destination {
      id
      name
      scope {
        id
        type
      }
    }
  }
}
```

````

**Create PagerDuty account level destination**

Use `aiNotificationsCreateDestination` mutation to create a PagerDuty account-level destination that integrates with your entire PagerDuty account using an API key, allowing for broader incident management capabilities.

#### Input parameters

| **Parameter name**              | **Data type**    | **Description**                                                                                                                                                                |
| ------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `scope`                         | Object           | (Required) Defines the scope where the destination will be created. Use `type: ORGANIZATION` for cross account destinations or `type: ACCOUNT` for account-level destinations. |
| `scope.id`                      | String           | (Required) The organization ID for cross account destinations or account ID for account-level destinations.                                                                    |
| `scope.type`                    | Enum             | (Required) Must be `ORGANIZATION` for cross account destinations or `ACCOUNT` for account-level destinations.                                                                  |
| `destination.type`              | Enum             | (Required) Must be `PAGERDUTY_ACCOUNT_INTEGRATION` for PagerDuty account-level destinations.                                                                                   |
| `destination.name`              | String           | (Required) A descriptive name for the PagerDuty account destination.                                                                                                           |
| `destination.auth`              | Object           | (Required) Authentication configuration containing the PagerDuty account API key.                                                                                              |
| `destination.auth.type`         | Enum             | (Required) Must be `TOKEN` for PagerDuty account integrations.                                                                                                                 |
| `destination.auth.basic`        | Object           | (Required) Contains the API token and prefix for PagerDuty account authentication.                                                                                             |
| `destination.auth.basic.token`  | String           | (Required) The PagerDuty account API key obtained from your PagerDuty account settings.                                                                                        |
| `destination.auth.basic.prefix` | String           | (Required) Must be `"Token token="` for PagerDuty account integrations.                                                                                                        |
| `destination.properties`        | Array of Objects | (Optional) Configuration properties for the account integration. Common property: `two_way_integration` set to "true" for bidirectional communication.                         |

#### Sample query:

````graphql
mutation {
  aiNotificationsCreateDestination(
    scope: { id: YOUR_ACCOUNT_ID, type: ACCOUNT }
    destination: {
      type: PAGERDUTY_ACCOUNT_INTEGRATION
      name: "Global PagerDuty Account"
      auth: {
        type: TOKEN
        basic: { token: YOUR_API_KEY, prefix: "Token token=" }
      }
      properties: [{ key: "two_way_integration", value: "true" }]
    }
  ) {
    destination {
      id
      name
      scope {
        id
        type
      }
    }
  }
}
```

````

**Create Slack destination**

Creating a cross-account Slack destination in New Relic requires OAuth authentication between the NerdGraph API and Slack. The following steps show you how to generate the authentication URL and complete the setup.

1.  **Generate the OAuth URL**
    1.  Open the [NerdGraph Explorer](https://api.newrelic.com/graphiql) and paste the following query into the query editor. This query generates a unique Slack OAuth URL for your organization.

        ```graphql
        {
          actor {
            organization {
              aiNotifications {
                oAuthUrl(type: SLACK) {
                  url
                  transactionId
                  error {
                    description
                    details
                    type
                  }
                }
              }
            }
          }
        }
        ```

    2.  Click **Play** (Execute Query) at the top of the explorer.
2.  **Access the authentication link**
    1.  Once the query runs, you will see a JSON response on the right side of the screen containing a URL.
    2.  Locate the `url` field in the response.
    3.  Copy the entire URL string (everything inside the quotation marks).
    4.  Open a new tab in your browser and paste the URL.
3.  **Complete Slack authorization**
    1.  The link takes you to a Slack authorization page.
    2.  If prompted, sign in to the Slack workspace you want to connect.
    3.  Review the permissions requested by New Relic.
    4.  To authorize the connection, click **Allow**.
    5.  You should be redirected back to a New Relic "Success" page.
4.  **Verify the destination**
    After successful OAuth authentication, the destination is automatically created at the organization level, making it available across all accounts in your organization.
    1.  Navigate to **[one.newrelic.com](https://one.newrelic.com) > Alerts > Destinations**.
    2.  In the **Destinations** list, you should now see a new entry for the Slack workspace you just authenticated.

**Create ServiceNow destination**

Use `aiNotificationsCreateDestination` mutation to create a ServiceNow destination that integrates with your ServiceNow instance for creating and managing incidents from New Relic alerts.

#### Input parameters

| **Parameter name**                                    | **Data type**    | **Description**                                                                                                                                                                |
| ----------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `scope`                                               | Object           | (Required) Defines the scope where the destination will be created. Use `type: ORGANIZATION` for cross account destinations or `type: ACCOUNT` for account-level destinations. |
| `scope.id`                                            | String           | (Required) The organization ID for cross account destinations or account ID for account-level destinations.                                                                    |
| `scope.type`                                          | Enum             | (Required) Must be `ORGANIZATION` for cross account destinations or `ACCOUNT` for account-level destinations.                                                                  |
| `destination.type`                                    | Enum             | (Required) Must be `SERVICE_NOW` for ServiceNow destinations.                                                                                                                  |
| `destination.name`                                    | String           | (Required) A descriptive name for the ServiceNow destination.                                                                                                                  |
| `destination.auth`                                    | Object           | (Required) Authentication configuration for connecting to your ServiceNow instance.                                                                                            |
| `destination.auth.type`                               | Enum             | (Required) Must be `BASIC` for ServiceNow integrations using username and password authentication.                                                                             |
| `destination.auth.basic`                              | Object           | (Required) Contains the ServiceNow authentication credentials (username and password).                                                                                         |
| `destination.auth.basic.user`                         | String           | (Required) Your ServiceNow account username or email address.                                                                                                                  |
| `destination.auth.basic.password`                     | String           | (Required) Your ServiceNow account password. Consider using a service account for better security.                                                                             |
| `destination.properties`                              | Array of Objects | (Required) Configuration properties including the ServiceNow instance URL and integration options.                                                                             |
| `destination.properties[].key: "url"`                 | String           | (Required) Must include a property with key "url" and value set to your ServiceNow instance URL (e.g., "<https://yourcompany.service-now.com">).                               |
| `destination.properties[].key: "two_way_integration"` | String           | (Optional) Set to "true" to enable bidirectional integration between New Relic and ServiceNow.                                                                                 |

#### Sample query:

````graphql
mutation {
  aiNotificationsCreateDestination(
    scope: { id: YOUR_ACCOUNT_ID, type: ACCOUNT }
    destination: {
      type: SERVICE_NOW
      name: "Destination Name"
      auth: {
        type: BASIC
        basic: { user: YOUR_EMAIL, password: YOUR_PASSWORD }
      }
      properties: [
        { key: "url", value: "https://YOUR_INSTANCE.service-now.com" }
        { key: "two_way_integration", value: "true" }
      ]
    }
  ) {
    destination {
      id
      name
      scope {
        id
        type
      }
    }
  }
}
```

````

**Create AWS EventBridge destination**

Use `aiNotificationsCreateDestination` mutation to create an AWS EventBridge destination that sends New Relic alert events to your AWS EventBridge for further processing and routing within your AWS ecosystem.

#### Input parameters

| **Parameter name**                             | **Data type**    | **Description**                                                                                                                                                                |
| ---------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `scope`                                        | Object           | (Required) Defines the scope where the destination will be created. Use `type: ORGANIZATION` for cross account destinations or `type: ACCOUNT` for account-level destinations. |
| `scope.id`                                     | String           | (Required) The organization ID for cross account destinations or account ID for account-level destinations.                                                                    |
| `scope.type`                                   | Enum             | (Required) Must be `ORGANIZATION` for cross account destinations or `ACCOUNT` for account-level destinations.                                                                  |
| `destination.type`                             | Enum             | (Required) Must be `EVENT_BRIDGE` for AWS EventBridge destinations.                                                                                                            |
| `destination.name`                             | String           | (Required) A descriptive name for the AWS EventBridge destination.                                                                                                             |
| `destination.auth`                             | Object           | (Required) Authentication configuration for connecting to AWS EventBridge using IAM credentials.                                                                               |
| `destination.auth.type`                        | Enum             | (Required) Must be `BASIC` for AWS EventBridge integrations using IAM user credentials.                                                                                        |
| `destination.auth.basic`                       | Object           | (Required) Contains the AWS IAM authentication credentials (access key ID and secret access key).                                                                              |
| `destination.auth.basic.user`                  | String           | (Required) Your AWS IAM access key ID. Ensure the IAM user has EventBridge permissions.                                                                                        |
| `destination.auth.basic.password`              | String           | (Required) Your AWS IAM secret access key. Store this securely and consider using IAM roles when possible.                                                                     |
| `destination.properties`                       | Array of Objects | (Required) Configuration properties including the AWS account ID and region for EventBridge.                                                                                   |
| `destination.properties[].key: "AWSAccountId"` | String           | (Required) Must include a property with key "AWSAccountId" and value set to your AWS account ID (12-digit number).                                                             |
| `destination.properties[].key: "AWSRegion"`    | String           | (Required) Must include a property with key "AWSRegion" and value set to your AWS region (e.g., "us-east-1", "eu-west-1").                                                     |

#### Sample query:

````graphql
mutation {
  aiNotificationsCreateDestination(
    scope: { id: YOUR_ACCOUNT_ID, type: ACCOUNT }
    destination: {
      type: EVENT_BRIDGE
      name: "Destination Name"
      auth: {
        type: BASIC
        basic: { user: YOUR_IAM_USER, password: YOUR_PASSWORD }
      }
      properties: [
        { key: "AWSAccountId", value: YOUR_AWS_ACCOUNT_ID }
        { key: "AWSRegion", value: YOUR_AWS_REGION }
      ]
    }
  ) {
    destination {
      id
      name
      scope {
        id
        type
      }
    }
  }
}
```

````

## Test a cross account destination [#test-destination]

You can test cross account destinations before or after creation. You must provide the scope object.

**Test destination configuration**

Use `aiNotificationsTestDestination` mutation to test a destination configuration before creating it. This allows you to validate the settings and credentials without actually creating the destination.

#### Input parameters

| **Parameter name**       | **Data type**    | **Description**                                                                                                                                                                         |
| ------------------------ | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `scope`                  | Object           | (Required) Defines the scope for the test. Use `type: ORGANIZATION` for cross account destinations or `type: ACCOUNT` for account-level destinations.                                   |
| `scope.id`               | String           | (Required) The organization ID for cross account destinations or account ID for account-level destinations.                                                                             |
| `scope.type`             | Enum             | (Required) Must be `ORGANIZATION` for cross account destinations or `ACCOUNT` for account-level destinations.                                                                           |
| `destination`            | Object           | (Required) The destination configuration object to test, including type, name, authentication, and properties.                                                                          |
| `destination.type`       | Enum             | (Required) The destination type to test. Options: `EMAIL`, `WEBHOOK`, `PAGERDUTY_SERVICE_INTEGRATION`, `PAGERDUTY_ACCOUNT_INTEGRATION`, `SLACK`, `JIRA`, `SERVICE_NOW`, `EVENT_BRIDGE`. |
| `destination.name`       | String           | (Required) A name for the destination configuration being tested.                                                                                                                       |
| `destination.auth`       | Object           | (Optional) Authentication configuration for destinations that require credentials. Required for WEBHOOK, PAGERDUTY, JIRA, SERVICE_NOW, and EVENT_BRIDGE destinations.                   |
| `destination.properties` | Array of Objects | (Required) Key-value pairs that configure destination-specific settings such as URLs, email addresses, or integration options.                                                          |

#### Sample query:

````graphql
mutation {
  aiNotificationsTestDestination(
    scope: { id: YOUR_ACCOUNT_ID, type: ACCOUNT }
    destination: {
      type: EMAIL
      name: "Destination Name"
      properties: [{ key: "email", value: YOUR_EMAIL }]
    }
  ) {
    error {
      details
    }
    details
    result
  }
}
```

````

**Test existing destination by ID**

Use `aiNotificationsTestDestinationById` mutation to test an existing destination by its ID. This verifies that the destination is properly configured and can successfully deliver notifications.

#### Input parameters

| **Parameter name** | **Data type** | **Description**                                                                                                                                                         |
| ------------------ | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `scope`            | Object        | (Required) Defines the scope where the destination exists. Use `type: ORGANIZATION` for cross account destinations or `type: ACCOUNT` for account-level destinations.   |
| `scope.id`         | String        | (Required) The organization ID for cross account destinations or account ID for account-level destinations.                                                             |
| `scope.type`       | Enum          | (Required) Must be `ORGANIZATION` for cross account destinations or `ACCOUNT` for account-level destinations.                                                           |
| `destinationId`    | String        | (Required) The unique identifier of the existing destination you want to test. This ID is returned when creating a destination or can be found by listing destinations. |

#### Sample query:

````graphql
mutation {
  aiNotificationsTestDestinationById(
    scope: { id: YOUR_ACCOUNT_ID, type: ACCOUNT }
    destinationId: YOUR_DESTINATION_ID
  ) {
    error {
      details
    }
    details
    result
  }
}
```

````

## List and filter destinations [#list-and-filter]

The `destinations` query allows you to paginate through all of your destinations at both account and organization levels. It also allows filtering functionality for cross account destinations.

**List all cross account destinations for an organization**

Use the `actor.organization.aiNotifications.destinations` query to retrieve all destinations at the organization level, including cross account destinations that can be used across all accounts in the organization.

#### Input parameters

This query uses the GraphQL `actor.organization` context and does not require explicit input parameters. The query automatically returns all destinations accessible at the organization level.

| **Query field**   | **Data type** | **Description**                                                                                                       |
| ----------------- | ------------- | --------------------------------------------------------------------------------------------------------------------- |
| `actor`           | Object        | Root query object representing the authenticated user's context.                                                      |
| `organization`    | Object        | Organization context that provides access to organization-level resources and cross account destinations.             |
| `aiNotifications` | Object        | AI Notifications service context for accessing notification-related resources.                                        |
| `destinations`    | Object        | Query field that returns all destinations accessible at the organization level, including cross account destinations. |

#### Sample query:

````graphql
{
  actor {
    organization {
      aiNotifications {
        destinations {
          entities {
            id
            name
            scope {
              id
              type
            }
          }
          error {
            details
          }
        }
      }
    }
  }
}
```

````

**List destinations for a specific account**

Use the `actor.account.aiNotifications.destinations` query to retrieve all destinations accessible to a specific account, including both account-scoped destinations and cross account destinations available to that account.

#### Input parameters

| **Parameter name** | **Data type** | **Description**                                                                                                                   |
| ------------------ | ------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `account.id`       | String/ID     | (Required) The specific account ID for which to retrieve destinations. This account must be accessible to the authenticated user. |

#### Query fields

| **Query field**   | **Data type** | **Description**                                                                                                              |
| ----------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `actor`           | Object        | Root query object representing the authenticated user's context.                                                             |
| `account`         | Object        | Account context that provides access to account-specific resources and cross account destinations available to this account. |
| `aiNotifications` | Object        | AI Notifications service context for accessing notification-related resources.                                               |
| `destinations`    | Object        | Query field that returns all destinations accessible to the specified account (both account-scoped and organization-scoped). |

#### Sample query:

````graphql
{
  actor {
    account(id: YOUR_ACCOUNT_ID) {
      aiNotifications {
        destinations {
          entities {
            id
            name
            scope {
              id
              type
            }
          }
          error {
            details
          }
        }
      }
    }
  }
}
```

````

**Paginating through destinations with cursor pagination**

Use cursor pagination to efficiently navigate through large sets of destinations. You must request the `nextCursor` field in your query to enable pagination.

#### Input parameters

| **Parameter name**    | **Data type** | **Description**                                                                                                                                                 |
| --------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `account.id`          | String/ID     | (Required) The specific account ID for which to retrieve destinations. This account must be accessible to the authenticated user.                               |
| `destinations.cursor` | String        | (Optional) Cursor for pagination. Use empty string `""` for the first request, then use the `nextCursor` value from previous responses to get subsequent pages. |

#### Pagination workflow

With cursor pagination, you continue to make requests through the result set until the `nextCursor` that is returned from the response comes back empty. This signifies that you reached the end of your results.

Here's an example for an account (the same logic applies to organization):

````graphql
{
  actor {
    account(id: YOUR_ACCOUNT_ID) {
      aiNotifications {
        destinations(cursor: "") {
          nextCursor
          entities {
            id
            name
            scope {
              id
              type
            }
          }
          totalCount
        }
      }
    }
  }
}
```

The code above returns a set of results like this:

```json
{
  "data": {
    "actor": {
      "account": {
        "aiNotifications": {
          "destinations": {
            "nextCursor": "/8o0y2qiR54m6thkdgHgwg==:jZTXDFKbTkhKwvMx+CtsPVM=",
            "entities": [
              {
                "id": "01c0cbe7-3d70-47c1-99e0-adf906eed6c2",
                "name": "Destination Name",
                "scope": {
                  "type": "ACCOUNT",
                  "id": "312312"
                }
              },
              {
                "id": "05db0207-c137-4985-8cb5-f21e7e57b8cc",
                "name": "Another Destination Name",
                "scope": {
                  "type": "ACCOUNT",
                  "id": "312312"
                }
              }
            ],
            "totalCount": 807
          }
        }
      }
    }
  }
}
```

So, in your subsequent request, provide the cursor like so, until the cursor is empty:

```graphql
{
  actor {
    account(id: YOUR_ACCOUNT_ID) {
      aiNotifications {
        destinations(cursor: "/8o0y2qiR54m6thkdgHgwg==:jZTXDFKbTkhKwvMx+CtsPVM=") {
          nextCursor
          entities {
            id
            name
            scope {
              id
              type
            }
          }
          totalCount
        }
      }
    }
  }
}
```
Here's another example for an organization

```graphql
{
  actor {
    organization {
      aiNotifications {
        destinations(cursor: "") {
          nextCursor
          entities {
            id
            name
            scope {
              id
              type
            }
          }
          totalCount
        }
      }
    }
  }
}
```
The code above returns a set of results like this:

```json
{
  "data": {
    "actor": {
      "organization": {
        "aiNotifications": {
          "destinations": {
            "nextCursor": "/8o0y2qiR54m6thkdgHgwg==:jZTXDFKbTkhKwvMx+CtsPVM=",
            "entities": [
              {
                "id": "01c0cbe7-3d70-47c1-99e0-adf906eed6c2",
                "name": "Destination Name",
                "scope": {
                  "type": "ORGANIZATION",
                  "id": "01ddcbe7-3d70-47c1-99e0-adf906eed6c2"
                }
              },
              {
                "id": "05db0207-c137-4985-8cb5-f21e7e57b8cc",
                "name": "Another Destination Name",
                "scope": {
                  "type": "ORGANIZATION",
                  "id": "01ddcbe7-3d70-47c1-99e0-adf906eed6c2"
                }
              }
            ],
            "totalCount": 807
          }
        }
      }
    }
  }
}
```
So, in your subsequent request, provide the cursor like so, until the cursor is empty:

```graphql
{
  actor {
    organization {
      aiNotifications {
        destinations(cursor: "/8o0y2qiR54m6thkdgHgwg==:jZTXDFKbTkhKwvMx+CtsPVM=") {
          nextCursor
          entities {
            id
            name
            scope {
              id
              type
            }
          }
          totalCount
        }
      }
    }
  }
}
```


````

**Filter destinations by name**

Use name filtering to search for destinations by their names. The name filter supports both exact matches and partial matches, and is case insensitive.

#### Input parameters

| **Parameter name**          | **Data type** | **Description**                                                                                                                                         |
| --------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `account.id`                | String/ID     | (Required) The specific account ID for which to retrieve destinations. This account must be accessible to the authenticated user.                       |
| `destinations.filters`      | Object        | (Required) Filter criteria object to narrow down results.                                                                                               |
| `destinations.filters.name` | String        | (Required) Filter by destination name. Supports partial matches and is case insensitive. Returns destinations whose names contain the specified string. |

#### Sample query:

This example finds destinations with "DevOps" in the name:

````graphql
{
  actor {
    account(id: YOUR_ACCOUNT_ID) {
      aiNotifications {
        destinations(filters: { name: "DevOps" }) {
          entities {
            id
            name
            scope {
              id
              type
            }
          }
        }
      }
    }
  }
}
```

````

**Filter destinations by ID**

Use ID filtering to retrieve a specific destination by its unique identifier. This filter returns exact matches only.

#### Input parameters

| **Parameter name**        | **Data type** | **Description**                                                                                                                                   |
| ------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `account.id`              | String/ID     | (Required) The specific account ID for which to retrieve destinations. This account must be accessible to the authenticated user.                 |
| `destinations.filters`    | Object        | (Required) Filter criteria object to specify the exact destination to retrieve.                                                                   |
| `destinations.filters.id` | String        | (Required) Filter by destination ID. Returns the destination with the exact matching ID, if it exists and is accessible to the specified account. |

#### Sample query:

````graphql
{
  actor {
    account(id: YOUR_ACCOUNT_ID) {
      aiNotifications {
        destinations(filters: { id: YOUR_DESTINATION_ID }) {
          entities {
            id
            name
            scope {
              id
              type
            }
          }
        }
      }
    }
  }
}
```

````

**Filter destinations by type**

Use type filtering to retrieve destinations of a specific type. This filter returns all destinations that match the specified destination type.

#### Input parameters

| **Parameter name**          | **Data type** | **Description**                                                                                                                                                                            |
| --------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `account.id`                | String/ID     | (Required) The specific account ID for which to retrieve destinations. This account must be accessible to the authenticated user.                                                          |
| `destinations.filters`      | Object        | (Required) Filter criteria object to narrow down results by destination type.                                                                                                              |
| `destinations.filters.type` | Enum          | (Required) Filter by destination type. Valid values: `EMAIL`, `WEBHOOK`, `PAGERDUTY_SERVICE_INTEGRATION`, `PAGERDUTY_ACCOUNT_INTEGRATION`, `SLACK`, `JIRA`, `SERVICE_NOW`, `EVENT_BRIDGE`. |

#### Sample query:

The following query will return all email destinations on the chosen account:

````graphql
{
  actor {
    account(id: YOUR_ACCOUNT_ID) {
      aiNotifications {
        destinations(filters: { type: EMAIL }) {
          entities {
            id
            name
            scope {
              id
              type
            }
          }
        }
      }
    }
  }
}
```

````

## Update a cross account destination [#update-destination]

To update an existing cross-account destination, you must provide the organization scope and the destination ID.

**Update a cross account destination**

Use `aiNotificationsUpdateDestination` mutation to update an existing cross-account destination.

#### Input parameters

| **Parameter name**       | **Data type**    | **Description**                                                                                                                                                       |
| ------------------------ | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `scope`                  | Object           | (Required) Defines the scope where the destination exists. Use `type: ORGANIZATION` for cross account destinations or `type: ACCOUNT` for account-level destinations. |
| `scope.id`               | String           | (Required) The organization ID for cross account destinations or account ID for account-level destinations.                                                           |
| `scope.type`             | Enum             | (Required) Must be `ORGANIZATION` for cross account destinations or `ACCOUNT` for account-level destinations.                                                         |
| `destinationId`          | String           | (Required) The unique identifier of the destination you want to update. This ID is returned when creating a destination or can be found by listing destinations.      |
| `destination`            | Object           | (Required) The destination update object containing the fields you want to modify. Only include the fields you want to change.                                        |
| `destination.name`       | String           | (Optional) Updated name for the destination.                                                                                                                          |
| `destination.auth`       | Object           | (Optional) Updated authentication configuration for destinations that require credentials.                                                                            |
| `destination.properties` | Array of Objects | (Optional) Updated key-value pairs for destination-specific settings such as URLs, email addresses, or integration options.                                           |

#### Sample query:

````graphql
mutation {
  aiNotificationsUpdateDestination(
    scope: { id: YOUR_ACCOUNT_ID, type: ACCOUNT }
    destinationId: YOUR_DESTINATION_ID
    destination: { name: "Updated destination Name" }
  ) {
    destination {
      id
      name
      scope {
        id
        type
      }
    }
  }
}
```

````

## Delete a cross account destination [#delete-destination]

Delete cross account destinations by providing the `scope` and `destination ID`.

> #### ⚠️ IMPORTANT
>
> **Before deleting**: If you receive an error stating "Entity type channel is in use", you must first delete all channels associated with the destination. Find associated channels and delete them individually before proceeding with destination deletion.

**Delete a cross account destination**

Use `aiNotificationsDeleteDestination` mutation to permanently delete a cross account destination.

#### Input parameters

| **Parameter name** | **Data type** | **Description**                                                                                                                                                       |
| ------------------ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `scope`            | Object        | (Required) Defines the scope where the destination exists. Use `type: ORGANIZATION` for cross account destinations or `type: ACCOUNT` for account-level destinations. |
| `scope.id`         | String        | (Required) The organization ID for cross account destinations or account ID for account-level destinations.                                                           |
| `scope.type`       | Enum          | (Required) Must be `ORGANIZATION` for cross account destinations or `ACCOUNT` for account-level destinations.                                                         |
| `destinationId`    | String        | (Required) The unique identifier of the destination you want to delete. This ID is returned when creating a destination or can be found by listing destinations.      |

#### Sample query:

````graphql
mutation {
  aiNotificationsDeleteDestination(
    scope: { id: YOUR_ACCOUNT_ID, type: ACCOUNT }
    destinationId: YOUR_DESTINATION_ID
  ) {
    ids
    error {
      details
    }
  }
}
```

````

**Find channels using a destination**

Use this query to find all channels that are currently using a specific destination. This is useful before deleting a destination to ensure no active channels will be affected.

#### Input parameters

| **Parameter name**               | **Data type** | **Description**                                                                                                                      |
| -------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `account.id`                     | String/ID     | (Required) The specific account ID to search for channels. This account must be accessible to the authenticated user.                |
| `channels.filters`               | Object        | (Required) Filter criteria object to find channels using a specific destination.                                                     |
| `channels.filters.destinationId` | String        | (Required) The unique identifier of the destination to search for. Returns all channels that are configured to use this destination. |

#### Sample query:

````graphql
{
  actor {
    account(id: YOUR_ACCOUNT_ID) {
      aiNotifications {
        channels(filters: { destinationId: YOUR_DESTINATION_ID }) {
          entities {
            id
            name
          }
        }
      }
    }
  }
}
```

````

**Delete associated channels**

Use `aiNotificationsDeleteChannel` mutation to delete channels that are using a destination. You must delete all associated channels before you can delete the destination itself.

#### Input parameters

| **Parameter name** | **Data type** | **Description**                                                                                                                         |
| ------------------ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `accountId`        | String/ID     | (Required) The account ID where the channel exists. This account must be accessible to the authenticated user.                          |
| `channelId`        | String        | (Required) The unique identifier of the channel you want to delete. This ID can be found by querying channels using the destination ID. |

#### Sample query:

````graphql
mutation {
  aiNotificationsDeleteChannel(
    accountId: YOUR_ACCOUNT_ID
    channelId: "YOUR_CHANNEL_ID"
  ) {
    ids
    error {
      details
    }
  }
}
```

````

## Next steps

[Cross account destinations overview](https://docs.newrelic.com/docs/apis/nerdgraph/examples/cross-account-destinations/overview)

Learn about cross account destinations concepts and key features.

[Use cross account destinations in the UI](https://docs.newrelic.com/docs/apis/nerdgraph/examples/cross-account-destinations/use-cross-account-destinations-in-the-ui)

Learn where cross account destinations appear in the UI and how to use them in workflows.
