# Update User

Update a user's email address or password. At least one field must be provided.

## Overview

Use this endpoint to allow users to change their email or reset their password from an account settings screen. The request body requires at least one of `email` or `password` — you only need to send the fields that should change.

This endpoint operates on any user by UUID, making it suitable for both self-service (user updating their own account) and admin-driven updates.

### `PUT /v1/users/{id}`

Authentication: bearer token required.

Updates a user's email or password. At least one field required.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | User UUID |

**Request body**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | string | no | New email address |
| `password` | string | no | New password (min 8 characters) |

**Responses**

`200` OK

```json
{ "id": "uuid", "username": "alice", "email": "new@example.com" }
```

`400` Bad Request

```json
{ "detail": "At least one field (email or password) must be provided" }
```

`404` Not Found

```json
{ "detail": "User not found" }
```

## Implementation

```javascript
// Account settings — update email
async function updateUserEmail(token, userId, newEmail) {
  const res = await fetch(`https://api.aureahub.com/v1/users/${userId}`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${token}`
    },
    body: JSON.stringify({ email: newEmail })
  });
  if (!res.ok) throw new Error((await res.json()).detail);
  return res.json();
}

// Change password
async function changePassword(token, userId, newPassword) {
  const res = await fetch(`https://api.aureahub.com/v1/users/${userId}`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${token}`
    },
    body: JSON.stringify({ password: newPassword })
  });
  if (!res.ok) throw new Error((await res.json()).detail);
  return res.json();
}
```

---

Web version: https://docs.aureahub.com/#users-update
