# 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:** 4

<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, 3:49pm UTC](https://community.auth0.com/t/update-app-meta-data-from-post-user-registration/62720/4 "2021-05-13T15:49:14Z")

</div>

Hi @techdynamism,

I just tested out your code in my own tenant, and it seems to make the update on the user, although the user ID is referenced with `event.user.user_id` instead of `event.user.id`. You can find the post-user registration event object here: [Actions Triggers: post-user-registration - Event Object](https://auth0.com/docs/actions/triggers/post-user-registration/event-object). It might be helpful to log the secrets to make sure they contain the correct credentials and don’t contain quotes, etc.

As a side note, since you are updating app metadata, you may want to consider using a pre-user registration or post login action instead of a post-registration action.

Post-user registration actions are best suited for tasks such as notifying another system about a signup. Due to the async nature of this trigger, you may encounter unexpected behavior or side effects if you use it to make persistent changes on a user (for example, assigning a role or updating app metadata).

For updating app metadata, it’d be much safer to use a pre-user registration or post login action.

Here is how you can update app metadata in a pre-user registration action:

```auto
exports.onExecutePreUserRegistration = async (event, api) => {
  api.user.setUserMetadata('alternateId', 123);  
};

```

> **[Pre User Registration Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/pre-user-registration-flow)**
>
> Learn about the Pre User Registration Flow, which runs when a user attempts to register through a Database or Passwordless connection. It can be used to add metadata to the user profile before it is created or to deny a registration.

And here is how you would update app metadata in a post-login action:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (event.stats.logins_count === 1) {
    api.user.setAppMetadata('alternateId', 123);
  }
};

```

[https://auth0.com/docs/actions/triggers/post-login/manage-user-metadata](https://auth0.com/docs/actions/triggers/post-login/manage-user-metadata)

---

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