# setAppMetadata & setUserMetadata not working

**URL:** <https://community.auth0.com/t/setappmetadata-setusermetadata-not-working/133280>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [May 2, 2024, 1:30pm UTC](https://community.auth0.com/t/setappmetadata-setusermetadata-not-working/133280 "2024-05-02T13:30:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonetics](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/anonetics/32/71118_2.png) [@anonetics](https://community.auth0.com/u/anonetics)\
**Post date:** [May 2, 2024, 1:30pm UTC](https://community.auth0.com/t/setappmetadata-setusermetadata-not-working/133280/1 "2024-05-02T13:30:22Z")

</div>

Hi! I am currently trying to create an action which is Post Registration and creates some App Metadata for the user. However, even if I break down my code into just these few lines:

exports.onExecutePostUserRegistration = async (event, api) =\> {

api.user.setAppMetadata(“key”, “value”);

};

It still throws the following error:

“Cannot read properties of undefined (reading ‘setAppMetadata’)”

I already have searched the forums but I’m still unable to find a solution. Any help is very appreciated! Thank you so much in advance!!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 10, 2024, 9:06pm UTC](https://community.auth0.com/t/setappmetadata-setusermetadata-not-working/133280/3 "2024-05-10T21:06:44Z")

</div>

Hey @anonetics welcome to the community!

Sorry for the delayed response here - As noted in the following post, adding app and or user metadata to users should be done in pre registration or post login actions:

> [@Update App Meta Data from Post User Registration](https://community.auth0.com/t/update-app-meta-data-from-post-user-registration/62720/4):
>
> 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…

---

<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:** [May 31, 2024, 8:49am UTC](https://community.auth0.com/t/setappmetadata-setusermetadata-not-working/133280/5 "2024-05-31T08:49:49Z")

</div>

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