Deactivate a User

LAST EDIT Apr 08 2021

To deactivate a user, Stream Chat exposes a deactivateUser method. This method can only be called server-side due to security concerns, so please keep this in mind when attempting to make the call.

Below is an example of how to execute the call to deactivateUser:

1
const deactivate = await client.deactivateUser('user_id');
1
response = client.deactivate_user("user_id")
1
response = @client.deactivate_user('user_id')
1
$response = $this->client->deactivateUser($user["id"]);
1
1
result = await this._endpoint.Deactivate([user.ID]);

The response will contain an object with the user ID that was deactivated. Further, the user will no longer be able to connect to Stream Chat as an error will be thrown.

To reinstate the user as active, use the reactivateUser method by passing the users ID as a parameter:

1
const reactivate = await client.reactivateUser('user_id');
1
response = client.reactivate_user("user_id")
1
response = @client.reactivate_user('user_id')
1
$response = $this->client->reactivateUser($user["id"]);
1
1
result = await this._endpoint.Reactivate([user.ID]);