Search code examples
google-workspace

Automatic reminder before an user get purged in Google Workspace


According to this article, you have up to 20 days to restore a deleted user. How can I create an automatic reminder to double check the user status before that? I did not find this functionality in the guides.


Solution

  • There are some events-based admin alerts available in the Admin Console. Anyway, for deleted users, there is only one option: send an alert when a user is deleted.

    To have the functionality you want, you need to create it using the Google Workspace Admin SDK > Directory API > Users:

    • Using Method: users.list, you will be able to list all the deleted users by selecting the query parameter showDeleted as true.
    • In the results, each deleted user will include the field deletionTime.
    • Comparing the deletionTime against the current time, you would be able to count the days since the user was deleted. Depending on the number of days you define (for example more than 15 days), you may want to send you an alert (like an email).
    • You would be able to define this alert as you need (for example send a reminder every three days after a user was deleted and it has not been restored).