I have tried multiple approaches to this. Tried first getting the user without any user id - this returns me just my user, then tried getting user with other id\'s and it al
You can use Slack's SCIM API to enable and disable a user. Note that, as with the undocumented API endpoint mentioned in other answers this requires a Plus/Enterprise account.
The users.profile.set apparently does not work for for setting each and every property of a user.
To set the deleted
property there is another API method called users.admin.setInactive. Its an undocumented method and it will only work on paid teams.
in python you can do the following:
import requests
def del_slack_user(user_id): # the user_id can be found under get_slack_users()
key = 'TOKEN KEY' #replace token key with your actual token key
payload = {'token': key, 'user': user_id}
response = requests.delete('https://slack.com/api/users.admin.setInactive', params=payload)
print(response.content)
def get_slack_users():
url = 'https://slack.com/api/users.list?token=ACCESSTOKEN&pretty=1'
response = requests.get(url=url)
response_data = response.json() # turns the query into a json object to search through`