# SendGrid Destination

[SendGrid](https://sendgrid.com/solutions/email-marketing/) provides email marketing automation for businesses. With Segment you can add contacts and lists to SendGrid.

## Getting started

1. From the Segment web app, click **Catalog**, then click **Destinations**.
2. Find the Destinations Actions item in the left navigation, and click it.
3. Click **Configure SendGrid**.
4. Select an existing Source to connect to SendGrid.
5. In the destination settings, enter your SendGrid "API key" into the connection settings. You should create a new API key for the Segment destination. You can read more about API keys on [Marketing Campaigns's docs.](/docs/sendgrid/ui/account-and-settings/api-keys)

## Destination Settings

| Field                        | Description                                                                                                                                                                                                                                                                                       | Required | Type     |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- |
| Regional Processing Endpoint | The regional processing endpoint for your SendGrid account. \[See more details]\(https://www.twilio.com/en-us/blog/send-emails-in-eu?\_gl=1\*7hyri9\*\_gcl\_au\*MTg0MTQwMjAzNi4xNzQzMDAyNzc4\*\_ga\*MTk4OTI2MDk1LjE3NDMwMDI3Nzg.\*\_ga\_8W5LR442LD\*MTc0MzY3NTc2NC41LjAuMTc0MzY3NTc2NC4wLjAuMA..) | No       | select   |
| API Key                      | The Api key for your SendGrid account.                                                                                                                                                                                                                                                            | Yes      | password |

## Available Actions

Build your own Mappings. Combine supported [triggers](/docs/segment/connections/destinations/actions/#components-of-a-destination-action) with the following SendGrid-supported actions:

> \[!NOTE]
>
> Individual destination instances have support a maximum of 50 mappings.

* [Upsert Contact](#upsert-contact)
* [Send Email with Dynamic Template](#send-email-with-dynamic-template)

### Upsert Contact

Add or update a Contact in SendGrid.

Upsert Contact is a **Cloud** action.

| Field                                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Required | Type    |
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
| Batch Data to SendGrid Contacts PUT API | When enabled, the action will use the SendGrid Contacts PUT API to perform the batch operation. Batches can contain up to 30k records in a request.                                                                                                                                                                                                                                                                                                                        | No       | BOOLEAN |
| First Name                              | The contact's first name.                                                                                                                                                                                                                                                                                                                                                                                                                                                  | No       | STRING  |
| Last Name                               | The contact's last name.                                                                                                                                                                                                                                                                                                                                                                                                                                                   | No       | STRING  |
| Country                                 | The contact's country.                                                                                                                                                                                                                                                                                                                                                                                                                                                     | No       | STRING  |
| Postal Code                             | The contact's postal code.                                                                                                                                                                                                                                                                                                                                                                                                                                                 | No       | STRING  |
| City                                    | The contact's city.                                                                                                                                                                                                                                                                                                                                                                                                                                                        | No       | STRING  |
| State                                   | The contact's state.                                                                                                                                                                                                                                                                                                                                                                                                                                                       | No       | STRING  |
| Address Line 1                          | The contact's address line 1.                                                                                                                                                                                                                                                                                                                                                                                                                                              | No       | STRING  |
| Address Line 2                          | The contact's address line 2.                                                                                                                                                                                                                                                                                                                                                                                                                                              | No       | STRING  |
| Phone Number                            | The contact's phone number. Note: This is different from the Phone Number ID field, but the same value can be stored in both fields.                                                                                                                                                                                                                                                                                                                                       | No       | STRING  |
| WhatsApp                                | The contact's WhatsApp.                                                                                                                                                                                                                                                                                                                                                                                                                                                    | No       | STRING  |
| Line                                    | The contact's landline.                                                                                                                                                                                                                                                                                                                                                                                                                                                    | No       | STRING  |
| Facebook                                | The contact's Facebook identifier.                                                                                                                                                                                                                                                                                                                                                                                                                                         | No       | STRING  |
| Unique Name                             | The contact's unique name.                                                                                                                                                                                                                                                                                                                                                                                                                                                 | No       | STRING  |
| Email Address                           | The contact's email address.                                                                                                                                                                                                                                                                                                                                                                                                                                               | No       | STRING  |
| Phone Number ID                         | Primary Phone Number used to identify a Contact. This must be a valid phone number.                                                                                                                                                                                                                                                                                                                                                                                        | No       | STRING  |
| External ID                             | The contact's External ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                 | No       | STRING  |
| Anonymous ID                            | The contact's Anonymous ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                | No       | STRING  |
| Other Fields                            | &#xA;  Additional fields to send to SendGrid. On the left-hand side, input the SendGrid Custom Fields Id. On the right-hand side, map the Segment field that contains the value.&#xA;&#xA;  Custom Fields must be predefined in your SendGrid account and you can retrieve corresponding Id using get all field definitions endpoint.&#xA;&#xA;  Reference: \[Get All field definitions]\(https://docs.sendgrid.com/api-reference/custom-fields/get-all-field-definitions) | No       | OBJECT  |

### Send Email with Dynamic Template

Send email to recipient(s) using a Dynamic Template in Sendgrid

Send Email with Dynamic Template is a **Cloud** action.

| Field                 | Description                                                                                                                                                                                                                                  | Required | Type   |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------ |
| Validated Domain      | The domain to use for the email. This field is optional but recommended. If you do not provide a domain, Sendgrid will attempt to send the email based on the from address, and may fail if the domain in the from address is not validated. | No       | STRING |
| From                  | From details.                                                                                                                                                                                                                                | Yes      | OBJECT |
| To                    | Recipient details.                                                                                                                                                                                                                           | Yes      | OBJECT |
| CC                    | CC recipient details                                                                                                                                                                                                                         | No       | OBJECT |
| BCC                   | BCC recipient details                                                                                                                                                                                                                        | No       | OBJECT |
| Headers               | Headers for the email.                                                                                                                                                                                                                       | No       | OBJECT |
| Dynamic Template Data | A collection of property names that will be substituted by their corresponding property values in the subject, reply-to and content portions of a SendGrid Dynamic Template.                                                                 | No       | OBJECT |
| Dynamic Template      | The Dynamic Template to use for the email.                                                                                                                                                                                                   | Yes      | STRING |
| Custom Args           | Custom arguments for the email.                                                                                                                                                                                                              | No       | OBJECT |
| Send At               | The time to send the email. ISO 8601 format. E.g. 2024-09-23T12:00:00Z. A send cannot be scheduled more than 72 hours in advance.                                                                                                            | No       | STRING |
| Reply To              | Reply to details. If left empty 'Reply To' settings will be taken from the 'From' field values.                                                                                                                                              | No       | OBJECT |
| Categories            | Categories for the email. Accepts a single string or array of strings.                                                                                                                                                                       | No       | STRING |
| IP Pool               | Send email with an ip pool.                                                                                                                                                                                                                  | No       | STRING |
| Group ID              | Specify a Group ID                                                                                                                                                                                                                           | No       | STRING |

## Additional details for the Send Email With Dynamic Template Action

### Usage

The [Send Email With Dynamic Template](#send-email-with-dynamic-template) Action can be used to send emails through SendGrid using [SendGrid Dynamic Templates](/docs/sendgrid/ui/sending-email/how-to-send-an-email-with-dynamic-templates). The Dynamic Template you use must already exist in SendGrid. Use the Action field [Dynamic Template Data](#dynamic-template-data) to populate values in the Dynamic Template.

### Contacts

SendGrid sends emails to the email addresses you specify, even if they are not listed as Contacts in SendGrid.

### SendGrid API Key

Segment and SendGrid recommend that you define the SendGrid API key within a subuser account and the domain is authenticated under that same subuser account. The Send Email With Dynamic Template Action requires that the SendGrid API Key has the following scopes assigned:

* Category Management: full
* IP Management: full
* Template Engine: full

## Additional details for the Upsert Contact Action

### Recording Custom User Traits

If you want to view any other custom user traits in the Marketing Campaigns list dashboard, you must create a [Custom Field inside Marketing Campaigns's UI](/docs/sendgrid/ui/managing-contacts/custom-fields#creating-custom-fields) of the traits in your identify calls. Note that you do not need to map all user.traits you are sending inside Marketing Campaigns. You only need to create Custom Fields of the traits you want to see in your list view.

### Custom Fields

To send custom fields/user traits to Marketing Campaigns you need to create the field first in Marketing Campaigns for each trait you want sent to Marketing Campaigns. Then when you call identify with keys that match those traits they will appear in your Marketing Campaigns list.

For any other custom traits just add a Custom Field inside of SendGrid with a tag that matches the key you are using in your identify call.

### Recording userId

To record a Segment userId in SendGrid, you must pass the userID as a trait on your identify() calls. SendGrid does not automatically map the Segment userID to any Marketing Campaigns properties.

### SendGrid API Key

The Upsert Contact Action requires the SendGrid API Key to have the following scopes:

* Marketing: full
