> ## Documentation Index
> Fetch the complete documentation index at: https://docs-xcor.paloaltonetworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an Opsgenie notifier

> Create an Opsgenie notifier with Palo Alto Networks Cortex XCOR, Chronoctl, or Terraform.

To create an Opsgenie notifier, set up Opsgenie and then create the notifier in
Palo Alto Networks Cortex XCOR.

Before you begin, make sure you have your Opsgenie API key and API URL.

## Set up Opsgenie

Before creating an Opsgenie notifier in Cortex XCOR, generate an API key.
Refer to the [Opsgenie documentation](https://docs.opsgenie.com/docs/api-integration)
for instructions.

Next, [create an Opsgenie notifier](#create-an-opsgenie-notifier-in-cortex-xcor)
in Cortex XCOR.

## Create an Opsgenie notifier in Cortex XCOR

After [setting up Opsgenie](#set-up-opsgenie), you can create an Opsgenie notifier in
Cortex XCOR.

Select from the following methods to create an Opsgenie notifier. You can use
[variables](/investigate/alerts/notifications/notifiers#use-variables-in-notifiers) in your
notifiers.

<Tabs>
  <Tab title="Web" id="opsgenie-notifier-web">
    To create an Opsgenie notifier:

    1. In the navigation menu select
       **<Icon icon="bell" /> Alerting <span aria-label="and then">></span> Notifiers**.

    2. Click **Create notifier**.

    3. Enter a descriptive name for the notifier.

    4. Select **Opsgenie** as the type of notifier you want to create.

    5. In the **API Key** field, enter the value of your Opsgenie API key.

    6. In the **API URL** field, enter the following URL, which is called as a `POST`
       request:

       ```text theme={null}
       https://api.opsgenie.com/
       ```

    7. Optional: Select **Notify when resolved** to send a resolved alert notification.

    8. Click **Save**.
  </Tab>

  <Tab title="Chronoctl" id="opsgenie-notifier-chronoctl">
    To create one or more notifiers using [Chronoctl](/tooling/chronoctl), create a YAML file
    that defines them and apply the configuration to your instance.

    <Note>
      You can use the `notifiers scaffold` command to generate an example notifier, and
      then copy the resource definition for your notifier type:

      ```shell theme={null}
      chronoctl notifiers scaffold
      ```
    </Note>

    1. Define the resource definition for your Opsgenie notifier:

       ```yaml Chronoctl example icon="square-terminal" /NAME/ /SLUG/ /API_KEY/ /API_URL/ theme={null}
       api_version: v1/config
       kind: Notifier
       spec:
         name: NAME
         slug: SLUG
         skip_resolved: true
         ops_genie:
           api_key: 'API_KEY'
           api_url: API_URL
       ```

       Replace the following:

       * *`NAME`*: A descriptive name, such as `test-opsgenie`.
       * *`SLUG`*: A unique identifier, such as `test-opsgenie`.
       * *`API_KEY`*: Your OpsGenie API key.
       * *`API_URL`*: Your OpsGenie API URL.

    2. Enter your Opsgenie API key in the `api_key` field.

    3. Enter the following URL in the `api_url` field:

       ```text theme={null}
       https://api.opsgenie.com/
       ```

    4. Apply the changes:

       ```shell /FILE_NAME/ theme={null}
       chronoctl apply -f FILE_NAME.yaml
       ```

       Replace *`FILE_NAME`* with the name of your notifier YAML file.
  </Tab>

  <Tab title="Terraform" id="opsgenie-terraform">
    To create an Opsgenie notifier:

    1. Create an Opsgenie notifier with [Terraform](/tooling/infrastructure/terraform) by using the
       `chronosphere_opsgenie_alert_notifier` type followed by a name in a resource
       declaration:

       ```terraform expandable Terraform example icon="square-terminal" theme={null}
       resource "chronosphere_opsgenie_alert_notifier" "opsgenie_notifier" {
         name = "Opsgenie Notifier"

         # Optional slug of the Opsgenie notifier.
         slug = "opsgenie-notifier"

         ## Notifier-specific required configuration
         # Detailed definitions can be found at: https://prometheus.io/docs/alerting/latest/configuration/#opsgenie_config
         api_key = "your-api-key"

         ## Notifier-specific optional configurations
         api_url     = "your-api-url"
         message     = "custom message"
         description = "description"
         source      = "source"
         tags        = ["tag-1", "tag-2"]
         note        = "note"
         priority    = "P1"

         details = {
           "first_detail" = "interesting detail"
         }

         # Can have multiple responders.
         responder {
          # Set one of the [id, name, username] fields
           name = "Productivity Platform - Compute"
           type = "TEAM" # Or: USER, ESCALATION, SCHEDULE
         }

         ## (Optional) Base configuration common to all notifiers
         send_resolved = true # The default value

         ## (Optional) HTTP configuration common to HTTP notifiers
         basic_auth_username = "username"
         basic_auth_password = "strong+p@ssword"
         # Can use bearer_token instead of basic auth
         tls_insecure_skip_verify = false
       }
       ```

    2. Enter your Opsgenie API key in the `api_key` field.

    3. Enter the following URL in the `api_url` field:

       ```text theme={null}
       https://api.opsgenie.com/
       ```

    4. Run `terraform apply` to create the notifier resource:

       ```shell theme={null}
       terraform apply
       ```
  </Tab>

  <Tab title="API" id="opsgenie-API">
    To complete this action with the Cortex XCOR API, use the `ops_genie` object in the
    [`CreateNotifier`](/tooling/api-info/definition/operations/CreateNotifier) endpoint.

    Because the Cortex XCOR API requires authentication, include an API token with your
    `curl` request, as shown in the following example. For more details, see
    [Create an API token](/tooling/api-info#create-an-api-token).

    ```shell /"TOKEN"/ /INSTANCE/ /METHOD/ /ENDPOINT_PATH/ theme={null}
    export CHRONOSPHERE_API_TOKEN="TOKEN"
    export CHRONOSPHERE_DOMAIN="INSTANCE.chronosphere.io"

    curl -H "API-Token: ${CHRONOSPHERE_API_TOKEN}" \
         -X METHOD "https://${CHRONOSPHERE_DOMAIN}/ENDPOINT_PATH"
    ```

    Replace the following:

    * *`TOKEN`*: Your API token.
    * *`INSTANCE`*: The subdomain name for your organization's Cortex XCOR instance.
    * *`METHOD`*: The HTTP method to use with the request, such as `GET` or `POST`.
    * *`ENDPOINT_PATH`*: The specific endpoint you want to access.
  </Tab>
</Tabs>


## Related topics

- [Notifier connections](/investigate/alerts/notifications/external-connections.md)
- [CreateNotifier](/tooling/api-info/definition/operations/CreateNotifier.md)
- [Create a discard notifier](/investigate/alerts/notifications/notifiers/discard.md)
- [Create a Slack notifier](/investigate/alerts/notifications/notifiers/slack.md)
- [Create an email notifier](/investigate/alerts/notifications/notifiers/email.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.