# Update a Slack integration

Updates the settings of a Slack integration, the same settings as its **Configure** page. Send only the parameters you wish to change.

Connect the integration in **Errors** → [Integrations](https://errors.betterstack.com/team/0/integrations/) first, since connecting Slack needs you to authorize Better Stack in Slack.

[endpoint]
base_url = "https://errors.betterstack.com"
path = "/api/v1/slack-integrations/{id}"
method = "PATCH"

[[path_param]]
name = "id"
description = "The ID of the Slack integration, the number in the URL of its **Configure** page."
required = true
type = "string"

[[body_param]]
name = "applications"
description = "The applications whose errors the integration handles, replacing the whole list. Each is an object with the `application_id` of an error tracking application in the integration's team and optionally its `environments`, a list of environment names where empty or left out means every environment. Send `[]` for any application."
required = false
type = "array of objects"

[[body_param]]
name = "notifications"
description = "The **Notify me when** toggles to change, as booleans. Toggles you leave out keep their value. The keys are `spikes`, `spike_protection`, `new_releases`, `new_errors`, `occurrence_milestones`, `occurrence_threshold`, `affected_users_threshold`, `automatically_reopened`."
required = false
type = "object"

[[body_param]]
name = "occurrence_threshold_count"
description = "How many occurrences within `occurrence_threshold_interval` trigger `notifications.occurrence_threshold`. A positive whole number."
required = false
type = "integer"

[[body_param]]
name = "occurrence_threshold_interval"
description = "The interval of the occurrence threshold: `minute`, `hour`, `day`, or `week`."
required = false
type = "string"

[[body_param]]
name = "affected_users_threshold_count"
description = "How many affected users in total trigger `notifications.affected_users_threshold`. A positive whole number."
required = false
type = "integer"

[[body_param]]
name = "tag_filter"
description = "Only send messages for errors where at least one exception has every tag listed, with one of its values, replacing the whole list. Each row is an object with a `tag` and its `values`, a list of strings. Use a tag once, at most 10 rows, 50 values per tag and 200 characters per tag or value. Send `[]` for every error. New releases and spike protection aren't filtered."
required = false
type = "array of objects"

[[body_param]]
name = "post_updates"
description = "`single_channel` posts every update to the channel, `thread_based` posts new errors to the channel and their updates in a thread."
required = false
type = "string"

[[body_param]]
name = "broadcast_updates"
description = "Also send important updates in a thread to the channel: resolved and re-opened errors, spikes and occurrence milestones. Applies when `post_updates` is `thread_based`."
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"

[[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": "188",
    "type": "slack_integration",
    "attributes": {
      "team_id": "t123456",
      "team_name": "My team",
      "applications": [
        { "application_id": 1234, "environments": ["production"] }
      ],
      "notifications": {
        "spikes": true,
        "spike_protection": true,
        "new_releases": true,
        "new_errors": true,
        "occurrence_milestones": true,
        "occurrence_threshold": false,
        "affected_users_threshold": true,
        "automatically_reopened": false
      },
      "occurrence_threshold_count": 10,
      "occurrence_threshold_interval": "minute",
      "affected_users_threshold_count": 50,
      "tag_filter": [
        { "tag": "level", "values": ["error", "fatal"] }
      ],
      "slack_team_name": "My Slack workspace",
      "slack_channel_name": "#errors",
      "post_updates": "thread_based",
      "broadcast_updates": true,
      "ai_sre_on_mention": true
    }
  }
}'''

[[response]]
status = 401
description = '''Unauthorized'''
body = '''{
  "errors": "Invalid Team API token. How to find your Team API token: https://betterstack.com/docs/logs/api/getting-started/#obtaining-a-logtail-api-token"
}'''

[[response]]
status = 404
description = '''Not Found'''
body = '''{
  "errors": "Resource with the provided ID was not found"
}'''

[[response]]
status = 422
description = '''Returned when a value can't be applied. The error says which and why.'''
body = '''{
  "errors": "The \"level\" tag is used in more than one row."
}'''
[/responses]

#### Example cURL

[code-tabs]
```shell
[label Notify about production errors only]
curl --request PATCH \
  --url https://errors.betterstack.com/api/v1/slack-integrations/188 \
  --header "Authorization: Bearer $TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
    "applications": [
      { "application_id": 1234, "environments": ["production"] }
    ]
  }'
```
```shell
[label Post updates in threads]
curl --request PATCH \
  --url https://errors.betterstack.com/api/v1/slack-integrations/188 \
  --header "Authorization: Bearer $TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
    "post_updates": "thread_based",
    "broadcast_updates": false
  }'
```
[/code-tabs]
