Skip to main content

Notification Providers

Notification providers handle sending notifications through various channels like email, SMS, push notifications, and more. They support both template-based and content-based notifications with attachments.

Available Notification Providers

Medusa includes two notification providers:

Local Notification Provider

@medusajs/medusa/notification-local - Logs notifications to the console. Use cases:
  • Development and testing
  • Debugging notification flows
  • Preview notification data

SendGrid Notification Provider

@medusajs/medusa/notification-sendgrid - Sends email notifications via SendGrid. Use cases:
  • Production email delivery
  • Transactional emails
  • Marketing emails
  • Template-based emails
Features:
  • Support for SendGrid templates
  • HTML email content
  • Email attachments
  • Dynamic template data

Installation

Both providers are included in the core Medusa package:
For SendGrid, also install the SendGrid SDK:

Configuration

Configure the local notification provider:
medusa-config.ts

Notification Provider Interface

All notification providers extend AbstractNotificationProviderService and implement the following method:

send(notification: ProviderSendNotificationDTO): Promise<ProviderSendNotificationResultsDTO>

Sends a notification. With HTML Content:
With SendGrid Template:
Parameters:
  • to - Recipient email address
  • channel - Notification channel (e.g., “email”, “sms”)
  • template - Template identifier (provider-specific)
  • from - Sender email (optional, uses default from config)
  • content - Notification content
    • subject - Email subject
    • html - HTML content
    • text - Plain text content (optional)
  • data - Dynamic data for templates
  • attachments - File attachments
    • filename - Attachment filename
    • content - Base64-encoded content
    • content_type - MIME type
    • disposition - “attachment” or “inline”
    • id - Content ID for inline images
SendGrid does not support mixing HTML content and templates. Use either content.html or template, not both.

Using the Notification Module

Access notification providers through the Notification Module:

Notification Workflows

Notifications are typically sent through workflows that handle specific events:

Common Notification Types

Order Confirmation

Shipment Notification

Password Reset

Creating Custom Notification Providers

Create a custom notification provider by extending AbstractNotificationProviderService:
packages/modules/providers/notification-custom/src/services/custom-notification.ts

SMS Provider Example

packages/modules/providers/notification-sms/src/services/sms-notification.ts
Register your custom provider:
packages/modules/providers/notification-custom/src/index.ts

Reference

  • Local Provider: packages/modules/providers/notification-local/src/services/local.ts
  • SendGrid Provider: packages/modules/providers/notification-sendgrid/src/services/sendgrid.ts
  • Base class: packages/core/utils/src/notification/abstract-notification-provider.ts
  • Types: packages/core/types/src/notification/provider.ts

Next Steps

Payment Providers

Send payment confirmation emails

Fulfillment Providers

Send shipment notifications