Users

Users export

Stream allows you to export users with their data, including the calls they participated in.

// request data export for multiple users at once
await client.exportUsers({ user_ids: ["<user id1>", "<user id1>"] });

Exporting users is an async operation, this is how you can check the progress and retrieve the result:

// Example of monitoring the status of an async task
// The logic is same for all async tasks
const response = await client.exportUsers({
  user_ids: ["<user id1>", "<user id1>"],
});

// you need to poll this endpoint
const taskResponse = await client.getTask({ id: response.task_id });

console.log(taskResponse.status === "completed");

For more information, please refer to the async operations guide.

Users deletion

Stream allows you to delete users and optionally the calls they were part of.
Note that this apply only to 1:1 calls, not group calls.

client.deleteUsers({ user_ids: ["<id>"] });

//restore
client.restoreUsers({ user_ids: ["<id>"] });

The delete users endpoints supports the following parameters to control which data needs to be deleted and how. By default users and their data are soft-deleted.

NameTypeDescriptionOptional
userEnum (soft, pruning, hard)- Soft: marks user as deleted and retains all user data.
- Pruning: marks user as deleted and nullifies user information.
- Hard: deletes user completely - this requires hard option for messages and conversation as well.
Yes
conversationsEnum (soft, hard)- Soft: marks all conversation channels as deleted (same effect as Delete Channels with ‘hard’ option disabled).
- Hard: deletes channel and all its data completely including messages (same effect as Delete Channels with ‘hard’ option enabled).
Yes
messagesEnum (soft, pruning, hard)- Soft: marks all user messages as deleted without removing any related message data.
- Pruning: marks all user messages as deleted, nullifies message information and removes some message data such as reactions and flags.
- Hard: deletes messages completely with all related information.
Yes
new_channel_owner_idstringChannels owned by hard-deleted users will be transferred to this userID. If you doesn’t provide a value, the channel owner will have a system generated ID like delete-user-8219f6578a7395gYes
callsEnum (soft, hard)- Soft: marks calls and related data as deleted.
- Hard: deletes calls and related data completely
Note that this applies only to 1:1 calls, not group calls
Yes

Deleting users is done asynchronously and and can take some time to complete. You can find more information on how to work with API endpoints performing async work in the async operations guide.

© Getstream.io, Inc. All Rights Reserved.