# Updating a single user's information

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

To change, or update, a user's information, a PATCH request needs to be made. In thise scenario, we'll update a user's status programmatically. To do so, we'll need to:

-   Find our user using a query parameter
-   Send the appropiate status ID
-   Send a PATCH request to the [update a user's status](/docs/api/contact-center/#tag/users/patch/contact_center/users/{userId}/status) endpoint.

We'll use a helper function to do the first task:

**Find and set user ID on component mount sample**

```javascript
let userId;
const useEffect(() => {
  const userEmail = new URLSearchParams(window.location.search).get('email');
  userId = (JSON.parse(localStorage.getItem("users"))).find(u => u.email === userEmail).id;
}, [])
```

With our user ID identified, we can update their status based on input:

**Function to make PATCH request, with user ID appended to endpoint URL sample**

```javascript
const UpdateStatus = async (e) => {
    e.preventDefault();
    try {
        const data = await fetch(
            `https://api.zoom.us/v2/contact_center/users/${userId}/status`,
            {
                method: "PATCH",
                headers: {
                    "Content-Type": "application/json",
                    Authorization: "Bearer YOUR_SECRET_TOKEN",
                },
                body: JSON.stringify({
                    status_id: statusId,
                }),
            },
        );
    } catch (error) {
        console.log(`Error: ${error.message}`);
    }
};
```

> **Demo vs. best practices**:
>
> -   Users are presumably stored in local storage here, but it's best to use a connected database in enterprise-level scnenarios
> -   Built-in logic is assumed to use a URL parameter to find the user. There are multiple ways to implement user identifcation, and a best-fitting flow should be decided on for each use-case
> -   The above code uses a hard-coded status ID. It's best to have status ID's easily accessible, on or offline, for either dynamic or manual input.

<ChildNavigator sidebarName="contact-center" targetKey="managing-users" />
