Deliver email notifications with your SendGrid account
To have SendGrid configured for your MagicBell project, follow these steps:
- Sign up for SendGrid and obtain an API key. It must have full access to the Mail Send endpoint.
- Send us your API key and your verified sender identity (email address).
- Verify the email channel in MagicBell is enabled
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.
Sending emails with additional or unique content
Our create notifications endpoint
allows you to customize the content sent to SendGrid by setting
notification.overrides
.
The notification.overrides
parameter accepts all of the SendGrid's Web API
body parameters.
Below you can see how to send an email notification with custom headers.
json{
"notification": {
"title": "We're processing your order",
"content": "<p>Thank you for your order. We'll notify you when these items are ready.</p>",
"recipients": [
{
"email": "dan@example.com"
}
],
"overrides": {
"providers": {
"sendgrid": {
"headers": {
"X-Original-To": "devs@example.com"
}
}
}
}
}
}
Using SendGrid email templates
MagicBell can deliver email notifications using SendGrid email templates.
Create a template in SendGrid, and grab its ID. Then create a notification with
the template_id
attribute set in notification.overrides.providers.sendgrid
when creating
a notification. MagicBell will use custom_attributes
to fill in your template.
{
"notification": {
"title": "We are processing your order",
"recipients": [{
"email": "dan@example.com"
}],
"custom_attributes": {
"name": "Dan",
"company": {
"name": "Example Inc"
}
}
"overrides": {
"providers": {
"sendgrid": {
"template_id": "[sengrid_template_id]"
}
}
}
}
}
Keep in mind that the content of the notification is ignored when you use a template. Sending will use the template content instead.