# How to use Auth0 management API to retrieve user metadata

**URL:** <https://community.auth0.com/t/how-to-use-auth0-management-api-to-retrieve-user-metadata/119220>\
**Category:** Get Help\
**Tags:** user-password-management, user-management\
**Created:** [October 23, 2023, 9:53pm UTC](https://community.auth0.com/t/how-to-use-auth0-management-api-to-retrieve-user-metadata/119220 "2023-10-23T21:53:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![perathkarthik](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/perathkarthik/32/44683_2.png) [@perathkarthik](https://community.auth0.com/u/perathkarthik)\
**Post date:** [October 23, 2023, 9:53pm UTC](https://community.auth0.com/t/how-to-use-auth0-management-api-to-retrieve-user-metadata/119220/1 "2023-10-23T21:53:26Z")

</div>

Hi,

I need to retrieve user metadata on “Post Change Password” action. Docs says user\_metadata can not be retrieved using event.user.user\_metadata. So i am planning to use mgmt API and pass user\_id to getUser API. With the response from getUser i am planning to retrieve user\_metadata attribute. I have the following code which is not working.

```auto
const { ManagementClient } = require('auth0');

exports.onExecutePostChangePassword = async (event) => {
try {
const auth0 = new ManagementClient({
    domain: event.secrets.domain,
    clientId: event.secrets.clientID,
    clientSecret: event.secrets.clientSecret,
  });
const user_id = event.user.user_id
  const user = await auth0.getUser({ id: user_id });

  console.log('User Details:', user);
} catch (err) {
    console.log(`Error sending email to ${event.user.email}:`, err.message)
  }
};

```

But when testing in actions page, i get this error

> auth0.getUser is not a function

Any suggestions?

---

<div class="post-metadata">

**Author:** ![perathkarthik](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/perathkarthik/32/44683_2.png) [@perathkarthik](https://community.auth0.com/u/perathkarthik)\
**Post date:** [October 23, 2023, 11:03pm UTC](https://community.auth0.com/t/how-to-use-auth0-management-api-to-retrieve-user-metadata/119220/2 "2023-10-23T23:03:55Z")

</div>

i figured this out.

await management.users.get({ id: USER\_ID }, function (err, user) {  
console.log(user);  
});

---

<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:** [November 6, 2023, 11:04pm UTC](https://community.auth0.com/t/how-to-use-auth0-management-api-to-retrieve-user-metadata/119220/3 "2023-11-06T23:04:25Z")

</div>

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