Accessing user_metadata in Auth0 Action

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

"user": {
    "id": "SOME_ID",
    "user_id": "899898",
    "email": "",
    "email_verified": true,
    "last_password_reset": "2022-03-10T19:08:03.417Z",
    "username": "some smith"

instead of the full-blown

"user": {
    "app_metadata": {},
    "created_at": "2022-03-10T19:13:33.919Z",
    "email_verified": true,
    "email": "",
    "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": "",
    "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?

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?

Hi @dheerajdhall2709,

Thanks for reaching out to the Auth0 Community!

That is correct. The Post Password Change Action 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? FAQ to learn how to do so.

Once that is complete, you can call the ManagementClient getUser method to get the user’s user_metadata.

Hoped this helps!

Please let me know if you have any additional questions.

Thank you.

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

1 Like

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