Skip to main content

Notifications

The notification system provides multi-channel notifications (push, in-app, email, SMS, chat) powered by Novu. All notification endpoints are available through the KrakenD API gateway.

Concepts

TermDescription
ChannelDelivery method: PUSH, IN_APP, EMAIL, SMS, CHAT
SubscriberA user registered to receive notifications
TopicA named group of subscribers for fan-out delivery
WorkflowA notification template defining content and delivery steps
DigestBatching strategy that groups notifications before delivery
ProviderExternal service for delivery (FCM, APNS, SendGrid, Twilio, etc.)

Architecture

The NotificationGatewayService extracts authentication context from request headers (X-User-ID, X-Tenant-ID) and forwards requests to the downstream NotificationService, which owns the Novu integration.

Endpoint Paths

User-facing endpoints use /api/v1/notifications/, while admin/management endpoints use /api/v1/notifications/manage/.

Push Device Registration

Register a device to receive push notifications via FCM.

Register a Device

POST /api/v1/notifications/register-push-device
{
"fcmToken": "firebase-cloud-messaging-token",
"platform": "IOS",
"deviceId": "device-unique-id"
}
FieldTypeDescription
fcmTokenstringFirebase Cloud Messaging token
platformenumIOS, ANDROID, or WEB
deviceIdstringUnique device identifier

Unregister a Device

POST /api/v1/notifications/unregister-push-device
{
"fcmToken": "firebase-cloud-messaging-token"
}

Get Registered Channels

Check which notification channels are available for the current user.

POST /api/v1/notifications/get-registered-channels
{}

Response:

{
"channels": [
{"channel": "PUSH", "registered": true, "credentialCount": 2},
{"channel": "IN_APP", "registered": true, "credentialCount": 1},
{"channel": "EMAIL", "registered": false, "credentialCount": 0}
]
}

Sending Notifications

Send Immediately

POST /api/v1/notifications/manage/send
{
"userId": "recipient-user-id",
"channel": "PUSH",
"category": "TRANSACTIONAL",
"content": {
"title": "New Message",
"body": "You have a new coaching update",
"data": {"screen": "conversation", "id": "conv_abc"},
"deepLink": "socayo://conversation/conv_abc"
},
"idempotencyKey": "unique-key-123"
}

Response:

{
"transactionId": "txn_abc123"
}
FieldTypeDescription
userIdstringRecipient user ID
channelenumPUSH, IN_APP, EMAIL, SMS, CHAT
categoryenumSYSTEM, TRANSACTIONAL, PRODUCT, PROMOTIONAL
contentobjectNotification content (title, body, data, deepLink, imageUrl)
idempotencyKeystringPrevents duplicate sends

Send Scheduled

Schedule a notification for a specific time.

POST /api/v1/notifications/manage/send-scheduled
{
"userId": "recipient-user-id",
"channel": "PUSH",
"category": "PRODUCT",
"content": {
"title": "Weekly Summary",
"body": "Your health coaching summary is ready"
},
"scheduledAt": "2026-03-20T09:00:00Z",
"timezone": "America/New_York"
}

Send Delayed

Queue a notification for delivery after a delay (1–86,400 seconds).

POST /api/v1/notifications/manage/send-delayed
{
"userId": "recipient-user-id",
"channel": "IN_APP",
"category": "TRANSACTIONAL",
"content": {
"title": "Follow-up",
"body": "How did your workout go?"
},
"delaySeconds": 3600
}

Send Bulk

Fan-out to up to 100 users in a single call.

POST /api/v1/notifications/manage/send-bulk
{
"userIds": ["user-1", "user-2", "user-3"],
"channel": "PUSH",
"category": "PRODUCT",
"content": {
"title": "New Feature",
"body": "Check out our latest update"
}
}

Cancel a Notification

Cancel a pending, delayed, or scheduled notification.

POST /api/v1/notifications/manage/cancel
{
"transactionId": "txn_abc123"
}

In-App Inbox

Get Inbox Session

Get a Novu session token and WebSocket URL for direct client access to the inbox.

POST /api/v1/notifications/get-inbox-session
{}

Response:

{
"sessionToken": "novu-session-jwt",
"apiUrl": "https://novu-api.internal:3000",
"wsUrl": "https://novu-ws.internal:3002"
}

Use the session token to connect directly to the Novu WebSocket for real-time inbox updates.

Get Inbox Feed

POST /api/v1/notifications/get-inbox-feed
{
"page": 1,
"pageSize": 20,
"feedIds": ["default"],
"categories": ["TRANSACTIONAL", "PRODUCT"]
}

Response:

