NapX PMS Docs

Notifications

Notification delivery and preference management in NapX PMS.

Notifications

NapX PMS sends transactional notifications for key reservation and access-code events. Delivery is handled asynchronously via a BullMQ queue with automatic retry, and tenants can opt out of specific notification types per channel.

Channel support: email is fully active (AWS SES). sms has provider backing (AWS SNS, gated by SES_FROM_ADDRESS) and processor dispatch, but no event listeners currently enqueue SMS notifications. push and in_app are schema-defined but have no provider implementation.

Endpoints

MethodPathDescription
GET/v1/notificationsList notifications for the tenant (paginated)
GET/v1/notifications/preferencesGet all notification preferences for the tenant
PATCH/v1/notifications/preferencesUpsert a notification preference (opt in or opt out)

Response Shape — Notification

FieldTypeDescription
iduuidNotification ID
tenantIduuidOwning tenant
recipientIduuid | nullRecipient user/guest ID; null for system-audience notifications
recipientTypestringAudience class: user, guest, admin, or system
templateKeystringTemplate identifier (see known templates below)
channelstringDelivery channel (e.g. email)
subjectstring | nullEmail subject line
bodystringRendered notification body
statusstringDelivery status (pending, sent, failed)
sentAtISO 8601 | nullWhen the notification was successfully delivered
createdAtISO 8601 stringEnqueue timestamp

BullMQ Queue with Retry

Notifications are never sent synchronously. When a domain event fires (e.g. reservation checked in), NotificationListenerService enqueues a job in BullMQ's notifications queue. The processor:

  1. Calls db.setTenantContext(job.data.tenantId) to enforce row-level security on all DB reads.
  2. Checks NotificationPreference — skips delivery if the tenant has opted out for the (templateKey, channel) combination.
  3. Renders the appropriate email template.
  4. Calls the NOTIFICATION_ADAPTER to dispatch via SES (email) or SNS (sms). When SES_FROM_ADDRESS is unset, a DisabledNotificationAdapter logs a warning instead of sending.

BullMQ handles backoff and retry automatically for transient failures (SES throttling, network errors). Permanent failures are logged and the Notification row is updated to status: 'failed'.

Notification Preferences

Preferences allow per-tenant opt-outs at the (templateKey, channel) level. A PATCH to /v1/notifications/preferences upserts a preference row:

PATCH /v1/notifications/preferences
Authorization: Bearer <session-token>
Content-Type: application/json

{
  "templateKey": "checkin_reminder",
  "channel": "email",
  "enabled": false
}

When a preference with enabled: false exists for a (templateKey, channel) pair, the processor skips delivery for that combination. When no preference row exists, the notification is sent (all notifications default to enabled).

For the operator account settings screen, the app updates these email preference templates:

  • check_in_alerts
  • nightly_summary
  • marketing_emails

Known Template Keys

templateKeyTrigger
checkin_reminderReservation checked in
checkout_summaryReservation checked out
reservation_cancelledReservation cancelled
access_code_deliveryAccess code created

Recipient Types

recipientTypeMeaning
userA platform user with a user account
guestA guest without a platform account
adminAn admin-level recipient
systemSystem-generated notification (no human recipient)

Security Model

  • Every request requires Authorization: Bearer <session-token>.
  • Tenant context is derived from validated auth claims; callers only see notifications for their tenant.

Error Handling

  • 400 Bad Request when channel is not one of email, sms, push, in_app.
  • 401 Unauthorized when the bearer token is missing or invalid.

Example — List Recent Notifications

GET /v1/notifications?limit=20&offset=0
Authorization: Bearer <session-token>

See the API reference for the detailed endpoint contract.

On this page