SendGrid Integration

How to use SendGrid with MagicBell

Deliver email notifications with your SendGrid account

To configure SendGrid for your MagicBell project, follow these steps:

  1. Sign up for SendGrid and obtain an API key. It must have full access to the v3 Mail Send endpoint.
  2. From the Settings Channels page in your dashboard, select Add Provider SendGrid.
  3. Enable the provider and enter the API key from step 1 then click Save.
You can optionally configure a custom from/reply to email address (verified sender identity) and name.

Once your account is set up, MagicBell will automatically deliver email notifications through your SendGrid account, no additional work is needed. You will be able to use SendGrid's activity feed to view your activity.

Provider Overrides

Our create notifications endpoint allows you to customize the payload sent to SendGrid by setting notification.overrides.

The notification.overrides.sendgrid parameter accepts all the body parameters of SendGrid's Mail Send API.

Provider-specific parameters in notification.overrides take precedence over the ones specified in notification.

Example: Set a custom header

{
  "notification": {
    "title": "We are processing your order",
    "content": "

Thank you for your order. We will notify you when these items are ready.

", "recipients": [ { "email": "[email protected]" } ], "overrides": { "providers": { "sendgrid": { "headers": { "X-Original-To": "[email protected]" } } } } } }

Example: SendGrid email templates

In addition to our own email templates, MagicBell can deliver email notifications using SendGrid's.

After creating a template in SendGrid, you can specify its ID in notification.overrides.providers.sendgrid.template and the values for substitution in notification.custom_attributes:

{
  "notification": {
    "title": "We are processing your order",
    "recipients": [
      {
        "email": "[email protected]"
      }
    ],
    "custom_attributes": {
      "name": "Dan",
      "company": {
        "name": "Example Inc"
      }
    },
    "overrides": {
      "providers": {
        "sendgrid": {
          "template_id": "SENDGRID_TEMPLATE_ID"
        }
      }
    }
  }
}

Keep in mind that the content of the notification is ignored when you use a template. SendGrid will use the template content instead.