{
"messages": [
{
"messageId": "msg_123",
"notificationId": "notif_abc",
"title": "New Message",
"body": "You have a coaching update",
"data": {"screen": "conversation"},
"deepLink": "socayo://conversation/conv_abc",
"status": "UNSEEN",
"category": "TRANSACTIONAL",
"createdAt": "2026-03-18T10:00:00Z"
}
],
"hasMore": true
}

Get Unseen Count

POST /api/v1/notifications/get-inbox-unseen-count

Response:

{
"unseenCount": 5,
"unreadCount": 12
}

Mark Messages

Mark a single message:

POST /api/v1/notifications/mark-inbox-message
{
"messageId": "msg_123",
"status": "READ"
}

Mark all messages:

POST /api/v1/notifications/mark-all-inbox-messages
{
"status": "SEEN",
"feedIds": ["default"]
}

Status options: SEEN, READ, UNSEEN, UNREAD.

Delete Inbox Message

POST /api/v1/notifications/delete-inbox-message
{
"messageId": "msg_123"
}

Preferences

Users can opt in/out of notification channels and categories.

Get Preferences

POST /api/v1/notifications/get-preferences

Response:

{
"preferences": [
{
"channel": "PUSH",
"channelEnabled": true,
"categories": {
"TRANSACTIONAL": true,
"PRODUCT": true,
"PROMOTIONAL": false
}
}
]
}

Update Preferences

POST /api/v1/notifications/update-preferences
{
"channel": "PUSH",
"category": "PROMOTIONAL",
"enabled": false
}
info

Notifications with category SYSTEM bypass preferences — they are always delivered regardless of user settings.

Topics

Topics enable pub/sub-style fan-out delivery. Create a topic, subscribe users, then send to all subscribers.

Create a Topic

POST /api/v1/notifications/manage/create-topic
{
"topicKey": "weekly-updates"
}

Add/Remove Subscribers

POST /api/v1/notifications/manage/add-subscribers-to-topic
{
"topicKey": "weekly-updates",
"subscriberIds": ["user-1", "user-2"]
}

Up to 100 subscribers per call.

POST /api/v1/notifications/manage/remove-subscribers-from-topic
{
"topicKey": "weekly-updates",
"subscriberIds": ["user-1"]
}

Send to Topic

POST /api/v1/notifications/manage/send-to-topic
{
"topicKey": "weekly-updates",
"channel": "PUSH",
"category": "PRODUCT",
"content": {
"title": "Weekly Update",
"body": "Your weekly health summary is ready"
},
"excludeUserIds": ["user-admin"]
}

List Topic Subscribers

POST /api/v1/notifications/manage/list-topic-subscribers
{
"topicKey": "weekly-updates",
"page": 1,
"pageSize": 50
}

Check Subscription

POST /api/v1/notifications/manage/check-topic-subscription
{
"topicKey": "weekly-updates",
"subscriberId": "user-1"
}

Digest / Batching

Group notifications before delivery using a digest strategy.

POST /api/v1/notifications/manage/send-with-digest
{
"userId": "user-1",
"channel": "EMAIL",
"category": "PRODUCT",
"content": {
"title": "Activity Update",
"body": "New activity in your coaching plan"
},
"digestConfig": {
"strategy": "REGULAR",
"windowSeconds": 3600,
"digestKey": "coaching-updates"
}
}
StrategyDescription
REGULARBatch events within a time window (windowSeconds)
LOOK_BACKCheck for recent events before creating a new digest
SCHEDULEDDeliver on a cron schedule (cronExpression, timezone)

Cancel a digest event:

POST /api/v1/notifications/manage/cancel-digest-event
{
"transactionId": "txn_abc123"
}

Subscriber Management

Create Subscriber

POST /api/v1/notifications/manage/create-subscriber
{
"userId": "user-1",
"subscriberData": {
"firstName": "Jane",
"lastName": "Doe",
"email": "jane@example.com",
"phone": "+1234567890",
"locale": "en-US",
"timezone": "America/New_York"
}
}

Get / Update / Delete Subscriber

POST /api/v1/notifications/manage/get-subscriber
{
"userId": "user-1"
}
POST /api/v1/notifications/manage/update-subscriber-data
{
"userId": "user-1",
"subscriberData": {
"email": "jane.updated@example.com",
"locale": "en-GB"
}
}
POST /api/v1/notifications/manage/delete-subscriber
{
"userId": "user-1"
}

List Subscribers

POST /api/v1/notifications/manage/list-subscribers
{
"page": 1,
"pageSize": 50
}

Workflow Management

Workflows define notification templates with steps and delivery preferences.

Create Workflow

