# Retry Hook if my own API server failed

**URL:** <https://community.auth0.com/t/retry-hook-if-my-own-api-server-failed/44139>\
**Category:** Get Help\
**Tags:** hooks\
**Created:** [June 4, 2020, 9:25pm UTC](https://community.auth0.com/t/retry-hook-if-my-own-api-server-failed/44139 "2020-06-04T21:25:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdere](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mdere/32/21705_2.png) [@mdere](https://community.auth0.com/u/mdere)\
**Post date:** [June 4, 2020, 9:25pm UTC](https://community.auth0.com/t/retry-hook-if-my-own-api-server-failed/44139/1 "2020-06-04T21:25:18Z")

</div>

Is there a way to ensure a hook runs successfully and keep on retrying? We are trying to sync Auth0 DB users to our legacy DB as we are integrating Auth0 and we want our pre existing features to be back ward compatible with when a user is created through Auth0 vs our legacy system.

So my thought is to send the authenthication event results from two ways:

1. Through client from using Lock on event “on authentication” to our own endpoint
2. Have Auth0 handle it through hooks

I don’t know a good way for us to approach this on ensuring that the database is synced at all times. Any suggestions?

Thanks,

---

<div class="post-metadata">

**Author:** ![rashid779939](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rashid779939/32/27027_2.png) [@rashid779939](https://community.auth0.com/u/rashid779939)\
**Post date:** [June 5, 2020, 7:39am UTC](https://community.auth0.com/t/retry-hook-if-my-own-api-server-failed/44139/2 "2020-06-05T07:39:19Z")

</div>

Hi @mdere,

Welcome to the Community!

As hooks run in a sequence from top to down and there is not any way to re run hook in same cycle. What i suggest to you is that you write your logic in hook in some kind of loop to retry when your required condition doesn’t meet or you can write two hooks to give another try to sync your DB.

Please let us know if it helps.

---

<div class="post-metadata">

**Author:** ![mdere](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mdere/32/21705_2.png) [@mdere](https://community.auth0.com/u/mdere)\
**Post date:** [June 5, 2020, 5:50pm UTC](https://community.auth0.com/t/retry-hook-if-my-own-api-server-failed/44139/3 "2020-06-05T17:50:04Z")

</div>

@rashid779939 - are we able to just rollback the created user in the post registration - if so can you provide a quick code snippet on how to achieve that in the hook?

---

<div class="post-metadata">

**Author:** ![mdere](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mdere/32/21705_2.png) [@mdere](https://community.auth0.com/u/mdere)\
**Post date:** [June 5, 2020, 5:51pm UTC](https://community.auth0.com/t/retry-hook-if-my-own-api-server-failed/44139/4 "2020-06-05T17:51:04Z")

</div>

Also I am having difficulty getting a full context on what we can do inside a hook - are there more hook examples of specific scenarios?

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [June 18, 2020, 9:26pm UTC](https://community.auth0.com/t/retry-hook-if-my-own-api-server-failed/44139/5 "2020-06-18T21:26:41Z")

</div>

Touching base on this topic @mdere and I wanted to find out if you are still running into a challenge with this? Also are you accounting for rate limiting with your implementation? I would love to find out more about the situation and how I can be of service. Thanks!

> **[Auth0 Hooks](https://auth0.com/docs/customize/hooks)**
>
> Describes Auth0 hooks, some of which may be used with database and passwordless connections.

---

<div class="post-metadata">

**Author:** ![mdere](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mdere/32/21705_2.png) [@mdere](https://community.auth0.com/u/mdere)\
**Post date:** [June 19, 2020, 3:53pm UTC](https://community.auth0.com/t/retry-hook-if-my-own-api-server-failed/44139/6 "2020-06-19T15:53:47Z")

</div>

I think I am good now.

---

<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:** [June 22, 2020, 8:41am UTC](https://community.auth0.com/t/retry-hook-if-my-own-api-server-failed/44139/7 "2020-06-22T08:41:13Z")

</div>

Perfect! Glad to hear that!

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [July 6, 2020, 12:41pm UTC](https://community.auth0.com/t/retry-hook-if-my-own-api-server-failed/44139/8 "2020-07-06T12:41:13Z")

</div>

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