> ## Documentation Index
> Fetch the complete documentation index at: https://help.impactu.colav.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Edit user

> Updates the email address and/or the role of a user. The admin role cannot be assigned and admin accounts cannot be edited.

> [!NOTE]
>
> Requires an active session with the `admin` role. Only active accounts that are not
> `admin` can be edited; otherwise it returns `403`.

## Path parameters

**email** `string` *required*

Current email address of the user to edit.

## Request body

At least one of the two fields is mandatory, and both must be text. Any other field returns `400`.

**email** `string`

New email address. If another user already uses it, it returns `409`.

**role** `string`

New role. It cannot be `admin`.

### Email change

Changing the email generates a new password and sends it to the new email; the old one stops working. The email is sent before the change is saved: if it cannot be sent, it returns `502` and the user keeps their email and password.

If only the role changes, no email is sent.

## Response

**success** `boolean`

`true` if the update succeeded.

**msg** `string`

Confirmation or error message.

```json 200 — role theme={null}
{ "success": true, "msg": "Rol del usuario usuario@example.com actualizado correctamente." }
```

```json 200 — email theme={null}
{
  "success": true,
  "msg": "Correo del usuario actualizado correctamente y notificación enviada a nuevo@example.com."
}
```

```json 400 theme={null}
{ "success": false, "msg": "Debes enviar al menos email o rol." }
```

```json 400 — no changes theme={null}
{ "success": false, "msg": "No se detectaron cambios para actualizar." }
```

```json 403 theme={null}
{ "success": false, "msg": "No se puede asignar el rol 'admin' a un usuario." }
```

```json 404 theme={null}
{ "success": false, "msg": "Usuario con correo usuario@example.com no encontrado." }
```

```json 409 theme={null}
{ "success": false, "msg": "Ya existe un usuario con el correo nuevo@example.com" }
```

```json 401 theme={null}
{"msg": "Token no proporcionado o inválido. Por favor, inicia sesión nuevamente.", "success": false}
```

```json 502 theme={null}
{ "success": false, "msg": "No se pudo enviar el correo con las credenciales. No se guardó ningún cambio." }
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.