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

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.kosli.com/feedback

```json
{
  "path": "/integrations/actions",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Actions

> Automate if-this-then-that workflows with Kosli Actions.

<Note>
  You need the Admin or Member role to create, update, and delete Actions.

  Learn more about roles in Kosli in [Roles in Kosli](/administration/managing_users/roles_in_kosli/).
</Note>

Actions enable you to automate the execution of if-this-do-that workflows based on Kosli events. You can configure actions to either receive a Slack notification or a JSON payload on a custom webhook when certain Kosli events happen.

You can configure actions to be triggered by one or more of the following events occurring in one or more environments:

* When a new artifact starts execution in an environment.
* When an artifact ceases execution in an environment.
* When instances of an artifact are scaled up or down.
* When an artifact is added to the allow-list in an environment.
* When an environment changes state from <Badge color="green">Compliant</Badge> to <Badge color="red">Non-Compliant</Badge>.
* When an environment changes state from <Badge color="red">Non-Compliant</Badge> to <Badge color="green">Compliant</Badge>.

## Slack Notifications

To receive Kosli notifications in Slack, you have two options. You can either use the Kosli Slack App or set up Slack Incoming Webhooks. Both approaches allow you to configure Kosli notifications in Slack, offering flexibility based on your preferences.

<Card title="Kosli Slack App (recommended)" icon="slack">
  Subscribe to Kosli notifications using the [Kosli Slack App](/integrations/slack/). This method is recommended for a seamless integration.
  Use the app to create notification settings by running the `/kosli subscribe` slash command.
</Card>

<Card title="Slack Incoming Webhooks" icon="webhook">
  * Create a [Slack incoming webhook](https://api.slack.com/messaging/webhooks#create_a_webhook).
  * Use this webhook to [create a notification settings in the Kosli UI](/integrations/actions/#manage-actions-in-the-ui).
</Card>

## Custom Webhook Notifications

Custom webhook notifications empower you to implement automation workflows for "if-this-then-that" scenarios. Whenever an event that matches your specified notification settings occurs, a JSON payload, as outlined below, is transmitted to your designated custom webhook:

```json theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
{
    "version": "1.0",
    "timestamp": "1692616493",
    "org": "cyber-dojo",
    "environment": "aws-prod",
    "event_type": "ARTIFACT_STARTED",
    "description": "1 instance started running (from 0 to 1)",
    "snapshot":  {
           "index": "1035",
           "status": "compliant",
           "html_url": "https://app.kosli.com/cyber-dojo/environments/aws-prod/snapshots/1035",
           "api_url": "https://app.kosli.com/api/v2/snapshots/cyber-dojo/aws-prod/1035"
     },
    "artifact": {
        "name": "runner",
        "fingerprint": "719defb995c86ad7c406ad74258fe98b9ebd71dfa80cd786870c967cb6c1f08d",
        "provenance": {
            "flow": "runner",
            "status": "compliant",
            "commit": "1ac157003dd6fb9ec764daa47726b7bfed65c312",
            "commit_url": "https://github.com/cyber-dojo/runner/commit/1ac157003dd6fb9ec764daa47726b7bfed65c312",
            "html_url": "https://app.kosli.com/cyber-dojo/runner/719defb995c86ad7c406ad74258fe98b9ebd71dfa80cd786870c967cb6c1f08d",
            "api_url": "https://app.kosli.com/api/v2/artifacts/cyber-dojo/runner/fingerprint/719defb995c86ad7c406ad74258fe98b9ebd71dfa80cd786870c967cb6c1f08d",
            "build_url": "https://github.com/cyber-dojo/runner/actions/runs/5891969166",
            "deployments": [
                {
                   "number": "44",
                   "timestamp": "1692618644",
                   "build_url": "https://github.com/cyber-dojo/runner/actions/runs/5891969166",
                   "html_url": "https://app.kosli.com/cyber-dojo/flows/runner/deployments/44",
                   "api_url": "https://app.kosli.com/api/v2/deployments/cyber-dojo/runner/44"
               }
            ],
            "approvals": [
                {
                   "number": "42",
                   "timestamp": "1692617329",
                   "state": "approved",
                   "latest_reviewer": "username",
                   "latest_review_comment": "lgtm",
                    "html_url": "https://app.kosli.com/cyber-dojo/flows/runner/approvals/42",
                    "api_url": "https://app.kosli.com/api/v2/approvals/cyber-dojo/runner/42"
               }
            ]
        }
    }
}
```

## Email

Provide a comma-separated list of recipient email addresses. Notifications are sent from `noreply@kosli.com`.

# Manage Actions in the UI

You can manage Actions for your organization in the Kosli UI from the `Actions` section in the left navigation menu. The Actions sections enables you to:

* **Create Notifications:** Create a new notifications settings.
* **Delete Notifications:** Remove existing notification settings that are no longer needed.
* **Update Notifications:** Modify notification settings as needed.