POST /api/v1/notifications/manage/create-workflow
{
"workflow": {
"name": "Welcome Notification",
"description": "Sent when a user completes onboarding",
"active": true,
"critical": false,
"tags": ["onboarding"],
"steps": [
{
"channel": "IN_APP",
"title": "Welcome!",
"body": "Welcome to your health coaching journey"
},
{
"channel": "PUSH",
"title": "Welcome!",
"body": "Tap to start your first session"
}
],
"preferenceSettings": {
"email": true,
"push": true,
"inApp": true,
"sms": false,
"chat": false
}
}
}
info

Setting critical: true causes the workflow to bypass user preferences — use this only for essential system notifications.

Update / Get / List / Delete Workflow

POST /api/v1/notifications/manage/update-workflow
{
"workflowId": "wf_abc123",
"workflow": {
"name": "Welcome Notification v2",
"active": true
}
}
POST /api/v1/notifications/manage/get-workflow
POST /api/v1/notifications/manage/list-workflows
POST /api/v1/notifications/manage/delete-workflow

Provider Configuration

Configure external delivery providers (FCM, APNS, SendGrid, etc.).

POST /api/v1/notifications/manage/configure-provider
{
"providerType": "FCM",
"credentials": {
"serviceAccountJson": "{...}"
},
"active": true
}

Supported providers: FCM, APNS, SENDGRID, SES, TWILIO, SLACK, DISCORD.

POST /api/v1/notifications/manage/get-providers

Promotion (Dev → Prod)

Manage promotion of notification template changes from development to production.

POST /api/v1/notifications/manage/get-pending-changes
POST /api/v1/notifications/manage/promote-change
POST /api/v1/notifications/manage/promote-all-changes

Activity & Delivery Status

Get Delivery Status

Track the delivery status of a specific notification.

POST /api/v1/notifications/manage/get-delivery-status
{
"transactionId": "txn_abc123"
}

Response:

{
"transactionId": "txn_abc123",
"channel": "PUSH",
"result": "DELIVERED",
"providerMessageId": "fcm-msg-xyz",
"queuedAt": "2026-03-18T10:00:00Z",
"deliveredAt": "2026-03-18T10:00:02Z"
}
Delivery ResultDescription
SENTQueued for delivery
DELIVEREDSuccessfully delivered
RATE_LIMITEDThrottled by provider
OPTED_OUTUser opted out of this channel/category
NO_CHANNELNo registered device/channel
INVALID_CREDENTIALExpired or invalid FCM token
CANCELLEDCancelled before delivery
FAILEDDelivery failed

Get Notification Activity

Query delivery history with filtering.

POST /api/v1/notifications/manage/get-notification-activity
{
"channels": ["PUSH", "IN_APP"],
"categories": ["TRANSACTIONAL"],
"startTime": "2026-03-01T00:00:00Z",
"endTime": "2026-03-18T23:59:59Z",
"page": 1,
"pageSize": 50
}

RPC Summary

User-Facing (11 RPCs)

EndpointDescription
register-push-deviceRegister FCM token
unregister-push-deviceRemove FCM token
get-registered-channelsList available channels
get-inbox-sessionGet Novu session for WebSocket
get-inbox-feedPaginated inbox messages
get-inbox-unseen-countUnseen/unread counts
mark-inbox-messageMark single message status
mark-all-inbox-messagesBulk mark messages
delete-inbox-messageDelete inbox message
get-preferencesGet notification preferences
update-preferencesUpdate notification preferences

Admin/Management (31 RPCs)

EndpointDescription
manage/sendSend immediate notification
manage/send-scheduledSchedule notification
manage/send-delayedDelay notification
manage/send-bulkFan-out to multiple users
manage/cancelCancel pending notification
manage/send-to-topicSend to topic subscribers
manage/send-with-digestSend with digest batching
manage/cancel-digest-eventCancel digest event
manage/create-topicCreate topic
manage/delete-topicDelete topic
manage/add-subscribers-to-topicAdd subscribers to topic
manage/remove-subscribers-from-topicRemove from topic
manage/list-topic-subscribersList topic subscribers
manage/check-topic-subscriptionCheck subscription
manage/create-subscriberCreate subscriber
manage/get-subscriberGet subscriber details
manage/update-subscriber-dataUpdate subscriber data
manage/delete-subscriberDelete subscriber
manage/list-subscribersList subscribers
manage/create-workflowCreate workflow template
manage/update-workflowUpdate workflow
manage/get-workflowGet workflow details
manage/list-workflowsList workflows
manage/delete-workflowDelete workflow
manage/configure-providerConfigure delivery provider
manage/get-providersList active providers
manage/get-pending-changesList pending promotions
manage/promote-changePromote single change
manage/promote-all-changesPromote all changes
manage/get-delivery-statusTrack delivery status
manage/get-notification-activityQuery delivery history