@medusajs/notification-sendgrid
Documentation | Website
Building blocks for digital commerce
SendGrid Notification Module Provider for Medusa: sends email notifications through SendGrid, using SendGrid dynamic templates or raw HTML content. Use it to send transactional emails, such as order confirmations or password resets. It ships with @medusajs/medusa and is registered through the @medusajs/medusa/notification-sendgrid path.
At a glance
| Package | @medusajs/notification-sendgrid |
| Type | Module Provider (Notification Module) |
| Provider ID | notification-sendgrid |
| Registered by default | No |
| Import from | @medusajs/medusa/notification-sendgrid |
Features
- Sends a notification's
templateas a SendGrid dynamic template ID, with the notification'sdataas the template data. - Sends a notification's
content(subjectandhtml) instead of a template when it's set. - Supports attachments, a per-notification
fromaddress, and SendGridpersonalizationsthroughprovider_data.
Installation
No installation needed. The provider is a dependency of @medusajs/medusa.
Usage
Register the provider in the Notification Module's providers array in medusa-config.ts for the email channel. Each channel can be handled by only one provider.
import { defineConfig } from "@medusajs/framework/utils"
module.exports = defineConfig({
// ...
modules: [
{
resolve: "@medusajs/medusa/notification",
options: {
providers: [
{
resolve: "@medusajs/medusa/notification-sendgrid",
id: "sendgrid",
options: {
channels: ["email"],
api_key: process.env.SENDGRID_API_KEY,
from: process.env.SENDGRID_FROM,
},
},
],
},
},
],
})
Configuration
| Option | Type | Description | Default |
|---|---|---|---|
channels |
string[] |
Read by the Notification Module. The channels this provider handles; use ["email"]. |
[] |
api_key |
string |
Required. Your SendGrid API key. | - |
from |
string |
Required. The default sender email address. | - |
| Environment variable | Description |
|---|---|
SENDGRID_API_KEY |
Value for api_key, as used in the example above. |
SENDGRID_FROM |
Value for from, as used in the example above. |