SendGrid Channel Provider

Configuration

To configure the SendGrid integration, you'll need the following data:

required fields are marked with an `*`
ParameterTypeDescription
reply_toobject
└ emailstring *The email address to reply to
└ name The name to reply to
api_keystring *The API key for Sendgrid
fromobject
└ emailstring *The email address to send from
└ name The name to send from

In the Dashboard

The easiest way to configure this integration is through the MagicBell dashboard:

  1. Log in to your MagicBell dashboard.
  2. Navigate to Channels.
  3. Find and click on this channel name in the sidebar.
  4. Click the Configure SendGrid button.
  5. Follow the on-screen instructions to complete the configuration.

Using the API

Use the API to save , list and delete SendGrid. For example, to save the integration:

Request
curl --request PUT \
  --url 'https://api.magicbell.com/v2/integrations/sendgrid' \
  --header 'content-type: application/json' \
  --header "authorization: Bearer $TOKEN" \
  --data '{"api_key":"SG.1234567890","from":{"email":"company@example.com","name":"Company Name"},"reply_to":{"email":"reply-to@example.com","name":"Reply to Company"}}'

Usage

1. When configured with

{
  "api_key": "SG.1234567890",
  "from": {
    "email": "company@example.com",
    "name": "Company Name"
  },
  "reply_to": {
    "email": "reply-to@example.com",
    "name": "Reply to Company"
  }
}

2. With a channel token

{
  "address": "dan@example.com",
  "name": "Dan"
}

3. With Broadcast

{
  "action_url": "https://example.com",
  "category": "example",
  "content": "I come from broadcast",
  "custom_attributes": {},
  "id": "d1b3b3b3-3b3b-3b3b-3b3b-3b3b3b3b3b3b",
  "overrides": {},
  "recipients": [
    {
      "custom_attributes": {
        "plan": "enterprise",
        "preferred_pronoun": "They",
        "pricing_version": "v10"
      },
      "email": "test@example.com",
      "external_id": "83d987a-83fd034",
      "first_name": "Person",
      "last_name": "Doe",
      "phone_numbers": [
        "+1 5005550001"
      ]
    }
  ],
  "title": "Hello, World!",
  "topic": "example"
}

The channel handler triggers a HTTP request

POST https://api.sendgrid.com/v3/mail/send

With payload

{
  "content": [
    {
      "type": "text/html",
      "value": "I come from broadcast"
    }
  ],
  "from": {
    "email": "company@example.com",
    "name": "Company Name"
  },
  "personalizations": [
    {
      "to": [
        {
          "email": "dan@example.com",
          "name": null
        }
      ]
    }
  ],
  "reply_to": {
    "email": "reply-to@example.com",
    "name": "Reply to Company"
  },
  "subject": "Hello, World!"
}

Overrides

The provider overrides key in the broadcast payload can be used to change the default behavior of the channel handler.

overrides >> providers >> sendgrid

Override `from` key

Overrides

{
  "providers": {
    "sendgrid": {
      "from": {
        "email": "another@example.com"
      }
    }
  }
}

Payload

{
  "content": [
    {
      "type": "text/html",
      "value": "I come from broadcast"
    }
  ],
  "from": {
    "email": "another@example.com",
    "name": "Company Name"
  },
  "personalizations": [
    {
      "to": [
        {
          "email": "dan@example.com",
          "name": null
        }
      ]
    }
  ],
  "reply_to": {
    "email": "reply-to@example.com",
    "name": "Reply to Company"
  },
  "subject": "Hello, World!"
}

Override `custom_args` key

Overrides

{
  "providers": {
    "sendgrid": {
      "custom_args": {
        "tracking_id": "abcd1234"
      }
    }
  }
}

Payload

{
  "content": [
    {
      "type": "text/html",
      "value": "I come from broadcast"
    }
  ],
  "custom_args": {
    "tracking_id": "abcd1234"
  },
  "from": {
    "email": "company@example.com",
    "name": "Company Name"
  },
  "personalizations": [
    {
      "to": [
        {
          "email": "dan@example.com",
          "name": null
        }
      ]
    }
  ],
  "reply_to": {
    "email": "reply-to@example.com",
    "name": "Reply to Company"
  },
  "subject": "Hello, World!"
}