Skip to content

@venturekit/notify API

FunctionDescription
createNotifyClient(options)Build the notify client (store, defaultFrom, providers, addressResolver)

NotifyClient interface (selected methods):

MethodDescription
enqueue(input: EnqueueInput)Write a notification to the outbox (the 99% case); returns EnqueueResult
sendNow(input: SendNowInput)Render + send immediately, bypassing the outbox/cron; returns SendNowResult
registerTemplate(template: NotifyTemplate)Register an in-code template (generic over the payload type)
registerTemplates(templates: NotifyTemplate[])Register many templates at once
registerProvider(provider: NotifyProvider)Register / override a channel provider

The client also exposes the configured store, templates, providers, defaultFrom, and addressResolver for use in admin handlers.

FunctionDescription
createPostgresNotifyStore(options?)Postgres-backed outbox store implementing NotifyStore
FunctionDescription
createSesEmailProvider(config)AWS SESv2 email provider
createMetaWhatsAppProvider(config)Meta Cloud API WhatsApp provider
createSecretsTokenResolver(options)Resolve a provider token from Secrets Manager
createEmailNoopProvider(options?)Log-only email provider (dev)
createMailHogProvider(config)SMTP provider targeting MailHog (local dev)
createSmsNoopProvider() / createPushNoopProvider()Placeholder providers

Errors: ProviderHardError, ProviderSendError.

FunctionDescription
dispatchOnce(options)Drain pending outbox rows once (used by the cron Lambda)
makeDispatchHandler(options?)Build the EventBridge cron dispatcher handler
makeBounceHandler(options?)Build the SNS bounce/complaint handler

Imported from @venturekit/notify/dispatcher and @venturekit/notify/bounce-handler.

Exported from @venturekit/notify/admin — wire into your own handlers:

FunctionDescription
adminListNotifications(client, options)Paginated list with status/channel/template/search filters
adminGetNotification(client, id)Fetch one notification
adminSendNotification(client, input)Enqueue (separate name for audit logging)
adminRetryNotification(client, id)Flip failed/bounced back to pending
adminCancelNotification(client, id)Cancel a pending row before dispatch
adminClearSuppression(client, channel, address)Lift a bounce/complaint suppression
listUserPreferences(client, userId) / upsertUserPreference(client, ...)Per-user opt-in management
listNotificationsForUser(client, userId, options)Buyer-portal inbox view
FunctionDescription
createTemplateRegistry()In-memory template registry (TemplateRegistry)

Errors: TemplateNotFoundError.

NotifyChannel, NotificationStatus, NotifyAddress, NotificationRow, NotificationPreferenceRow, NotificationEventLogRow, EnqueueInput, EnqueueResult, SendNowInput, SendNowResult, RenderedMessage, NotifyTemplate, NotifyClient, CreateNotifyClientOptions, AddressResolver, NotifyStore, NotifyProvider.