# Update user\_metadata example from API docs not working

**URL:** <https://community.auth0.com/t/update-user-metadata-example-from-api-docs-not-working/77656>\
**Category:** Get Help\
**Tags:** user\_metadata, rules\
**Created:** [February 3, 2022, 11:00pm UTC](https://community.auth0.com/t/update-user-metadata-example-from-api-docs-not-working/77656 "2022-02-03T23:00:38Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [February 4, 2022, 7:59pm UTC](https://community.auth0.com/t/update-user-metadata-example-from-api-docs-not-working/77656/3 "2022-02-04T19:59:40Z")

</div>

Hi @conner.linzy,

Thanks for reaching out to the Auth0 Community!

First, I have tested the Rule snippet and was able to get it to work. I can confirm the [doc example](https://auth0.com/docs/manage-users/user-accounts/metadata/manage-metadata-rules#update-user-metadata) works correctly without issues.

In this case, I recommend you check the user’s profile details to verify if the _user.user\_metadata.preferences_ has already been created. If so, you will want to delete the property and retry again.

As an alternative, there is also the option to use the Auth0 [Post-Login Action](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow#enrich-the-user-profile) to accomplish the same results. For example:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if(!event.user.user_metadata.preferences){
    const preference = { "fontSize" : 12 }
    api.user.setUserMetadata("preferences", preference);
  }
};

```

Please let me know if you need any clarification or have further questions.

Thank you.

---

_[View the full topic](https://community.auth0.com/t/update-user-metadata-example-from-api-docs-not-working/77656)._
