# Using api.user.setAppMetadata() in Pre Registration Action for Passwordless flow

**URL:** <https://community.auth0.com/t/using-api-user-setappmetadata-in-pre-registration-action-for-passwordless-flow/89894>\
**Category:** Get Help\
**Tags:** pre-user-registratio, actions, passwordless\
**Created:** [September 1, 2022, 8:47pm UTC](https://community.auth0.com/t/using-api-user-setappmetadata-in-pre-registration-action-for-passwordless-flow/89894 "2022-09-01T20:47:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaciel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cmaciel/32/33462_2.png) [@cmaciel](https://community.auth0.com/u/cmaciel)\
**Post date:** [September 1, 2022, 8:47pm UTC](https://community.auth0.com/t/using-api-user-setappmetadata-in-pre-registration-action-for-passwordless-flow/89894/1 "2022-09-01T20:47:14Z")

</div>

Hello, I’m trying to add some data to a user’s `app_metadata` in a pre-registration action for a passwordless flow. However, when running something like this in my action:

```auto
exports.onExecutePreUserRegistration = async (event, api) => {
  api.user.setAppMetadata('foo', 'bar');
};

```

After the user is created I don’t see the `{'foo': 'bar'}` data in the user’s app\_metadata. I’m also adding some logging to the Action which I do see running with no errors using the Real-Time webtask logs.

I did see [this post](https://community.auth0.com/t/adding-user-to-default-role-passwordless-flow/63706/6) from June 2021 that suggests this is a bug, wondering if this was just never fixed, or if I’m missing something on my end. Thanks for your time!

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [September 1, 2022, 11:39pm UTC](https://community.auth0.com/t/using-api-user-setappmetadata-in-pre-registration-action-for-passwordless-flow/89894/3 "2022-09-01T23:39:04Z")

</div>

Hi @cmaciel,

Welcome to the Auth0 Community!

I understand that you have not been able to set the user\_metadata for Passwordless Users in a Pre-User Registration Flow.

After testing this myself, I noticed the same observations as you where updating the user\_metadata does not persist in the user profile. More interestingly, when using the Realtime Webtask Logs extension to print the `event.user` property, the user\_metadata shows the updated values but ignores updating them in the user profile.

Moreover, after checking with our Engineering teams, I can confirm that this is a known bug and has been moved into our product backlog to be addressed. However, I am unable to provide an ETA as to when this will be fixed.

I hope this answers your questions.

Please reach out if you have additional questions.

Thank you.

---

<div class="post-metadata">

**Author:** ![cmaciel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cmaciel/32/33462_2.png) [@cmaciel](https://community.auth0.com/u/cmaciel)\
**Post date:** [September 7, 2022, 1:31pm UTC](https://community.auth0.com/t/using-api-user-setappmetadata-in-pre-registration-action-for-passwordless-flow/89894/4 "2022-09-07T13:31:58Z")

</div>

Hi @rueben.tiow,

Thanks for the investigation. Do you know if instead of actions, I can use either Rules or Hooks to update a user’s `user_metadata` in a pre-user registration flow since Actions is broken? Or are there any work arounds for this bug?

Thanks!

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [September 8, 2022, 12:25am UTC](https://community.auth0.com/t/using-api-user-setappmetadata-in-pre-registration-action-for-passwordless-flow/89894/5 "2022-09-08T00:25:13Z")

</div>

Hi @cmaciel,

Thank you for your response!

Unfortunately, it will not be possible to workaround this issue at the moment using either Rules or Hooks since behind the scenes, they function the same as Actions.

However, I would suggest a workaround using a Post-Login Action and checking if the user satisfies a condition that allows you to set the user\_metadata on the first login.

For example:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if(!event.user.user_metadata.setMetadata){
    //set your other user_metadata here
    api.user.setUserMetadata("setMetadata", true)
}

```

I hope this helps!

Please let me know if there’s anything else I can do to help.

Thank you.

---

<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:** [December 21, 2022, 6:13pm UTC](https://community.auth0.com/t/using-api-user-setappmetadata-in-pre-registration-action-for-passwordless-flow/89894/7 "2022-12-21T18:13:24Z")

</div>


