# Events, Notifications, Webhooks

CloudTruth allows you to subscribe to events.&#x20;

Use the example code below to configure sending a notification to a Slack channel.&#x20;

POST to `/api/v1/webhooks/` with a payload

```
{
  "name": "MyNewWebhook",
  "event_types": [
    "parameter_created"
  ],
  "type": "slack",
  "configuration": {
    "token": "string",
    "channel": "string",
    "username": "string"
  },
  "organization": "string"
}
```

`organization` is the organization ID for the installing org. I don't know how to advise a user to get this info and we might want to remove it from the request and just infer it in the same way we usually do.

`event_types` can be a list containing any combination of these items:

```
    "parameter_created"
    "parameter_updated"
    "parameter_deleted"
    "project_created"
    "project_updated"
    "project_deleted"
    "environment_created"
    "environment_updated"
    "environment_deleted"
    "value_created"
    "value_updated"
    "value_deleted"
```

`type` can only be slack, until we implement a different event handler

`configuration` is a JSON field that requires three keys (these are service-specific, this example is only for Slack):

```
{
    "token": <should be generated from Slack admin>,
    "channel": <should be the channel name to deliver messages to>,
    "username": <text to use for the username for the message into Slack>,
}
```

To generate a Slack API token:

1. Go to <https://api.slack.com/apps>
2. Click "Create New App"
3. Select "From a manifest"
4. Paste in the provided manifest (below)
5. Click "Create"
6. Click "OAuth & Permissions" on the left nav
7. Click the "Install to " button
8. Copy the generated Bot User OAuth Token

Slack App Manifest:

```
{
    "display_information": {
        "name": "CloudTruth Webhook"
    },
    "features": {
        "bot_user": {
            "display_name": "CloudTruth Webhook",
            "always_online": false
        }
    },
    "oauth_config": {
        "scopes": {
            "bot": [
                "chat:write.public",
                "chat:write"
            ]
        }
    },
    "settings": {
        "org_deploy_enabled": false,
        "socket_mode_enabled": false,
        "token_rotation_enabled": false
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudtruth.com/configuration-management/events-notifications-webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
