Privy allows you to delete users via their Privy user ID. This is a destructive action: if the user logs into your app again, they will have a new user ID, will create a new embedded wallet address, and will have to relink any formerly linked accounts.

Please take extreme care when deleting users. For security of user assets, Privy does not delete the embedded wallet, and instead “soft deletes” it by disassociating it from the deleted user and archiving the data. If the user still has access to their login method, their wallet can be recovered after deletion. Reprovisioning a deleted wallet involves a support process, so please take care to only delete users that you intend to delete.

Use the PrivyClient’s deleteUser method to delete a user. As a parameter, pass the user’s Privy DID as a string:

await privy.deleteUser('did:privy:XXXXXX');

Complete Example

import { PrivyClient } from '@privy-io/server-auth';

const privy = new PrivyClient({
  appId: process.env.PRIVY_APP_ID,
  appSecret: process.env.PRIVY_APP_SECRET,
});

async function deletePrivyUser(did: string) {
  try {
    await privy.deleteUser(did);
    console.log(`User ${did} successfully deleted`);
    return true;
  } catch (error) {
    console.error(`Failed to delete user: ${error.message}`);
    return false;
  }
}

This method will throw an error if the deletion operation failed (e.g. due to an invalid Privy DID).