# Rules that run before user deletion

**URL:** <https://community.auth0.com/t/rules-that-run-before-user-deletion/24407>\
**Category:** Get Help\
**Tags:** management-api, auth0\
**Created:** [April 24, 2019, 10:02pm UTC](https://community.auth0.com/t/rules-that-run-before-user-deletion/24407 "2019-04-24T22:02:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![flle](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/flle/32/13741_2.png) [@flle](https://community.auth0.com/u/flle)\
**Post date:** [April 24, 2019, 10:02pm UTC](https://community.auth0.com/t/rules-that-run-before-user-deletion/24407/1 "2019-04-24T22:02:03Z")

</div>

Hi,

I wonder if there is a way to run rules on user deletion? If not, is there another way to hook into user deletion? In our system we need to make a pre check before a user is deleted.

Thank you

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [April 25, 2019, 11:54am UTC](https://community.auth0.com/t/rules-that-run-before-user-deletion/24407/2 "2019-04-25T11:54:50Z")

</div>

Hey there @flle!

Basically the core thing regarding rules that you need to take into account is that they are run upon successful login.

---

<div class="post-metadata">

**Author:** ![flle](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/flle/32/13741_2.png) [@flle](https://community.auth0.com/u/flle)\
**Post date:** [April 25, 2019, 10:07pm UTC](https://community.auth0.com/t/rules-that-run-before-user-deletion/24407/3 "2019-04-25T22:07:07Z")

</div>

So there is no way to hook into account deletion?

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [April 26, 2019, 8:08am UTC](https://community.auth0.com/t/rules-that-run-before-user-deletion/24407/4 "2019-04-26T08:08:07Z")

</div>

Can you provide me with more context around what you want to do before deleting the user? What kind of pre-check is that?

---

<div class="post-metadata">

**Author:** ![flle](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/flle/32/13741_2.png) [@flle](https://community.auth0.com/u/flle)\
**Post date:** [April 27, 2019, 7:38pm UTC](https://community.auth0.com/t/rules-that-run-before-user-deletion/24407/5 "2019-04-27T19:38:44Z")

</div>

Sure. Our users can own “Companies” in our software. The user should only be able to delete his account IF he’s not the only owner of the company. It would be good if our application could set a flag in the users app metadata that the user can be deleted. Users can delete them self if that flag is set to true (so before an account is deleted we would need to check if the user can be deleted). I personally would like to avoid having an access token on our backend that can delete users. So one solution would be what I described. Our application needs to allow it, and the user can then his account since the application gave approval. The users access token would need to have the delete account scope as well (don’t know if that’s the correct name of the scope - but I guess there is something like that).

---

<div class="post-metadata">

**Author:** ![p6l-richard](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/p6l-richard/32/13599_2.png) [@p6l-richard](https://community.auth0.com/u/p6l-richard)\
**Post date:** [September 21, 2020, 12:13pm UTC](https://community.auth0.com/t/rules-that-run-before-user-deletion/24407/7 "2020-09-21T12:13:56Z")

</div>

Any repsonse from auth0?  
This feels like a valid question (I myself would like to trigger something on user deletion, e.g. blacklist on our e-mailing list that is managed elsewhere).

---

<div class="post-metadata">

**Author:** ![markd](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/markd/32/38919_2.png) [@markd](https://community.auth0.com/u/markd)\
**Post date:** [September 21, 2020, 1:36pm UTC](https://community.auth0.com/t/rules-that-run-before-user-deletion/24407/8 "2020-09-21T13:36:27Z")

</div>

There’s nothing in Auth0 today (that I am aware of) that “triggers” on account deletion or an attempted account deletion. Perhaps Auth0 could create a new Hook that does this, though I can’t speak the technical possibility of that happening.

I would suggest submitting a [feature request](https://auth0.com/feedback).

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [September 21, 2020, 2:39pm UTC](https://community.auth0.com/t/rules-that-run-before-user-deletion/24407/9 "2020-09-21T14:39:24Z")

</div>

The previous reply from Mark is correct; there’s nothing (hooks or rules) that would execute upon user deletion.

However, the user deletion should be surfaced in tenant logs so you can configure log streaming ([Log Streams](https://auth0.com/docs/logs/streams)) to push tenant logs to your own system and from your own system configure alerts or actions to be taken for certain log events.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 8, 2024, 9:29am UTC](https://community.auth0.com/t/rules-that-run-before-user-deletion/24407/10 "2024-01-08T09:29:35Z")

</div>

Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next [Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team](https://community.auth0.com/t/auth0-community-ask-me-anything-rules-hooks-and-why-actions-matter/124043) on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

[Learn more here!](https://community.auth0.com/t/auth0-community-ask-me-anything-rules-hooks-and-why-actions-matter/124043)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 22, 2024, 9:29am UTC](https://community.auth0.com/t/rules-that-run-before-user-deletion/24407/11 "2024-01-22T09:29:48Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
