Notification API Reference

API endpoints for the notification system

Overview

Notification API endpoints live under apps/zooly-app/app/api/notifications/. All user-facing endpoints require cookie-based authentication via resolveAccountId. All endpoints support CORS based on ALLOWED_DOMAINS_CORS.


List Notifications

Returns recent notifications and unread count for the authenticated user.

Endpoint: GET /api/notifications/list

Auth: Required (cookie-based)

Query Parameters:

ParamTypeDefaultDescription
limitnumber5Max notifications to return (max: 50)

Response (200):

FieldTypeDescription
notificationsNotification[]Recent notifications, newest first
unreadCountnumberTotal unread notifications for this account

Errors: 401 — not authenticated

Implementation: apps/zooly-app/app/api/notifications/list/route.ts


Mark Notifications as Read

Marks one or all notifications as read for the authenticated user.

Endpoint: POST /api/notifications/mark-read

Auth: Required (cookie-based)

Request Body — one of:

FieldTypeDescription
notificationIdstringMark a single notification as read
alltrueMark all notifications as read

Response (200): { success: true }

Errors:

  • 400 — neither notificationId nor all provided
  • 404 — notification not found or does not belong to the authenticated user

Implementation: apps/zooly-app/app/api/notifications/mark-read/route.ts


Process Email Notifications (Cron)

Picks up unsent notification emails, resolves recipient email via Cognito, and sends via SendGrid.

Endpoint: GET /api/notifications/process-emails

Auth: None (designed for cron scheduler)

Behavior:

  1. Fetches up to 20 notifications where emailSent = false
  2. For each notification, looks up the account's ownerUserId and calls Cognito AdminGetUser to get the email
  3. Sends email via sendNotificationEmail() from @zooly/app-srv
  4. On success, calls markEmailSent(notificationId) to prevent re-sending
  5. Failed sends are logged but do not block processing of remaining notifications

Response (200):

FieldTypeDescription
processednumberTotal notifications attempted
sentnumberEmails successfully sent
skippednumberNotifications with no resolvable email
failednumberSendGrid send failures

Implementation: apps/zooly-app/app/api/notifications/process-emails/route.ts