# How long before updated user info visible through Management API search?

**URL:** <https://community.auth0.com/t/how-long-before-updated-user-info-visible-through-management-api-search/182081>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [February 13, 2025, 1:38am UTC](https://community.auth0.com/t/how-long-before-updated-user-info-visible-through-management-api-search/182081 "2025-02-13T01:38:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![richardcarrigan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/richardcarrigan/32/71529_2.png) [@richardcarrigan](https://community.auth0.com/u/richardcarrigan)\
**Post date:** [February 13, 2025, 1:38am UTC](https://community.auth0.com/t/how-long-before-updated-user-info-visible-through-management-api-search/182081/1 "2025-02-13T01:38:36Z")

</div>

In my Next.js app (using the app router if that matters), I regularly need to update the `app_metadata` and/or `user_metadata`, which is working as expected. However, afterwards, I want to refresh the list of users within my app with their current data (e.g., updated `accountStatus` field within their `app_metadata`), but it’s not updating. I understand that getting a list of users is “eventually consistent”, but what is the reasonable amount of time before consistency is guaranteed? As of right now, I’m still not seeing updates that were made yesterday!

Update user code

```auto
// app/api/users/[id]/route.js

import { ManagementClient } from 'auth0';

// Update a user
export async function PUT(request, { params }) {
    try {
        const body = await request.json();
        const { id } = params;

        const management = new ManagementClient({
            domain: process.env.AUTH0_DOMAIN,
            clientId: process.env.AUTH0_CLIENT_ID,
            clientSecret: process.env.AUTH0_CLIENT_SECRET
        });

        const updatedUser = await management.users.update({ id }, body);

        return new Response(JSON.stringify({ message: 'User updated successfully' }), { status: 201 }); // 201 Created
    } catch(error) {
        console.error('User update error:', error);
        return new Response(JSON.stringify({ message: 'User update failed' }), { status: 500 }); // Generic fallback
    }
}

```

Get users code

```auto
// app/api/users/route.js

import { ManagementClient } from 'auth0';

// Get all users
export async function GET() {
    const management = new ManagementClient({
        domain: process.env.AUTH0_DOMAIN,
        clientId: process.env.AUTH0_CLIENT_ID,
        clientSecret: process.env.AUTH0_CLIENT_SECRET
    });

    const getAllUsersResponse = await management.users.getAll();
    return Response.json(getAllUsersResponse.data);
}

```

---

<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 13, 2025, 11:49pm UTC](https://community.auth0.com/t/how-long-before-updated-user-info-visible-through-management-api-search/182081/3 "2025-02-13T23:49:58Z")

</div>

Hi @richardcarrigan,

The updated user info should be available immediately after an update using the Management API.

I performed a test using the [Management API](https://auth0.com/docs/api/management/v2) to update the user’s `app_metadata` and get the user profile afterward. In my result, I saw the updated `app_metadata` information in their user profile.

I called the **Update a user** , **Get a user** , and **List or Search Users** endpoints and got the updated information in the user’s profile.

For example, if the user data had the following:

```auto
{
  app_metadata: {
    "accountStatus": "inactive"
  }
}

```

Then, to update the `"accountStatus"` value to something else, you would pass the following:

```auto
{
  app_metadata: {
    "accountStatus": "active"
  }
}

```

After reviewing your code, I noticed that the `id` may not be properly referenced.

I recommend improving the readability of your code by doing something like the following:

```auto
const userId = 'auth0|1234567890';
const body = {
  app_metadata: {
    "accountStatus": "active"
  }
};
const updatedUser = await management.users.update({ id: userId }, body);

```

(Reference: [UsersManager | auth0](https://auth0.github.io/node-auth0/classes/management.UsersManager.html#update))

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![richardcarrigan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/richardcarrigan/32/71529_2.png) [@richardcarrigan](https://community.auth0.com/u/richardcarrigan)\
**Post date:** [February 14, 2025, 12:52am UTC](https://community.auth0.com/t/how-long-before-updated-user-info-visible-through-management-api-search/182081/4 "2025-02-14T00:52:39Z")

</div>

Thanks for the quick reply, @rueben.tiow , but this is not a solution. As I said, the update is working as expected, so refactoring for readability isn’t going to fix anything. My get users request is also successful in the sense that I receive a list of users, but the data isn’t current. I’m actually still not seeing changes made since 2 days ago now, so maybe there’s an issue with my tenant configuration?

FWIW, here’s an example request being sent to my API route to update the user:

```auto
// components/UserList.jsx

async function approveAccount(userId) {
  const response = await fetch(`/api/users/${userId}`, {
    method: 'PUT',
    body: JSON.stringify({
      app_metadata: {
        accountStatus: 'approved'
      }
    })
  });
}

```

P.S. - I’m not sure if this helps with diagnosing the issue, but I also don’t see new users that were created yesterday through the Management API, so something is definitely wrong, either with my code (not sure what it could be though) or with my tenant/account config. Does it matter that I’m on a Free account and/or creating fictitious users?

---

<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 14, 2025, 11:43pm UTC](https://community.auth0.com/t/how-long-before-updated-user-info-visible-through-management-api-search/182081/5 "2025-02-14T23:43:43Z")

</div>

Hi @richardcarrigan,

Thanks for the update.

Can you confirm if you see those updated changes after updating the user and checking their user profile on the Dashboard?

Or vice versa, if you make changes to the user’s profile on the Dashboard, can you see those changes when calling the Get a user endpoint?

As an additional test, could you try using the Management API [Update a user endpoint](https://auth0.com/docs/api/management/v2/users/patch-users-by-id) and [Get a user endpoint](https://auth0.com/docs/api/management/v2/users/get-users-by-id) to see if the updates to the user profile work as expected?

Let me know your findings.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![richardcarrigan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/richardcarrigan/32/71529_2.png) [@richardcarrigan](https://community.auth0.com/u/richardcarrigan)\
**Post date:** [February 19, 2025, 4:03am UTC](https://community.auth0.com/t/how-long-before-updated-user-info-visible-through-management-api-search/182081/6 "2025-02-19T04:03:57Z")

</div>

Ok, I think we’re getting closer to identifying the root cause. Updating the user through the Management API works fine (i.e., I can see the change in the dashboard). However, I’m unable to see the updated user info from my app, whether using the `users.get` method for a single user or the `users.getAll` method for all users, but I am able to see the updated user info when using the Get a user endpoint. Here’s the relevant code:

```auto
// app/api/users/route.js

import { ManagementClient } from 'auth0';

// Get all users
export async function GET() {
    const management = new ManagementClient({
        domain: process.env.AUTH0_DOMAIN,
        clientId: process.env.AUTH0_CLIENT_ID,
        clientSecret: process.env.AUTH0_CLIENT_SECRET
    });

    const getAllUsersResponse = await management.users.getAll();
    return Response.json(getAllUsersResponse.data);
}

```

```auto
// app/api/users/route.js

import { ManagementClient } from 'auth0';

// Get a single user
export async function GET(request, { params }) {
    const { id } = params;

    const management = new ManagementClient({
        domain: process.env.AUTH0_DOMAIN,
        clientId: process.env.AUTH0_CLIENT_ID,
        clientSecret: process.env.AUTH0_CLIENT_SECRET
    });

    const getUserResponse = await management.users.get({ id });
    return Response.json(getUserResponse.data);
}

```

---

<div class="post-metadata">

**Author:** ![richardcarrigan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/richardcarrigan/32/71529_2.png) [@richardcarrigan](https://community.auth0.com/u/richardcarrigan)\
**Post date:** [February 21, 2025, 7:01am UTC](https://community.auth0.com/t/how-long-before-updated-user-info-visible-through-management-api-search/182081/7 "2025-02-21T07:01:44Z")

</div>

I finally figured it out. It turns out that the data was being cached in the browser due to how my Next.js app was configured. After upgrading from Next.js v14 to v15, the issue has been resolved.

---

<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 7, 2025, 7:01am UTC](https://community.auth0.com/t/how-long-before-updated-user-info-visible-through-management-api-search/182081/8 "2025-03-07T07:01:49Z")

</div>

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