> ## 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 a Slack notifier

> Create a Slack notifier with Palo Alto Networks Cortex XCOR, Chronoctl, or Terraform.

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

Before you begin, make sure you have the incoming webhook API URL from Slack.

## Set up Slack

Before creating a Slack notifier in Cortex XCOR, create an incoming webhook
in Slack. See [Sending messages using incoming webhooks](https://api.slack.com/messaging/webhooks)
in the Slack documentation for more information.

Next, [create a Slack notifier](#create-a-slack-notifier-in-cortex-xcor) in
Cortex XCOR.

## Create a Slack notifier in Cortex XCOR

After [setting up Slack](#set-up-slack), you can create a Slack notifier in
Cortex XCOR.

Select from the following methods to create a Slack notifier. You can use
[variables](https://docs-xcor.paloaltonetworks.com/investigate/alerts/notifications/notifiers#use-variables-in-notifiers) in your
notifiers.

> [tab] Web
>
> To create a Slack notifier:
>
> 1. In the navigation menu select
>    \*\* Alerting > Notifiers\*\*.
> 2. Click **Create notifier**.
> 3. Enter a descriptive name for the notifier.
> 4. Select **Slack** as the type of notifier you want to create.
> 5. In the **API URL** field, enter the URL you created for your webhook in Slack,
>    which is called as a `POST` request. For example:
>
>    ```text theme={null}
>    https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXX
>    ```
>
>    The [API URL](https://api.slack.com/messaging/webhooks#create_a_webhook) from
>    Slack contains the channel name.
> 6. In the **Channel** field, enter any channel name. This field is required for
>    backward compatibility, but its value is ignored. The destination channel is
>    set by the webhook you entered in the **API URL** field.
> 7. Optional: In the **Username** field, enter the Slack username to post the notifier
>    as.
> 8. Optional: Select **Notify when resolved** to send a resolved alert notification.
> 9. Click **Save**.

> [tab] Chronoctl
>
> To create one or more notifiers using [Chronoctl](https://docs-xcor.paloaltonetworks.com/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
> > ```
>
> 1. Define the resource definition for your Slack notifier:
>
>    ```yaml Chronoctl example icon="square-terminal" /NAME/ /SLUG/ /CHANNEL/ /USERNAME/ theme={null}
>    api_version: v1/config
>    kind: Notifier
>    spec:
>      name: NAME
>      slug: SLUG
>      skip_resolved: true
>      slack:
>        actions: null
>        api_url: https://hooks.slack.com/services/
>        channel: CHANNEL
>        fields: null
>        mrkdwn_in: null
>        username: USERNAME
>    ```
>
>    Replace the following:
>
>    * *`NAME`*: A descriptive name, such as `test-slack`.
>    * *`SLUG`*: A unique identifier, such as `team-slack`.
>    * *`CHANNEL`*: Required for backward compatibility, but ignored. The destination
>      channel comes from the `api_url` webhook.
>    * *`USERNAME`*: Send the notification message from a specified Slack username.
>
> 2. Enter the URL you created for your webhook in Slack as the value for the `api_url`
>    field. The API URL contains the channel to send the message to.
>
> 3. Optional: Enter the Slack username to post the notifier as in the `username`
>    field.
>
> 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] Terraform
>
> To create a Slack notifier:
>
> 1. Create a Slack notifier with [Terraform](https://docs-xcor.paloaltonetworks.com/tooling/infrastructure/terraform) by using the
>    `chronosphere_slack_alert_notifier` type followed by a name in a resource
>    declaration:
>
>    ```terraform expandable Terraform example icon="square-terminal" theme={null}
>    resource "chronosphere_slack_alert_notifier" "slack_notifier" {
>      name = "Slack Notifier"
>
>      # Optional slug of the slack notifier.
>      slug = "slack-notifier"
>
>      ## Notifier-specific required configuration.
>      # For detailed definitions, see
>      # https://prometheus.io/docs/alerting/latest/configuration/#slack_config
>      # `api_url` is a sensitive value. Treat it like a secret.
>     api_url       = "https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX"
>     # Required for backward compatibility, but ignored. The destination channel
>     # comes from api_url.
>     channel       = "alerts"
>
>      ## Notifier-specific optional configurations
>      username      = "alertbot"
>      callback_id   = "example_callback_id"
>      color         = "red"
>      fallback      = "example_fallback"
>      footer        = "example_footer"
>      icon_emoji    = ""
>      image_url     = "https://example.com/images/img.png"
>      link_names    = false
>      mrkdwn_in     = []
>      pretext       = "example_pretext"
>      short_fields  = false
>      text          = "example_text"
>      title         = "example_title"
>      title_link    = "example_title_link"
>
>      # Can have multiple fields.
>      fields {
>        title = "example_title"
>        value = "example_value"
>        short = true
>      }
>
>      # Optional list of actions
>      action {
>        name                        = "example_action"
>        style                       = "example_style"
>        text                        = "example_text"
>        type                        = "example_type"
>        url                         = "https://example.com"
>        value                       = "example_value"
>        action_confirm_text         = "confirmation text"
>        action_confirm_tile         = "confirmation title"
>        action_confirm_ok_text      = "confirmation ok text"
>        action_confirm_dismiss_text = "dismissal text"
>      }
>
>      ## (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 the URL you created for your webhook in Slack as the
>    value for the `api_url` field. The API URL sets the channel to send the message to.
>    The `channel` field is required for backward compatibility, but its value is ignored.
>
> 3. Optional: Enter the Slack username to post the notifier as in the `username`
>    field.
>
> 4. Run `terraform apply` to create the notifier resource.
>
>    ```shell theme={null}
>    terraform apply
>    ```

> [tab] API
>
> To complete this action with the Cortex XCOR API, use the `slack` object in the
> [`CreateNotifier`](https://docs-xcor.paloaltonetworks.com/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](https://docs-xcor.paloaltonetworks.com/tooling/api-info.md#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.


## Related topics

- [Notifiers](https://docs-xcor.paloaltonetworks.com/investigate/alerts/notifications/notifiers.md)
- [Integrate with Cortex XCOR](https://docs-xcor.paloaltonetworks.com/integrate.md)
- [Slack unfurling integration](https://docs-xcor.paloaltonetworks.com/investigate/alerts/notifications/slack.md)
- [Monitor data model](https://docs-xcor.paloaltonetworks.com/investigate/alerts/monitors/data-model.md)
- [CreateNotifier](https://docs-xcor.paloaltonetworks.com/tooling/api-info/definition/operations/CreateNotifier.md)


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