Delete users
Two DeleteUser() methods let you remove an existing user. You can remove the user either with or without deleting their historical data from the App Context storage.
Both of these methods give the same output. The only difference is that you call a given method either on the Chat or the User object. Depending on the object, these methods take a different set of input parameters - you either have to specify the user ID you want to delete or not because it's already known.
Requires App Context
To store data about users, you must enable App Context for your app's keyset in the Admin Portal.
Method signature
These methods take the following parameters:
-
DeleteUser()(on theUserobject)1user.DeleteUser(bool soft = false) -
DeleteUser()(on theChatobject)1chat.DeleteUser(
2 string userId,
3 bool soft = false
4)
Input
| Parameter | Required in User object | Required in Chat object | Description |
|---|---|---|---|
userIdType: stringDefault: n/a | No | Yes | Unique user identifier (up to 92 UTF-8 characters). |
softType: boolDefault: false | No | No | Define if you want to permanently remove user metadata. The user metadata gets permanently deleted from the App Context storage by default. If you set this parameter to true, the user's IsDeleted property is set to true, and you can still restore/get their metadata. |
Output
| Type | Description |
|---|---|
Task<ChatOperationResult> | Returned Task that you can await to get the result of the delete operation. |
Sample code
Permanently delete user support_agent_15.
-
DeleteUser()(on theUserobject)1 -
DeleteUser()(on theChatobject)1
Other examples
Archive (soft delete) the user with an ID of support_agent_15, keeping their data in the App Context storage.
1