# Accessing user\_metadata in Auth0 Action

**URL:** <https://community.auth0.com/t/accessing-user-metadata-in-auth0-action/79681>\
**Category:** Get Help\
**Tags:** change-password, auth0\
**Created:** [March 10, 2022, 7:15pm UTC](https://community.auth0.com/t/accessing-user-metadata-in-auth0-action/79681 "2022-03-10T19:15:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dheerajdhall2709](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dheerajdhall2709/32/13346_2.png) [@dheerajdhall2709](https://community.auth0.com/u/dheerajdhall2709)\
**Post date:** [March 10, 2022, 7:15pm UTC](https://community.auth0.com/t/accessing-user-metadata-in-auth0-action/79681/1 "2022-03-10T19:15:10Z")

</div>

Hello! I am trying to add a check for a particular field that exists in `user_metadata`. I want to add this check in an on password-change action. For some reason the `User` Object in the Action Test section is this and it;s missing the user\_metadata

```auto
"user": {
    "id": "SOME_ID",
    "user_id": "899898",
    "email": "someemail@this.com",
    "email_verified": true,
    "last_password_reset": "2022-03-10T19:08:03.417Z",
    "username": "some smith"
  }

```

instead of the full-blown

```auto
"user": {
    "app_metadata": {},
    "created_at": "2022-03-10T19:13:33.919Z",
    "email_verified": true,
    "email": "someemail@this.com",
    "family_name": "some",
    "given_name": "smith",
    "identities": [
      {
        "connection": "Username-Password-Authentication",
        "isSocial": false,
        "provider": "auth0",
        "userId": "123",
        "accessToken": "",
        "profileData": {},
        "user_id": "5f7c8ec7c33c6c004bbafe82"
      }
    ],
    "last_password_reset": "2022-03-10T19:13:33.919Z",
    "name": "somesmith",
    "nickname": "j+smith",
    "phone_number": "18882352699",
    "phone_verified": false,
    "picture": "http://www.gravatar.com/avatar/?d=identicon",
    "updated_at": "2022-03-10T19:13:33.919Z",
    "user_id": "auth0|5f7c8ec7c33c6c004bbafe82",
    "user_metadata": {},
    "username": "somesmith",
    "multifactor": []
  }

```

I am not sure how to get the `user_metadata` field in that object.  
Also, what would be an alternative solution to check for `user_metadata` in an action?

---

<div class="post-metadata">

**Author:** ![dheerajdhall2709](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dheerajdhall2709/32/13346_2.png) [@dheerajdhall2709](https://community.auth0.com/u/dheerajdhall2709)\
**Post date:** [March 10, 2022, 7:49pm UTC](https://community.auth0.com/t/accessing-user-metadata-in-auth0-action/79681/3 "2022-03-10T19:49:57Z")

</div>

Okay. I see my mistake. I setup a `Post Login` Action instead of `Post Password Change` and both have different payloads. So the next question would be how to get the `user_metadata` in the `Post Password Change` Action? Do I use the Management API?

---

<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:** [March 10, 2022, 10:15pm UTC](https://community.auth0.com/t/accessing-user-metadata-in-auth0-action/79681/4 "2022-03-10T22:15:06Z")

</div>

Hi @dheerajdhall2709,

Thanks for reaching out to the Auth0 Community!

> [@dheerajdhall2709](#):
>
> how to get the `user_metadata` in the `Post Password Change` Action? Do I use the Management API?

That is correct. The [Post Password Change Action event object](https://auth0.com/docs/customize/actions/flows-and-triggers/post-change-password-flow/event-object) does not have any way to call the user’s user\_metadata.

As a workaround, you could use the Management API to accomplish this. Please take a look at the [How can I use the Management API in Actions?](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947) FAQ to learn how to do so.

Once that is complete, you can call the ManagementClient [`getUser`](https://auth0.github.io/node-auth0/ManagementClient.html#getUser) method to get the user’s user\_metadata.

Hoped this helps!

Please let me know if you have any additional questions.

Thank you.

---

<div class="post-metadata">

**Author:** ![dheerajdhall2709](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dheerajdhall2709/32/13346_2.png) [@dheerajdhall2709](https://community.auth0.com/u/dheerajdhall2709)\
**Post date:** [March 11, 2022, 12:05am UTC](https://community.auth0.com/t/accessing-user-metadata-in-auth0-action/79681/5 "2022-03-11T00:05:14Z")

</div>

@rueben.tiow Thank you for replying. I think this will do. I just wanted to be sure that this was the only way.

---

<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:** [March 26, 2022, 12:05am UTC](https://community.auth0.com/t/accessing-user-metadata-in-auth0-action/79681/6 "2022-03-26T00:05:48Z")

</div>

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