# Working example of updating metadata in Nodejs?

**URL:** <https://community.auth0.com/t/working-example-of-updating-metadata-in-nodejs/96865>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [December 21, 2022, 1:09am UTC](https://community.auth0.com/t/working-example-of-updating-metadata-in-nodejs/96865 "2022-12-21T01:09:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![athome176](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/athome176/32/40591_2.png) [@athome176](https://community.auth0.com/u/athome176)\
**Post date:** [December 21, 2022, 1:09am UTC](https://community.auth0.com/t/working-example-of-updating-metadata-in-nodejs/96865/1 "2022-12-21T01:09:33Z")

</div>

I have a NodeJS/Express backend. I’m building a React SPA which creates groups of users with a single group admin. If a new user creates their own group, then I mark them as an admin in my own user DB. I also want to leverage an Auth0 role to control permissions. I have a structure for this in both front and backends which works - but I currently manage role assignment only through the console. What I want instead is to include code in my backend that communicates with the Auth0 mgmt api during the New Group process and assigns the admin role to the user in question.

I found this guidance: [Manage Metadata Using the Management API](https://auth0.com/docs/manage-users/user-accounts/metadata/manage-metadata-api)

But it’s still not clear to me how to actually use this in my backend operationally. All I need if a single working Github example of mgmt API use in a NodeJS and I can probably figure it out - but I can’t find any working examples anywhere. Does anyone know of an example I can reference to see Node JS mgmt API communication in action, most especially an example which updates user or app metadata?

---

<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:** [December 21, 2022, 1:23am UTC](https://community.auth0.com/t/working-example-of-updating-metadata-in-nodejs/96865/3 "2022-12-21T01:23:39Z")

</div>

Hi @athome176,

Thanks for reaching out to the Auth0 Community!

I understand that you need some help with a working example of using the Management API to update a user’s metadata in Node.js

Here is an example:

```auto
var axios = require("axios").default;

var options = {
  method: 'PATCH',
  url: 'https://YOUR_DOMAIN/api/v2/users/user_id',
  headers: {authorization: 'Bearer ABCD', 'content-type': 'application/json'},
  data: {user_metadata: {addresses: {home: '123 Main Street, Anytown, ST 12345'}}}
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});

```

Let me also add that you can find this same example in [the doc you shared](https://auth0.com/docs/manage-users/user-accounts/metadata/manage-metadata-api?#update-user-metadata) and clicking on the **Node.js** tab:

I hope this helps!

Please let me know if I can help you with anything else.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![athome176](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/athome176/32/40591_2.png) [@athome176](https://community.auth0.com/u/athome176)\
**Post date:** [December 21, 2022, 1:45am UTC](https://community.auth0.com/t/working-example-of-updating-metadata-in-nodejs/96865/4 "2022-12-21T01:45:40Z")

</div>

Thanks for the quick reply Reuben! I saw that example. The problem is that I have no idea how to actually use this in practice. If there were even a single working sample app that used this operationally, I could look at the sample app and figure it out. Does Auth0 have a sample app that uses this anywhere?

---

<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:** [December 21, 2022, 3:02am UTC](https://community.auth0.com/t/working-example-of-updating-metadata-in-nodejs/96865/5 "2022-12-21T03:02:30Z")

</div>

Hi @athome176,

Thank you for your response.

I recommend reading our [Auth0 Express SDK Quickstart](https://auth0.com/docs/quickstart/webapp/express/interactive) documentation.

The documentation has an [example application](https://github.com/auth0-samples/auth0-express-webapp-sample/tree/master/01-Login) and a guide to using our [Express SDK](https://github.com/auth0/express-openid-connect).

Does that help?

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![athome176](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/athome176/32/40591_2.png) [@athome176](https://community.auth0.com/u/athome176)\
**Post date:** [December 21, 2022, 3:47am UTC](https://community.auth0.com/t/working-example-of-updating-metadata-in-nodejs/96865/6 "2022-12-21T03:47:00Z")

</div>

Thanks for the links Rueben. Unfortunately, none of that helps in this case as I do not see any examples of updating metadata via Auth0 mgmt api from the backend. I will keep digging through documentation and examples to see if I can find something.

---

<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:** [December 23, 2022, 11:20pm UTC](https://community.auth0.com/t/working-example-of-updating-metadata-in-nodejs/96865/7 "2022-12-23T23:20:24Z")

</div>

Hi @athome176,

Thank you for your reply.

You should be able to embed the code snippet I shared in my initial post into your backend code to make a call to the Management API to update the user’s user\_metadata.

Were you having any issues getting that implemented?

Thanks,  
Rueben

---

<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:** [January 6, 2023, 11:20pm UTC](https://community.auth0.com/t/working-example-of-updating-metadata-in-nodejs/96865/8 "2023-01-06T23:20:52Z")

</div>

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