Skip to main content

NotificationApiClient

Accessed via client.notifications().

Methods

send

send(request: NotificationRequest): Promise<NotificationResponse>

Equivalent to sendWithIdempotency(request) with no idempotency key.

sendWithIdempotency

sendWithIdempotency(request: NotificationRequest, idempotencyKey?: string): Promise<NotificationResponse>

Sends with a caller-supplied idempotency key, forwarded as the Idempotency-Key header.

sendBulk

sendBulk(requests: NotificationRequest[]): Promise<Record<string, any>>
search(channel: ChannelType | null, status: string | null, limit: number, offset: number): Promise<NotificationReceipt[]>

get

get(notificationId: string): Promise<NotificationReceipt>

getReceipts

getReceipts(notificationId: string): Promise<Record<string, any>>

cancelSchedule

cancelSchedule(taskId: string): Promise<Record<string, string>>

trackOpen

trackOpen(notificationId: string): Promise<ArrayBuffer>

Fetches the open-tracking pixel bytes. This request is unsigned — see Tracking.

Types

NotificationResponse

interface NotificationResponse {
notificationId: string;
idempotencyKey: string;
status: string;
dispatchedChannels: Record<string, string>[];
}

NotificationReceipt

interface NotificationReceipt {
notificationId: string;
tenantId: string;
channel: string;
currentStatus: string;
firstOpenedAt: string;
lastOpenedAt: string;
openCount: number;
createdAt: string;
updatedAt: string;
clickCount: number;
lastClickedAt: string;
}

Timestamps are ISO 8601 strings, matching how they're serialized over JSON.

NotificationRequestBuilder

MethodDescription
addChannel(channel: ChannelType)Adds a dispatch channel. Call once per channel.
toEmail(email: string)Sets the email recipient.
toPhone(phone: string)Sets the SMS recipient.
toWebhook(url: string)Sets the webhook target URL.
toPushToken(token: string)Sets a device push token target.
toPushTopic(topic: string)Sets a push topic target.
toInApp(userId: string)Sets the in-app recipient user ID.
withMediaUrl(imageUrl: string)Attaches a media/image URL.
withActionUrl(actionUrl: string)Attaches an action URL.
templateId(templateId: string)Renders content from a saved template.
subject(subject: string)Inline subject (email/push).
message(message: string)Inline message body.
addVariable(key: string, value: any)Adds a template/render variable.
scheduleFor(date: Date)Defers delivery to a future time; serialized as ISO 8601.
build()Returns a NotificationRequest. Throws if no channel was added.

Throws

All methods return a rejected Promise with a NotificationHubError (or typed subclass) on a non-OK response — see Exceptions.