Clear Read Notifications
Bulk-delete every read notification for the calling user. Returns the count actually deleted. Unread rows are untouched.
DELETE /api/v1/notifications/clear-read โ ๐ Bearer ยท Rate limit: 60 req / minute
Bulk-deletes every read notification (read = true) for the calling user via a single deleteMany. Unread rows are untouched. Returns the count actually deleted (zero is a normal result if nothing was read yet).
Hard delete, no undo. This is the bulk equivalent of DELETE /notifications/:id for read items. Once deleted, the rows are gone โ no recycle bin. If you want to keep a "see all" feed, don't expose this as a one-click action; gate it behind a confirm dialog.
No filtering parameters. This endpoint deletes all read notifications. There is no "delete read older than N days" or "delete read for event X". For scoped deletes, iterate DELETE /:id per item from the filtered list.
Request
No body, no params. Identity comes from the bearer token.
| Header | Required | Notes |
|---|---|---|
Authorization: Bearer <accessToken> | โ | JWT from POST /auth/login |
Response
200 OK โ ApiResponseOf<ClearReadResponseDto>
{
"success": true,
"data": {
"deleted": 12
}
}| Field | Type | Notes |
|---|---|---|
deleted | number | Count of read rows actually removed. 0 is a normal result. |
Errors
| HTTP | code / i18nKey | Reason |
|---|---|---|
401 | (guard) | Missing / invalid bearer token |
429 | (throttle) | Rate limit exceeded (60 req/min) |
Side effects
prisma.notification.deleteMany({ where: { userId, read: true } }).- Return
{ deleted: result.count }. - Unread rows are not touched (filter excludes them).
Code samples
curl -X DELETE https://api.bio.re/api/v1/notifications/clear-read \
-H "Authorization: Bearer $ACCESS_TOKEN"async function clearReadNotifications(accessToken: string): Promise<number> {
const res = await fetch('https://api.bio.re/api/v1/notifications/clear-read', {
method: 'DELETE',
headers: { Authorization: `Bearer ${accessToken}` },
});
const json = await res.json();
if (!res.ok || !json.success) {
throw Object.assign(new Error(json?.error?.message ?? 'Clear read failed'), {
code: json?.error?.code,
});
}
return json.data.deleted as number;
}import { useMutation, useQueryClient } from '@tanstack/react-query';
export function useClearReadNotifications() {
const qc = useQueryClient();
return useMutation({
mutationFn: async () => {
const res = await fetch('/api/v1/notifications/clear-read', { method: 'DELETE' });
const json = await res.json();
if (!res.ok || !json.success) {
throw Object.assign(new Error(json?.error?.message ?? 'Clear read failed'), {
code: json?.error?.code,
i18nKey: json?.error?.i18nKey,
});
}
return json.data.deleted as number;
},
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['notifications'] });
},
});
}Try it
Authorization
bearer In: header
Response Body
application/json
application/json
curl -X DELETE "https://loading/api/v1/notifications/clear-read"{
"success": true,
"data": {
"deleted": 0
}
}{
"success": false,
"error": {
"code": "AUTH_UNAUTHORIZED",
"message": "Invalid credentials",
"i18nKey": "auth.login.invalid_credentials",
"i18nVars": {
"field": "email"
},
"details": [
{
"message": "email must be an email"
}
],
"correlationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
}Source
| Source | Path | Lines |
|---|---|---|
| Controller (inline impl) | apps/api-core/src/modules/notification/user-notification.controller.ts | 184โ193 (clearReadNotifications โ direct Prisma deleteMany) |
| DTO (response) | apps/api-core/src/modules/notification/dto/notification-client-response.dto.ts | 87โ90 (ClearReadResponseDto) |
| Prisma model | packages/prisma/prisma/schema.prisma | Notification |
Update Notification Preference
Save the user's per-channel override for a single event. Upserts a NotificationPreference row. eventKey must exist in the admin-managed defaults catalog.
Email Unsubscribe (Public)
Public HMAC-token endpoint reachable from email footers without login. Adds the email to the suppression list AND disables the email channel in every event preference for the matching user.