Overview
Marks all of the authenticated user’s notifications as read in a single request. Useful for a “mark all as read” action in a notifications panel.
Endpoint
PUT /api/notifications/read-all
Request
This endpoint has no path parameters, query parameters, or request body.
Response
A confirmation string indicating all notifications were successfully marked as read.
Example
import { fetchWithAuth } from "./fetchWithAuth";
async function markAllNotificationsAsRead(): Promise<{ message: string }> {
const res = await fetchWithAuth(`/api/notifications/read-all`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
});
const data = await res.json();
if (!res.ok) {
throw new Error(data.error || "Failed to mark all notifications as read");
}
return data; // { message: string }
}