GDPR

Last Edit: Oct 19 2020

To export user data, Stream Chat exposes an exportUser 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 export user data:


const data = await client.exportUser('user_id');
                    

response = client.export_user("user_id");
                    

response = @client.export_user('user_id')
                    

$response = $this->client->exportUser($user["id"]);
                    

var exportedUser = await this._endpoint.Export(user1.ID);
                    

user, _ := client.ExportUser("userID", nil)
                    

The export will return all data about the user, including:

  • User ID

  • Messages

  • Reactions

  • Custom Data

Users with more than 10,000 messages will throw an error during the export process. The Stream Chat team is actively working on a workaround for this issue and it will be resolved soon.

Deactivate a User

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:


const deactivate = await client.deactivateUser('user_id');
                    

response = client.deactivate_user("user_id")
                    

response = @client.deactivate_user('user_id')
                    

$response = $this->client->deactivateUser($user["id"]);
                    

_ = client.DeactivateUser("userID", nil
                    

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:


const reactivate = await client.reactivateUser('user_id');
                    

response = client.reactivate_user("user_id")
                    

response = @client.reactivate_user('user_id')
                    

$response = $this->client->reactivateUser($user["id"]);
                    

_ = client.ReactivateUser("userID", nil)
                    

result = await this._endpoint.Reactivate([user.ID]);
                    

Delete a User

To delete user data, Stream Chat exposes a deleteUser 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 deleteUser:


const destroy = await client.deleteUser('user_id', {
    mark_messages_deleted: false,
});
                    

response = client.delete_user(random_user["id"])
                    

response = @client.delete_user(
   'user_id',
   mark_messages_deleted: true,
   hard_delete: true
)
                    

$response = $this->client->deleteUser($user["id"]);
                    

_ = client.DeleteUser("userID", nil)
                    

result = await this._endpoint.Delete([user.ID]);
                    
The mark_messages_deleted parameter is optional. This parameter will delete all messages associated with the user. If you would like to keep message history, ensure that mark_messages_deleted is set to false. To remove all messages related to the user, set the value to true.

To perform a "hard delete" on the user, you must set mark_messages_deleted to true and provide an additional parameter called hard_delete with the value set to true. This method will delete all messages, reactions, and any other associated data with the user.


const destroy = await client.deleteUser('user_id', {
    mark_messages_deleted: true,
    hard_delete: true,
});
                    

$response = $client->deleteUser($user["id"], ['mark_messages_deleted' => true, 'hard_delete' => true]);
                    

options := map[string][]string{
	"mark_messages_deleted": {"true"},
	"hard_delete":           {"true"},
}

_ = client.DeleteUser("userID", options)
                    

After deleting or hard deleting a user, the user will no longer be able to:

  • Connect to Stream Chat

  • Send or receive messages

  • Be displayed when querying users

  • Have messages stored in Stream Chat (depending on whether or not mark_messages_deleted is set to true or false)

Once a user has been deleted, there is no way to reinstate their access without creating a new user in Stream Chat.