Slack Cleaner2 is an improved slack cleaner version using a python first approach

slack_cleaner2, slack, slack-cleaner, pypi, python, python3, slack-api, slack-free-plan, slackapi
pip install slack-cleaner2==3.0.5



License: MIT Github Actions PyPi Read the Docs

Bulk delete messages and files on Slack.


Install from PyPi:

pip install slack-cleaner2

latest version

pip install -e git+


In contrast to the original version ( this version is a focusing on pure python package that allows for easy scripting instead of a vast amount of different command line arguments.

basic usage

from slack_cleaner2 import *

s = SlackCleaner('SECRET TOKEN')
# list of users
# list of all kind of channels

# delete all messages in -bots channels
for msg in s.msgs(filter(match('.*-bots'), s.conversations)):
  # delete messages, its files, and all its replies (thread)
  msg.delete(replies=True, files=True)

# delete all general messages and also iterate over all replies
for msg in s.c.general.msgs(with_replies=True):


The slack cleaner needs you to give Slack's API permission to let it run the operations it needs. You grant these by registering it as an app in the workspace you want to use it in.

You can grant these permissions to the app by:

  1. going to Your Apps
  2. select 'Create New App', fill out an App Name (eg 'Slack Cleaner') and select the Slack workspace you want to use it in
  3. select 'OAuth & Permissions' in the sidebar
  4. scroll down to User Token Scope and select all scopes you need according to list below
  5. select 'Save changes'
  6. select 'Install App to Workspace'
  7. review the permissions and press 'Authorize'
  8. copy the 'OAuth Access Token' shown, and use as the first argument to SlackCleaner

The token should start with xoxp and not like bot tokens with xoxb.

Beyond granting permissions, if you wish to use this library to delete messages or files posted by others, you will need to be an Owner or Admin of the workspace.

User Token Scopes by Use Case

General channel and user detection

  • users:read
  • channels:read
  • groups:read
  • im:read
  • mpim:read

Deleting messages from public channels

  • users:read
  • channels:read
  • channels:history
  • chat:write

Deleting messages from private channels

  • users:read
  • groups:read
  • groups:history
  • chat:write

Deleting messages from 1:1 IMs

Note: You can only delete your own messages, not the ones of others. This is due to a restriction in the Slack API and there is nothing one can do about it.

  • im:read
  • im:history
  • users:read
  • chat:write

Deleting messages from multi-person IMs

  • mpim:read
  • mpim:history
  • users:read
  • chat:write

Deleting files

  • files:read
  • users:read
  • files:write

All User Token scopes

user token scopes


To all the people who can only afford a free plan. ­čśó



bumpversion patch
git commit -am 'release vX.X.X'
git tag vX.X.X
invoke release
git push 
git push --tags

change version in slack_cleaner2/