# Update App Meta Data from Post User Registration

**URL:** <https://community.auth0.com/t/update-app-meta-data-from-post-user-registration/62720>\
**Category:** Get Help\
**Created:** [May 13, 2021, 4:51am UTC](https://community.auth0.com/t/update-app-meta-data-from-post-user-registration/62720 "2021-05-13T04:51:01Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [May 13, 2021, 5:28pm UTC](https://community.auth0.com/t/update-app-meta-data-from-post-user-registration/62720/6 "2021-05-13T17:28:43Z")

</div>

> [@techdynamism](#):
>
> Did you use client credentials (as my example shows)

Yes, here is my hook:

```auto
exports.onExecutePostUserRegistration = async (event) => {
  const ManagementClient = require('auth0').ManagementClient;

  var management = new ManagementClient({
      domain: event.secrets.domain,
      clientId: event.secrets.clientId,
      clientSecret: event.secrets.clientSecret,
  });

  await management.updateAppMetadata({id: event.user.user_id }, { alternateId: 123});
};

```

> [@techdynamism](#):
>
> What version of the auth0 package did you use (latest or 2.23.0)

`auth0@2.34.2`

> [@techdynamism](#):
>
> What permissions did you set (read:user, update:user, etc)

You should only need `update:users_app_metadata` for this, but my M2M app also has `create:users_app_metadata`, `read:users_app_metadata`, `update:users`, `read:users`, and `read:roles`.

> [@techdynamism](#):
>
> …So with that being said do you still recommend using pre-register?

If you want to be certain that the user has been created in Auth0 before syncing with your local database, I’d recommend using a post-login action. The action could check if it is the first login with `event.stats.logins_count === 1`.

The intent of post-user registration actions is more geared toward alerting other systems of the signup than altering data within Auth0. There is an uncommon, yet possible chance of a race condition where the user won’t be found in the post-user registration action when attempting to update the user’s metadata. More commonly, any alterations in the user’s data are not guaranteed to be present in other types of actions and this could lead to unexpected behavior later on.

---

_[View the full topic](https://community.auth0.com/t/update-app-meta-data-from-post-user-registration/62720)._
