# API responding to a rule

**URL:** <https://community.auth0.com/t/api-responding-to-a-rule/12676>\
**Category:** Get Help\
**Tags:** rules, redirect-rules, auth0\
**Created:** [June 29, 2018, 3:31am UTC](https://community.auth0.com/t/api-responding-to-a-rule/12676 "2018-06-29T03:31:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gregp/32/9350_2.png) [@gregp](https://community.auth0.com/u/gregp)\
**Post date:** [June 29, 2018, 3:31am UTC](https://community.auth0.com/t/api-responding-to-a-rule/12676/1 "2018-06-29T03:31:39Z")

</div>

I’ve been following this guide: [Redirect Users from Within Rules - Auth0 Docs](https://auth0.com/docs/rules/current/redirect) to use rules so that I can register a user’s user\_Id as a foreign key to related records. In my rule, I’m checking to ensure the protocol **is not a redirect callback** and that this is the user’s first time logging in (registering). That worked great, however I’m not exactly sure how to handle any errors down the Rule pipeline.

For example when creating a user, I check the database connection and if it’s unavailable then an error is thrown, if the new user record cannot be made, then another error is thrown, or what if the `user.user_id` or `state` from the Rule somehow doesn’t get passed as query arguments to my API?

Currently I’ve been catching those errors, and if found then I redirect the user to a custom “Unauthorized” url. This seems a little bit hacky, and I’m wondering if there is any functionality in Auth0 that handles these errors more elegantly, such as on an error, redirecting to some particular Auth0 route (maybe even Lock again).

FYI, using React front-end and Go for the API.

Any help is appreciated!

---

<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:** [December 19, 2018, 4:43pm UTC](https://community.auth0.com/t/api-responding-to-a-rule/12676/2 "2018-12-19T16:43:31Z")

</div>

Hey there @gregp,

As it has been more than a few months since this topic was opened and there has been no reply or further information provided from the community as to the existence of the issue we would like to check if you are still facing the described challenge?

We are more than happy to assist in any way! If the issue is still out there please let us know so we can create a new thread for better visibility, otherwise we’ll close this one in week’s time.

Thank you!

---

<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:** [December 26, 2018, 8:43am UTC](https://community.auth0.com/t/api-responding-to-a-rule/12676/4 "2018-12-26T08:43:37Z")

</div>

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