> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.onesignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SendGrid Setup

> Integrate SendGrid with OneSignal for email delivery.

# Requirements

* [SendGrid Account](https://www.sendgrid.com)
* [OneSignal Account](https://onesignal.com)

# Setup

## 1. SendGrid Sender Authentication

It is recommended to use SendGrid's "Domain Authentication" so that SendGrid sends emails via your domain rather than `via sendgrid.net`, and the links your users click as coming from your domain.

**Recommended**: Follow SendGrid's guide on [How to set up domain authentication](https://docs.sendgrid.com/ui/account-and-settings/how-to-set-up-domain-authentication).

SendGrid also provides [Single Sender Verification](https://docs.sendgrid.com/ui/sending-email/sender-verification) if you do not have a domain.

## 2. Install DNS Records

If you selected **Domain Authentication** make sure your DNS Records are verified.

<Frame caption="SendGrid DNS verification status">
  <img src="https://mintcdn.com/onesignal/_KaXe4GQkxsEfa17/images/docs/3ceb5db-Screen_Shot_2021-10-20_at_1.18.12_PM.png?fit=max&auto=format&n=_KaXe4GQkxsEfa17&q=85&s=9cbb18e747d85c69d73e272e3c2e23d5" width="1402" height="872" data-path="images/docs/3ceb5db-Screen_Shot_2021-10-20_at_1.18.12_PM.png" />
</Frame>

The SPF, DKIM and MX records should be configured automatically through SendGrid's setup wizard.

<Frame caption="SendGrid domain authentication setup">
  <img src="https://mintcdn.com/onesignal/YOTSrtBSoqdrJ37A/images/docs/41879e3-esp-sendgrid-domain-3.jpg?fit=max&auto=format&n=YOTSrtBSoqdrJ37A&q=85&s=deaeacb61d563fb01079199a4a1373be" width="2500" height="1600" data-path="images/docs/41879e3-esp-sendgrid-domain-3.jpg" />
</Frame>

## 3. Create API Key

In the SendGrid dashboard, go to [Settings -> API Keys](https://app.sendgrid.com/settings/api_keys) and click 'Create API Key'.

<Frame caption="SendGrid API key creation screen">
  <img src="https://mintcdn.com/onesignal/KSCNwSpBCNSQ8xdF/images/docs/f794466-esp-sendgrid-apikey.jpg?fit=max&auto=format&n=KSCNwSpBCNSQ8xdF&q=85&s=58f82278dd1461db66aedf9123723b50" width="2500" height="1270" data-path="images/docs/f794466-esp-sendgrid-apikey.jpg" />
</Frame>

Name your API key something like `OneSignal API Key` and be sure to set permissions to **Full Access**. Click 'Create & View' when you are ready.

<Frame caption="SendGrid API key permission settings">
  <img src="https://mintcdn.com/onesignal/RWtLFPeffHrC81wI/images/docs/afe1836-esp-sendgrid-apikey-2.jpg?fit=max&auto=format&n=RWtLFPeffHrC81wI&q=85&s=c2647bf1992dc79b00974c453a8ffb00" width="2500" height="1350" data-path="images/docs/afe1836-esp-sendgrid-apikey-2.jpg" />
</Frame>

Next, click on the API key to copy it to your clipboard.

<Frame caption="Copying the SendGrid API key">
  <img src="https://mintcdn.com/onesignal/56ctKxZSV4m5VEkn/images/docs/b8a9822-esp-sendgrid-apikey-3.jpg?fit=max&auto=format&n=56ctKxZSV4m5VEkn&q=85&s=df6331d166120cd300fac9d50bb04f82" width="2500" height="990" data-path="images/docs/b8a9822-esp-sendgrid-apikey-3.jpg" />
</Frame>

### What are the minimum API restrictions I can allow?

The minimum access you need to allow is as follows:

<Frame caption="Minimum API permission requirements">
  <img src="https://mintcdn.com/onesignal/3zq1PvSaqvUE2bIx/images/docs/2d82f50-Screen_Shot_2021-12-09_at_1.25.57_PM.png?fit=max&auto=format&n=3zq1PvSaqvUE2bIx&q=85&s=d8857161192778c6714357b2d5e95ac3" width="986" height="1722" data-path="images/docs/2d82f50-Screen_Shot_2021-12-09_at_1.25.57_PM.png" />
</Frame>

<Warning>
  If you are using SendGrid's allowlisting functionality, make sure to add OneSignal to this list.

  See below FAQ [How do I allowlist OneSignal's IPs?](./sendgrid-setup#how-do-i-whitelist-onesignals-ips)
</Warning>

## 4. Disable Sendgrid Subscription Tracking

OneSignal automatically adds its own default unsubscribe links for every email sent.

Disable **Subscription Tracking** in sendgrid to prevent Sendgrid from automatically adding its own unsubscribe link to the bottom of text and HTML emails.

<Frame caption="SendGrid subscription tracking settings">
  <img src="https://mintcdn.com/onesignal/tNi1OgLc_p9hiq7_/images/docs/1b863e8-Sendgrid_Tracking_Settings.png?fit=max&auto=format&n=tNi1OgLc_p9hiq7_&q=85&s=c483fc9706a46d3ab6cc4d00ee90802f" width="1235" height="647" data-path="images/docs/1b863e8-Sendgrid_Tracking_Settings.png" />
</Frame>

## 5. Enable Email Messaging

In OneSignal, navigate to **Settings > Platforms > Email** and **Activate** Email to configure your email settings.

Select **SendGrid** as the provider.

<Frame caption="Image selecting SendGrid from email settings">
  <img src="https://mintcdn.com/onesignal/RWtLFPeffHrC81wI/images/docs/a42b5c0-Screenshot_2023-09-27_at_4.38.36_PM.png?fit=max&auto=format&n=RWtLFPeffHrC81wI&q=85&s=af1b1a422edf6fc979eeb9b4c3cfc42e" width="1880" height="1026" data-path="images/docs/a42b5c0-Screenshot_2023-09-27_at_4.38.36_PM.png" />
</Frame>

Paste your SendGrid API key into the provided field.

<Frame caption="Image showing where to enter your API Key">
  <img src="https://mintcdn.com/onesignal/ciRrThfP6xMpI7GY/images/docs/0431d6a-Screenshot_2023-09-27_at_4.39.12_PM.png?fit=max&auto=format&n=ciRrThfP6xMpI7GY&q=85&s=bbb78dfd7e2c9deaf6699292dd55dab8" width="1862" height="644" data-path="images/docs/0431d6a-Screenshot_2023-09-27_at_4.39.12_PM.png" />
</Frame>

### Delivery Defaults

Add the default **name** and **email address** you want your emails to come from (these can be changed later).

Press Done when finished.

<Frame caption="Email configuration success banner">
  <img src="https://mintcdn.com/onesignal/YOTSrtBSoqdrJ37A/images/docs/4b63e41-Screenshot_2023-09-27_at_4.41.02_PM.png?fit=max&auto=format&n=YOTSrtBSoqdrJ37A&q=85&s=7fa2706b1fa954740752c6b1557552cc" width="1874" height="884" data-path="images/docs/4b63e41-Screenshot_2023-09-27_at_4.41.02_PM.png" />
</Frame>

## 6. Add Subscribers

If you have a list of emails ready, select **Upload CSV** or you can always do this again later.

If you have a website and want to prompt users to provide their email. Select **Add Web Prompt** to use OneSignal's [Email Web Prompt](./permission-requests).

<Frame caption="Email subscriber setup options">
  <img src="https://mintcdn.com/onesignal/MUgio66t0sYhGEvj/images/docs/6ba703e-Screenshot_2023-09-27_at_4.39.54_PM.png?fit=max&auto=format&n=MUgio66t0sYhGEvj&q=85&s=1073f5704e2367527d67cab6980789d2" width="1874" height="1174" data-path="images/docs/6ba703e-Screenshot_2023-09-27_at_4.39.54_PM.png" />
</Frame>

## 7. Testing

Navigate to **Messages > Email**, select **New Email**.

Add a `Subject`, select an Editing experience (Drag & Drop Editor is a good start) and click **Send Test Email**.

<Frame caption="Email testing interface">
  <img src="https://mintcdn.com/onesignal/6v_cVPknFpo5qSVB/images/docs/10d1976-Screenshot_2023-09-27_at_4.49.08_PM.png?fit=max&auto=format&n=6v_cVPknFpo5qSVB&q=85&s=5bd931f0ccb9ad064110678ce5e0e183" width="2206" height="692" data-path="images/docs/10d1976-Screenshot_2023-09-27_at_4.49.08_PM.png" />
</Frame>

Input your email and press **Send Test Email**. An email should arrive to your inbox shortly!

<Info>
  If running into issues, see our [Email FAQ](./email-troubleshooting).

  If stuck, contact `support@onesignal.com` for help.

  For faster assistance, please provide:

  * Your OneSignal App Id
  * Details, logs, and/or screenshots of the issue.
  * Steps to reproduce
</Info>

# Recommended

## Identify Users

**Required if using integrations.** **Recommended for messaging across multiple channels (push, email, sms).**

OneSignal creates subscription-level records under a unique ID called the subscription\_id. A single user can have multiple subscription\_id records based on how many devices, email addresses, and phone numbers they use to interact with your app.

If your app has its own login system to track users, call `login` at any time to link all channels to a single user. For more details, see [Aliases & External ID](./users).

## Collect New Emails

**Recommended if using Email and SMS messaging.**

There are several ways to pass new email addresses into OneSignal:

* Use OneSignal's Frontend SDK to capture new emails. See [Email SDK Methods](./mobile-sdk-reference#email).
* Use the [Create user](/reference/create-user) or [Create subscription](/reference/create-subscription) APIs to add emails from your server.
* If you want to import emails via CSV, see [Import Email Addresses](./import).

## Add Tags

**Optional**

Tags are custom `key : value` pairs of String data used for tracking user events and properties. Setting tags is required for more complex [segmentation](./segmentation) and [message personalization](./message-personalization).

See [Tags](./add-user-data-tags) for more details.

<Check>
  Visit [Email Tutorials](./email-messaging) for next steps.
</Check>

# Exporting Emails

1. **Contact Lists Navigation**: Go to `Marketing > Contacts`.

2. <Frame caption="Navigating to Contacts page">
     <img src="https://mintcdn.com/onesignal/jBdBk5XvQR5eKOks/images/docs/7c49df1-step-1-50.png?fit=max&auto=format&n=jBdBk5XvQR5eKOks&q=85&s=eb80902228ae5d891426577e09211c6a" width="224" height="1167" data-path="images/docs/7c49df1-step-1-50.png" />
   </Frame>

3. **List Identification**: Locate the list you want to export.

4. **Export Selection**: Open the context menu under the **Action** list header.

<Frame caption="Selecting Contact List to export">
  <img src="https://mintcdn.com/onesignal/Z6xkXGfmy814If53/images/docs/d900c5a-step-3-50.png?fit=max&auto=format&n=Z6xkXGfmy814If53&q=85&s=4ef417459779b56fe9211305f082782e" width="1261" height="679" data-path="images/docs/d900c5a-step-3-50.png" />
</Frame>

4. **Begin Export**: Click **Export**. This takes you to `Contact > Active Exports`.
5. **Download File**: Wait until the **Status** shows 'Ready for Download', then click **Download CSV**.

<Frame caption="Downloading the exported CSV">
  <img src="https://mintcdn.com/onesignal/3zq1PvSaqvUE2bIx/images/docs/2d1c12f-step-5-50.png?fit=max&auto=format&n=3zq1PvSaqvUE2bIx&q=85&s=3f8102ca85b5dde7c55e10cb12643ce6" width="1261" height="630" data-path="images/docs/2d1c12f-step-5-50.png" />
</Frame>

6. **File Retrieval**: The file will be saved in your downloads directory.

# Obtaining API Key

1. Navigate to your Sendgrid dashboard and open **Settings** from the left sidebar.

<Frame caption="Navigating to Settings > API Keys">
  <img src="https://mintcdn.com/onesignal/4HyuQPBpu-4xjmQC/images/docs/cf3fe33-step-1-50.png?fit=max&auto=format&n=4HyuQPBpu-4xjmQC&q=85&s=0a162a955d877a4b66623bbe835cfcb7" width="1616" height="1365" data-path="images/docs/cf3fe33-step-1-50.png" />
</Frame>

2. Select **API Keys**.

<Frame caption="Clicking the Create API Key button">
  <img src="https://mintcdn.com/onesignal/9_Q1FZLh6C0BFLq-/images/docs/c3045de-step-2-50.png?fit=max&auto=format&n=9_Q1FZLh6C0BFLq-&q=85&s=2421e360c654dcf620110214bdceb187" width="1616" height="1365" data-path="images/docs/c3045de-step-2-50.png" />
</Frame>

3. Name your key. Optionally, opt for *Restricted Access* for specific permissions.

<Frame caption="Naming the key and setting permissions">
  <img src="https://mintcdn.com/onesignal/0qspEXXeJ8zJbkJ-/images/docs/8770efc-step-3-50.png?fit=max&auto=format&n=0qspEXXeJ8zJbkJ-&q=85&s=f2c9125755ab5db955af0a8dd6d1edfc" width="1616" height="1365" data-path="images/docs/8770efc-step-3-50.png" />
</Frame>

If using *Restricted Access*, ensure that you grant **Full Access** privileges for Marketing.

<Frame caption="Granting Full Access to Marketing">
  <img src="https://mintcdn.com/onesignal/0qspEXXeJ8zJbkJ-/images/docs/83d80f8-step-4-50.png?fit=max&auto=format&n=0qspEXXeJ8zJbkJ-&q=85&s=33a46fe982c60987c70cd4dfa9e0d07e" width="1616" height="1365" data-path="images/docs/83d80f8-step-4-50.png" />
</Frame>

4. Click **Create & View**.

<Frame caption="Clicking the Create & View button">
  <img src="https://mintcdn.com/onesignal/KSCNwSpBCNSQ8xdF/images/docs/f92f0c4-step-5-50.png?fit=max&auto=format&n=KSCNwSpBCNSQ8xdF&q=85&s=75a7a005e4040d66c4badf0d68260942" width="1616" height="1365" data-path="images/docs/f92f0c4-step-5-50.png" />
</Frame>

5. Copy your API key.

<Frame caption="Copying the API key">
  <img src="https://mintcdn.com/onesignal/MUgio66t0sYhGEvj/images/docs/64034da-step-6-50.png?fit=max&auto=format&n=MUgio66t0sYhGEvj&q=85&s=73edf11c5792ca71d42301ac225594f6" width="1616" height="1365" data-path="images/docs/64034da-step-6-50.png" />
</Frame>

# FAQ

## How do I set up OneSignal if I already have an active Webhook in SendGrid?

To simplify setup and be able to access email delivery statistics, OneSignal will automatically configure Webhooks with SendGrid. Unfortunately, SendGrid only supports a single webhook for a given account. OneSignal requires webhooks for email analytics, which may conflict with webhooks previously set up (e.g. for an analytics integration).

If you need the webhook you have currently set up, you can forward the request to `https://onesignal.com/email/hooks/sendgrid`. Setup a timeout of 30 seconds for best results.

If you do not need the webhook you previously set up, you must change it. In SendGrid, go to **Settings > Mail Settings** and click 'Event Webhook'. The HTTP Post URL should be `https://onesignal.com/email/hooks/sendgrid` and have the minimum settings shown:

<Frame caption="SendGrid webhook configuration settings">
  <img src="https://mintcdn.com/onesignal/tc0EvmtSSX56SX0c/images/docs/989f714-Screen_Shot_2021-10-20_at_2.05.47_PM.png?fit=max&auto=format&n=tc0EvmtSSX56SX0c&q=85&s=fccfdce1d4e2ae9139c8a00bd1605bf2" width="2526" height="1522" data-path="images/docs/989f714-Screen_Shot_2021-10-20_at_2.05.47_PM.png" />
</Frame>

## How do I allowlist OneSignal's IPs?

See the requirements in our [REST API Overview](/reference/rest-api-overview) for details.

<Frame caption="OneSignal IP allowlist requirements">
  <img src="https://mintcdn.com/onesignal/56ctKxZSV4m5VEkn/images/docs/b7550d9-Screen_Shot_2022-05-27_at_5.32.06_PM.png?fit=max&auto=format&n=56ctKxZSV4m5VEkn&q=85&s=d107970e875efcb9418aea08ea412106" width="1626" height="1314" data-path="images/docs/b7550d9-Screen_Shot_2022-05-27_at_5.32.06_PM.png" />
</Frame>

***
