BIO.RE
Notifications

Delete Notification

Hard-delete a single notification by id. Ownership-checked. There is no recycle bin or undo flow.

DELETE /api/v1/notifications/:id โ€” ๐Ÿ”‘ Bearer ยท Rate limit: 60 req / minute

Hard-deletes a single notification row. Ownership is enforced via findFirst({ id, userId }); missing or cross-user lookups return 404 not_found (same code โ€” no enumeration leak).

Hard delete, no undo. Once gone, the row is gone โ€” there's no recycle bin or "deleted" flag. To bulk-clear notifications you've already read, use DELETE /notifications/clear-read instead (covered in Batch 2).

Request

Path parameters

ParamTypeValidationNotes
idstring (UUID)ParseUUIDPipeThe notification to delete

No body.

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

Response

200 OK โ€” SuccessOnlyResponseDto

{
  "success": true
}
FieldTypeNotes
successbooleanAlways true on 200

Errors

HTTPcode / i18nKeyReason
400(validation)id not a valid UUID
401(guard)Missing / invalid bearer token
404error.notification.not_foundNotification not found OR belongs to a different user (same code on purpose)
429(throttle)Rate limit exceeded (60 req/min)

Side effects

  1. Ownership-aware lookup โ€” prisma.notification.findFirst({ where: { id, userId } }). Returns null for missing OR cross-user โ†’ throw not_found.
  2. prisma.notification.delete({ where: { id } }).
  3. Return { success: true }.

Code samples

curl -X DELETE https://api.bio.re/api/v1/notifications/n1a2b3c4-d5e6-7890-abcd-ef1234567890 \
  -H "Authorization: Bearer $ACCESS_TOKEN"
async function deleteNotification(accessToken: string, notificationId: string): Promise<void> {
  const res = await fetch(`https://api.bio.re/api/v1/notifications/${notificationId}`, {
    method: 'DELETE',
    headers: { Authorization: `Bearer ${accessToken}` },
  });
  const json = await res.json();
  if (!res.ok || !json.success) {
    throw Object.assign(new Error(json?.error?.message ?? 'Delete failed'), {
      code: json?.error?.code,
    });
  }
}
import { useMutation, useQueryClient } from '@tanstack/react-query';

export function useDeleteNotification() {
  const qc = useQueryClient();
  return useMutation({
    mutationFn: async (notificationId: string) => {
      const res = await fetch(`/api/v1/notifications/${notificationId}`, { method: 'DELETE' });
      const json = await res.json();
      if (!res.ok || !json.success) {
        throw Object.assign(new Error(json?.error?.message ?? 'Delete failed'), {
          code: json?.error?.code,
          i18nKey: json?.error?.i18nKey,
        });
      }
    },
    onSuccess: () => {
      qc.invalidateQueries({ queryKey: ['notifications'] });
    },
  });
}

Try it

DELETE
/api/v1/notifications/{id}
AuthorizationBearer <token>

In: header

Path Parameters

id*string

Response Body

application/json

application/json

application/json

curl -X DELETE "https://loading/api/v1/notifications/string"
{
  "success": true
}
{
  "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"
  }
}
{
  "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.ts196โ€“210 (deleteNotification โ€” direct Prisma, ownership-aware findFirst)
DTO (response)apps/api-core/src/common/dto/common-response.dto.tsSuccessOnlyResponseDto
Prisma modelpackages/prisma/prisma/schema.prismaNotification

On this page