A tool to remove your own slack messages.
deslackify can only delete messages that you sent. The token you provide
authenticates as your own account, so it cannot remove messages authored by
other users.
deslackify supports Python 3.10 through 3.14.
Install the deslackify command with uv:
uv tool install deslackifydeslackify is meant to be run without the overhead of creating a Slack app. It
authenticates as your own browser session, using two values copied from your
logged-in Slack web client (https://app.slack.com):
- Open your workspace in a browser and open the developer tools.
- Token — in the Console, run:
It begins with
(d=>d.teams[Object.keys(d.teams)[0]].token)(JSON.parse(localStorage.localConfig_v2))
xoxc-. This is theTOKENbelow. - Cookie — in Application → Cookies →
https://app.slack.com, copy the value of thedcookie. It begins withxoxd-. This is theCOOKIEbelow. (deslackifyre-encodes it as needed, so it does not matter whether the value is shown URL-encoded or not.)
The token and cookie must come from the same logged-in session.
If you are able to create a Slack app, you can authenticate with a user OAuth
token instead of a browser session. It is more stable — it does not expire when
you sign out — and needs no --cookie:
- Create a new app at https://api.slack.com/apps ("From scratch").
- Under OAuth & Permissions, add the User Token Scopes
search:readandchat:write. - Click Install to Workspace and authorize the app.
- Copy the User OAuth Token (it begins with
xoxp-); use it asTOKENand omit--cookie.
deslackify --token TOKEN --cookie COOKIE USERNAMEBoth values can also be supplied via the SLACK_TOKEN and SLACK_COOKIE
environment variables (preferred, so the secrets do not appear in your shell
history or process list):
SLACK_TOKEN=… SLACK_COOKIE=… deslackify USERNAMEOr run it once without installing:
uvx deslackify --token TOKEN --cookie COOKIE USERNAMEUse --dry-run first to preview what would be deleted without deleting
anything.
By default deslackify will remove USERNAME's messages that are more than a
year old. You may also manually specify a before date via:
deslackify --token TOKEN --cookie COOKIE --before YYYY-MM-DD USERNAMENote: If no results are found, you may need to replace USERNAME with
USERID. You can find the USERID by going to Profile & Account, and then
clicking the three dots, and at the bottom, "Copy member ID".