# Access management API from hook

**URL:** <https://community.auth0.com/t/access-management-api-from-hook/63327>\
**Category:** Get Help\
**Created:** [May 25, 2021, 11:48am UTC](https://community.auth0.com/t/access-management-api-from-hook/63327 "2021-05-25T11:48:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![adeliab](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adeliab/32/12951_2.png) [@adeliab](https://community.auth0.com/u/adeliab)\
**Post date:** [May 25, 2021, 11:48am UTC](https://community.auth0.com/t/access-management-api-from-hook/63327/1 "2021-05-25T11:48:11Z")

</div>

Related to this post: [New user via API - set password flow - #11 by adeliab](https://community.auth0.com/t/new-user-via-api-set-password-flow/62654/11) I’m looking into using Post User Registation Hooks to get password change ticket and call sendgrid to send an email.

Looking at this post [Accessing Auth0 Management API in rules vs hooks](https://community.auth0.com/t/accessing-auth0-management-api-in-rules-vs-hooks/19264) it seems that it is not possible to access the management API from Hooks. Is this correct?

In this example: [Send Email Invitations for Application Signup](https://auth0.com/docs/email/send-email-invitations-for-application-signup) where does the process to get the change password ticket and send email take place? It’s unclear

Thanks

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [May 26, 2021, 7:22pm UTC](https://community.auth0.com/t/access-management-api-from-hook/63327/3 "2021-05-26T19:22:15Z")

</div>

Hi @adeliab,

> [@adeliab](#):
>
> Looking at this post [Accessing Auth0 Management API in rules vs hooks](https://community.auth0.com/t/accessing-auth0-management-api-in-rules-vs-hooks/19264) it seems that it is not possible to access the management API from Hooks. Is this correct?

It is possible to use the management API in hooks. That post is just saying that the same tools aren’t available to set up the call to the management API (it just takes a bit more code to get the access token).

With that said, you should avoid making a call to update a user (or send a ticket in this case) because a user may not exist when a post registration hook/action is executed.

> [@adeliab](#):
>
> In this example: [Send Email Invitations for Application Signup](https://auth0.com/docs/email/send-email-invitations-for-application-signup?_ga=2.157450810.1043052393.1621874283-1261373470.1602622721&_gl=1*1xc0fp9*rollup_ga*MTI2MTM3MzQ3MC4xNjAyNjIyNzIx*rollup_ga_F1G3E656YZ*MTYyMjA1NDQ4Ny4yLjEuMTYyMjA1NTQxMS41OQ..) where does the process to get the change password ticket and send email take place?

This would need to be handled by your backend.

---

<div class="post-metadata">

**Author:** ![adeliab](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adeliab/32/12951_2.png) [@adeliab](https://community.auth0.com/u/adeliab)\
**Post date:** [May 27, 2021, 6:45am UTC](https://community.auth0.com/t/access-management-api-from-hook/63327/4 "2021-05-27T06:45:06Z")

</div>

Thanks @dan.woda . According to the [documentation](https://auth0.com/docs/hooks/extensibility-points/post-user-registration) this hook is triggered after the user is added to the database. I understand that the hook will run async to the transaction so an update is not recommended. But creating a password change ticket shouldn’t affect the user right? It’s only creating a link?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [May 27, 2021, 7:16pm UTC](https://community.auth0.com/t/access-management-api-from-hook/63327/5 "2021-05-27T19:16:27Z")

</div>

I think it is possible that you would run into a scenario where the user does not yet exist and you return an `Error: 404 User not found`.

One of our engineers @stephanie.chamblee just wrote a great FAQ about it:

[https://community.auth0.com/t/can-i-use-a-post-user-registration-action-or-hook-to-update-a-user/63423](https://community.auth0.com/t/can-i-use-a-post-user-registration-action-or-hook-to-update-a-user/63423)

---

<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:** [July 13, 2021, 4:31pm UTC](https://community.auth0.com/t/access-management-api-from-hook/63327/6 "2021-07-13T16:31:44Z")

</div>

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