# Update Slack integration

Update an existing Slack integration. Every setting on the integration's **Configure** page can be changed here. Send only the parameters you wish to change, e.g. `integration_type`. Lists like `alert_options` replace the whole list.

Connecting Slack needs a sign-in to your Slack workspace, so [connect the integration](https://incidents.betterstack.com/team/0/integrations) in the Better Stack dashboard first.

[endpoint]
base_url = "https://incidents.betterstack.com"
path = "/api/v2/slack-integrations/{slack_integration_id}"
method = "PATCH"

[[path_param]]
name = "slack_integration_id"
description = "The ID of the Slack integration you want to update."
required = true
type = "string"

[[body_param]]
name = "integration_type"
description = "How incidents are posted. `verbose` posts every incident to the single connected channel, `thread` starts a thread per incident in it, and `channel` creates a new channel per incident. `thread` and `channel` need a paid plan."
required = false
type = "string"

[[body_param]]
name = "channel_invitees"
description = "Who to always invite into the incident channel when `integration_type` is `channel`. An array of objects with a `type` and an `id`. `type` is `user`, `on_call_calendar`, or `slack_user_group`."
required = false
type = "array"

[[body_param]]
name = "private_channel"
description = "Make the incident channels private. Needs at least one entry in `channel_invitees`."
required = false
type = "boolean"

[[body_param]]
name = "channel_display_name"
description = "The name shown for the connected channel in Better Stack. Send `null` to show the channel's own name."
required = false
type = "string"

[[body_param]]
name = "alert_all_teams_and_policies"
description = "Let Slack users alert every team and escalation policy. Set it to `false` to allow only the ones in `alert_options`."
required = false
type = "boolean"

[[body_param]]
name = "alert_options"
description = "The teams and escalation policies Slack users can alert. A team is `{\"type\": \"team\", \"id\": 7}` with the booleans `call`, `sms`, `email`, `push` and `critical_alert`, each `false` when left out. An escalation policy is `{\"type\": \"policy\", \"id\": 73}`. The read-only keys a GET returns, `name`, `team_id` and `team_name`, are ignored, so you can send the `alert_options` from a GET back unchanged."
required = false
type = "array"

[[body_param]]
name = "invite_new_slack_users"
description = "Invite new Slack users into your Better Stack team as responders."
required = false
type = "boolean"

[[body_param]]
name = "on_call_notifications"
description = "Notify the channel when the primary responder changes."
required = false
type = "boolean"

[[body_param]]
name = "notify_on_pause"
description = "Notify when a resource is paused."
required = false
type = "boolean"

[[body_param]]
name = "notify_on_resolve"
description = "Notify when an incident is resolved."
required = false
type = "boolean"

[[body_param]]
name = "direct_message_on_mention"
description = "Send a direct message to people tagged in incident comments."
required = false
type = "boolean"

[[body_param]]
name = "ai_sre_on_mention"
description = "Start an AI SRE conversation when Better Stack is tagged."
required = false
type = "boolean"

[[body_param]]
name = "restrict_incident_creation_to_channel"
description = "Allow creating incidents only by the members of the connected channel."
required = false
type = "boolean"

[[body_param]]
name = "post_timeline_events"
description = "Post incident timeline events about e-mails, phone calls, and integrations. Applies when `integration_type` is `thread` or `channel`."
required = false
type = "boolean"

[[body_param]]
name = "post_incident_metadata"
description = "Post incident metadata."
required = false
type = "boolean"

[[body_param]]
name = "post_status_page_updates"
description = "Post status page updates. Turning it off clears `status_page_update_resources`."
required = false
type = "boolean"

[[body_param]]
name = "status_page_update_resources"
description = "Post status page updates only for these affected resources, given as objects with a `type` and an `id`, or leave it empty to post updates for every resource of the integration's team. Needs `post_status_page_updates` turned on, and `type` is one of `status_page`, `monitor`, `heartbeat`, `monitor_group`, `heartbeat_group`, `webhook_integration`, `email_integration`, `incoming_webhook`, `amazon_sns_integration`, `manually_tracked_item`, `logs_chart`, or `catalog_reference`."
required = false
type = "array"

[[body_param]]
name = "notify_alongside_primary_responder"
description = "Notify this integration alongside the primary responder when no escalation policy is configured."
required = false
type = "boolean"

[[header]]
name = "Authorization"
description = "Bearer `$TOKEN`"
required = true
type = "string"

[[header]]
name = "Content-Type"
description = "application/json"
required = true
type = "string"

[/endpoint]

[responses]

[[response]]
status = 200
description = '''Returns the updated Slack integration'''
body = '''{
  "data": {
    "id": "37",
    "type": "slack_integration",
    "attributes": {
      "slack_team_id": "T04UQ7K4QMB",
      "slack_team_name": "My Slack workspace",
      "slack_channel_id": "C07Q2KF20EU",
      "slack_channel_name": "#better-stack-incidents",
      "slack_status": "active",
      "integration_type": "channel",
      "on_call_notifications": false,
      "notify_alongside_primary_responder": false,
      "channel_display_name": "incidents",
      "channel_invitees": [
        { "type": "user", "id": 2 },
        { "type": "on_call_calendar", "id": 1 }
      ],
      "status_page_update_resources": [
        { "type": "status_page", "id": 1 }
      ],
      "private_channel": true,
      "alert_all_teams_and_policies": false,
      "invite_new_slack_users": true,
      "notify_on_pause": false,
      "notify_on_resolve": true,
      "direct_message_on_mention": false,
      "ai_sre_on_mention": false,
      "restrict_incident_creation_to_channel": true,
      "post_timeline_events": true,
      "post_incident_metadata": false,
      "post_status_page_updates": true,
      "team_name": "My team",
      "alert_options": [
        {
          "type": "team",
          "id": 7,
          "name": "My team",
          "call": false,
          "sms": false,
          "email": true,
          "push": true,
          "critical_alert": true
        },
        {
          "type": "policy",
          "id": 73,
          "name": "High severity policy",
          "team_id": 7,
          "team_name": "My team"
        }
      ]
    }
  }
}'''

[[response]]
status = 422
description = '''Returned when a value can't be applied, e.g. a team outside your organization. The error names the parameter.'''
body = '''{
  "errors": {
    "alert_options": ["Team 8 was not found."]
  }
}'''

[[response]]
status = 422
description = '''Returned when the change needs a feature your plan doesn't include, e.g. `thread` or `channel` mode.'''
body = '''{
  "errors": "Thread-based and channel-based Slack integrations need a paid plan.",
  "unauthorized_attributes": ["integration_type"]
}'''

[/responses]

#### Example cURL
[code-tabs]
```shell
[label Create a channel per incident]
curl -X "PATCH" "https://incidents.betterstack.com/api/v2/slack-integrations/37" \
     -H "Authorization: Bearer $TOKEN" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "integration_type": "channel",
  "private_channel": true,
  "channel_invitees": [{ "type": "on_call_calendar", "id": 1 }]
}'
```
```shell
[label Allow only e-mail and push alerts]
curl -X "PATCH" "https://incidents.betterstack.com/api/v2/slack-integrations/37" \
     -H "Authorization: Bearer $TOKEN" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "alert_all_teams_and_policies": false,
  "alert_options": [
    { "type": "team", "id": 7, "email": true, "push": true },
    { "type": "policy", "id": 73 }
  ]
}'
```
[/code-tabs]
