BIO.RE
Notifications

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.

HeaderRequiredNotes
Authorization: Bearer <accessToken>โœ“JWT from POST /auth/login

Response

200 OK โ€” ApiResponseOf<ClearReadResponseDto>

{
  "success": true,
  "data": {
    "deleted": 12
  }
}
FieldTypeNotes
deletednumberCount of read rows actually removed. 0 is a normal result.

Errors

HTTPcode / i18nKeyReason
401(guard)Missing / invalid bearer token
429(throttle)Rate limit exceeded (60 req/min)

Side effects

  1. prisma.notification.deleteMany({ where: { userId, read: true } }).
  2. Return { deleted: result.count }.
  3. 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

DELETE
/api/v1/notifications/clear-read
AuthorizationBearer <token>

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

SourcePathLines
Controller (inline impl)apps/api-core/src/modules/notification/user-notification.controller.ts184โ€“193 (clearReadNotifications โ€” direct Prisma deleteMany)
DTO (response)apps/api-core/src/modules/notification/dto/notification-client-response.dto.ts87โ€“90 (ClearReadResponseDto)
Prisma modelpackages/prisma/prisma/schema.prismaNotification

On this page