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
| Param | Type | Validation | Notes |
|---|---|---|---|
id | string (UUID) | ParseUUIDPipe | The notification to delete |
No body.
| Header | Required | Notes |
|---|---|---|
Authorization: Bearer <accessToken> | โ | JWT from POST /auth/login |
Response
200 OK โ SuccessOnlyResponseDto
{
"success": true
}| Field | Type | Notes |
|---|---|---|
success | boolean | Always true on 200 |
Errors
| HTTP | code / i18nKey | Reason |
|---|---|---|
400 | (validation) | id not a valid UUID |
401 | (guard) | Missing / invalid bearer token |
404 | error.notification.not_found | Notification not found OR belongs to a different user (same code on purpose) |
429 | (throttle) | Rate limit exceeded (60 req/min) |
Side effects
- Ownership-aware lookup โ
prisma.notification.findFirst({ where: { id, userId } }). Returnsnullfor missing OR cross-user โ thrownot_found. prisma.notification.delete({ where: { id } }).- 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
Authorization
bearer In: header
Path Parameters
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
| Source | Path | Lines |
|---|---|---|
| Controller (inline impl) | apps/api-core/src/modules/notification/user-notification.controller.ts | 196โ210 (deleteNotification โ direct Prisma, ownership-aware findFirst) |
| DTO (response) | apps/api-core/src/common/dto/common-response.dto.ts | SuccessOnlyResponseDto |
| Prisma model | packages/prisma/prisma/schema.prisma | Notification |
Mark All Notifications Read
Bulk-flip every unread notification for the calling user to read=true. Returns the count actually updated. Scoped to caller โ no cross-user leak.
Get Notification Preferences
Per-event channel matrix (email / push / in-app / webPush / SMS) merged from system defaults plus user overrides. The customized flag tells the UI whether each row is user-modified.