Search code examples
slack-apislack

cant_delete_file even if I have the right scopes?


Since Slack doesn't support bulk delete, I have searched for alternatives. The search didn't took long, and I stumbled upon this Python script which use Slack's Web API to delete all files that are there for more than 30 days.

After struggling to get the token right, I got a valid token with the scopes files:read and files:write:user.

The script starts, gets the list of files, and sends the request to delete correctly, but the answer from Slack is systematic:

{"ok":false,"error":"cant_delete_file"}

Searching for this error code reveals it is because I don't have the permissions to do erase them.

I can't find any more information, and I'm struggling to know what goes wrong. What is the reason I don't have the permissions?


Solution

  • You need to be authenticated as an admin user to delete a file that belongs to another user.

    I would agree that the error message could give more details about the situation.

    Edit: this answer is outdated, see this comment.