# Webhooks (Datadog)

## Overview

In this tutorial, we’ll set up Datadog to send notifications to a Group Chat.
Although this tutorial is specific to Datadog, the general approach should apply widely.

Setup requires the following steps:

1. Create an API Key with the scopes below.
2. Find the ID of the Group you want to notify.
3. Set up the Webhook in Datadog to authenticate with the key and post to the group.
4. Set up a Monitor with the notification conditions and message format.

## Create an API key

Create an API key in _Roam Administration_ → _Developer_. Grant at least:

- `group:read` — list groups
- `chat:send_message` (or `chat:write`) — post messages

See the [Quick Start](/docs/intro) for more detail.

## Find the Group ID

Use the [`group.list`](/docs/api/group-list) endpoint to browse public groups and
find the ID of the group you wish to notify. Using your API key, run:

```bash
$ curl -H "Authorization: Bearer $API_KEY" https://api.ro.am/v1/group.list
```

Look for the desired group in the output and copy its `id` (a plain UUID).

## Set up a Webhook in Datadog

1.  Navigate to _Integrations_ in the web console and select Webhooks to install
    and configure it.

2.  Create a _New Variable_ for your API Key named `API_KEY`.

3.  Name your Webhook and set the URL to
    [`https://api.ro.am/v1/chat.post`](/docs/api/chat-post).

4.  Set the Payload to the following, using the Group ID from the last step:

```
        {
            "groupId": "4ff757dd-4954-42d4-b13d-f0dac34d6f7d",
            "text": "$EVENT_MSG"
        }
```

`$EVENT_MSG` is Datadog’s template variable for the monitor message. Message
`text` is [GitHub-flavored markdown](https://github.github.com/gfm/).

5.  Set _Custom Headers_ to the following:

```
        { "Authorization": "Bearer $API_KEY" }
```

6.  Save the Webhook.

## Set up a Monitor in Datadog

1. Navigate to Monitors > New Monitor and select a type corresponding to the
   event for which you want to notify.

2. Configure the notification conditions and compose a notification message.

3. In “Notify your services and your team members”, select `webhook-NAME` to
   deliver notifications using the webhook.

4. Save your monitor and click “Test Notifications” to open a dialog allowing
   you to send webhooks on demand. This is the best way to confirm that
   everything works and iterate on the notification content.