# How to automate user delete

**URL:** <https://community.auth0.com/t/how-to-automate-user-delete/61936>\
**Category:** Get Help\
**Tags:** bulk-delete-user, delete-user\
**Created:** [April 29, 2021, 7:03am UTC](https://community.auth0.com/t/how-to-automate-user-delete/61936 "2021-04-29T07:03:34Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ricardo.batista](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ricardo.batista/32/7711_2.png) [@ricardo.batista](https://community.auth0.com/u/ricardo.batista)\
**Post date:** [April 29, 2021, 10:10am UTC](https://community.auth0.com/t/how-to-automate-user-delete/61936/2 "2021-04-29T10:10:34Z")

</div>

Hi @ev-petteri.makela

There is no automatic “retention policy” feature, but you might accomplish this by getting a list of users with a last\_login date of longer than a year, iterating over that list and deleting the users.

1. to get the list of users that have not logged in in a year, you’ll need to use the [GET /api/v2/users](https://auth0.com/docs/api/management/v2#!/Users/get_users) endpoint with the query `last_login: [* TO 2020-04-29]`

2. to delete the users, you can use the [DELETE /api/v2/users/{id}](https://auth0.com/docs/api/management/v2#!/Users/delete_users_by_id) endpoint with each of the user ids

You can then create a script to run this periodically. Be sure to check the [rate limits](https://auth0.com/docs/policies/rate-limit-policy/management-api-endpoint-rate-limits), specially for the delete users step.

---

_[View the full topic](https://community.auth0.com/t/how-to-automate-user-delete/61936)._
