On this page

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 the User object)

    1user.DeleteUser(bool soft = false)
  • DeleteUser() (on the Chat object)

    1chat.DeleteUser(
    2 string userId,
    3 bool soft = false
    4)

Input

ParameterRequired in User objectRequired in Chat objectDescription
userId
Type: string
Default:
n/a
No
Yes
Unique user identifier (up to 92 UTF-8 characters).
soft
Type: bool
Default:
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

TypeDescription
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 the User object)

    1
    
  • DeleteUser() (on the Chat object)

    1
    

Other examples

Archive (soft delete) the user with an ID of support_agent_15, keeping their data in the App Context storage.

1

Last updated on