Deactivate a user
This endpoint is only available to organization administrators.
DELETE https://cores.zulipchat.com/api/v1/users/{user_id}
Deactivates a
user
given their user ID.
Note that any bots controlled by the user will be deactivated
before the user; clients that don't want this behavior are
expected to prompt the user to adjust the bot's owners before
making this API request.
Usage examples
#!/usr/bin/env python
import zulip
# The user for this zuliprc file must be an organization administrator
client = zulip.Client(config_file="~/zuliprc-admin")
# Deactivate a user given a user ID.
result = client.deactivate_user_by_id(user_id)
print(result)
curl -sSX DELETE https://cores.zulipchat.com/api/v1/users/12 \
-u BOT_EMAIL_ADDRESS:BOT_API_KEY \
--data-urlencode 'actions={"delete_direct_messages": false, "delete_private_channel_messages": false, "delete_profile": false, "delete_public_channel_messages": false}' \
--data-urlencode 'deactivation_notification_comment=Farewell!
'
Parameters
user_id integer required in path
Example: 12
actions object optional
Example: {"delete_profile": false, "delete_public_channel_messages": false, "delete_private_channel_messages": false, "delete_direct_messages": false}
Additional actions for the server to perform while deactivating the user.
As with the actual deactivation, actions are first applied
to any bots controlled by the target user, and then to the
target user.
Changes: New in Zulip 12.0 (feature level 459).
actions object details:
-
delete_profile: boolean Whether to delete the user's profile by updating their name
to "Deleted user" and removing their profile picture.
-
delete_public_channel_messages: boolean Whether to delete messages in public channels.
-
delete_private_channel_messages: boolean Whether to delete messages in private channels.
-
delete_direct_messages: boolean Whether to delete direct messages.
Response
Example response(s)
Changes: As of Zulip 7.0 (feature level 167), if any
parameters sent in the request are not supported by this
endpoint, a successful JSON response will include an
ignored_parameters_unsupported array.
A typical successful JSON response may look like:
{
"msg": "",
"result": "success"
}
An example JSON error response when attempting to deactivate the only
organization owner in an organization:
{
"code": "BAD_REQUEST",
"msg": "Cannot deactivate the only organization owner",
"result": "error"
}