> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bbrands.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Preferencias e inbox

> La matriz de opt-out por usuario (notification_preference) y el inbox de notificaciones de cara al usuario.

## Preferencias del usuario

`notification_preference` es una tabla de overrides de opt-out. La **ausencia de una fila
significa habilitado por defecto**.

* Columnas: `user` (FK `auth.users.id`), `channel`, `category`, `is_enabled`.
* Índice único parcial `(user, channel, category) WHERE is_deleted = false`.
* El dispatcher lo verifica en `isSuppressed(...)` **antes** de encolar; ante un
  error de lectura *falla abierto* (la notificación no se pierde).

### API v3

| Método    | Ruta                                      | Permiso                            | Propósito                                        |
| --------- | ----------------------------------------- | ---------------------------------- | ------------------------------------------------ |
| GET       | `/v3/notification/preference`             | `notification-preference:find-all` | Listado paginado (admin).                        |
| POST      | `/v3/notification/preference`             | `notification-preference:create`   | Crear override (admin; acepta `user`).           |
| GET       | `/v3/notification/preference/{id}`        | `notification-preference:find-one` | Detalle.                                         |
| PUT       | `/v3/notification/preference/{id}`        | `notification-preference:update`   | Actualizar override.                             |
| DELETE    | `/v3/notification/preference/{id}`        | `notification-preference:delete`   | Soft-delete.                                     |
| PATCH     | `/v3/notification/preference/{id}/active` | `notification-preference:active`   | Activar / desactivar.                            |
| GET       | `/v3/notification/preference/me`          | `notification-preference:find-all` | Matriz efectiva canal×categoría.                 |
| PUT/PATCH | `/v3/notification/preference/me`          | `notification-preference:update`   | Upsert de un override para el usuario del token. |

<Note>
  `/me` resuelve al propietario desde el JWT y rechaza deshabilitar categorías no
  suprimibles con un `400`. Nunca acepta un campo `user`.
</Note>

## Inbox de notificaciones

El inbox es un registro agnóstico al idioma de lo que se entregó, respaldado por dos
tablas:

| Tabla                        | Propósito                                             |
| ---------------------------- | ----------------------------------------------------- |
| `user_notification`          | Una fila por notificación lógica mostrada al usuario. |
| `user_notification_delivery` | Registro de entrega por canal para esa notificación.  |

La API de lectura `/me` devuelve el inbox del usuario autenticado para el renderizado del cliente.
Consulta la pestaña [Schemas](/schemas/notification/user-notification) para la referencia completa de
columnas.
