> For the complete documentation index, see [llms.txt](https://docs.anedot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.anedot.com/integrations/email-marketing-communication/sendgrid.md).

# SendGrid

Connect Anedot to SendGrid to add Action Page donors and supporters as marketing contacts, manage your connection, and review field mapping and payload data.

**SendGrid**, also known as Twilio SendGrid, is an email marketing platform. The integration in **Settings > Integrations** adds the donor or supporter from each Action Page submission to SendGrid as a marketing contact and can add that contact to your marketing lists.

## Before You Begin

* You need **Integrations: Edit permissions** to add, edit, push or delete a connection. Integrations: Edit permissions also require **Action Pages: View permissions** and **Integrations: View permissions**. See [Permission Sets](https://docs.anedot.com/settings/access/permission-sets.md).
* You need a SendGrid account with the marketing lists you want contacts added to.
* You need two values from SendGrid: an API key with **Marketing** set to **Full Access**, and the List ID of each list contacts should be added to. See [Step 1: Create an API Key in SendGrid](https://docs.anedot.com/integrations/email-marketing-communication/sendgrid.md#step-1-create-an-api-key-in-sendgrid) and [Step 2: Find Your List IDs](https://docs.anedot.com/integrations/email-marketing-communication/sendgrid.md#step-2-find-your-list-ids).
* You can't use this integration with SendGrid's **EU Data Residency** environment. It uses SendGrid Marketing Campaigns, which SendGrid documents as unavailable in that environment.

## Connect Anedot to SendGrid

### Step 1: Create an API Key in SendGrid

You create the API key in your SendGrid account, not in Anedot.

To create your API key:

1. Go to **Settings > API Keys** in SendGrid.
2. Click **Create API Key**.
3. Enter a name for the key in **API Key Name**.
4. Choose **Custom Access**.
5. Under **Marketing**, set access to **Full Access**.
6. Leave every other permission off, including **Marketing Campaigns**.
7. Click **Create & View**.
8. Copy the API key and store it somewhere safe.

Your API key is ready to enter in Anedot.

{% hint style="info" %}
Anedot only adds and updates marketing contacts, so the key needs only the **Marketing** permission. **Marketing Campaigns** is a legacy permission and isn't needed.
{% endhint %}

{% hint style="warning" %}
SendGrid shows the full API key only once, when you create it, and can't retrieve a lost or deleted key. Treat the API key like a password.
{% endhint %}

### Step 2: Find Your List IDs

A List ID is a 36-character ID that SendGrid creates for each list.

To find your List IDs:

1. Go to **Marketing > Contacts** in SendGrid.
2. Find the list you want contacts added to. To create a new list, choose **New List** from the **Create** menu.
3. Copy that list's 36-character ID.
4. Repeat these steps for each list you want to use.

You'll enter these IDs in the **List IDs** field in Anedot.

{% hint style="info" %}
SendGrid accepts up to 10 List IDs in one request, and a contact can belong to up to 250 lists. If you aren't sure where the ID is shown, check SendGrid's documentation or contact SendGrid support.
{% endhint %}

### Step 3: Create the Connection in Anedot

To create the connection:

1. Go to **Settings > Integrations**.
2. Click **New integration**.
3. Choose **SendGrid**, or enter "SendGrid" in the search box.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p><strong>SendGrid</strong> appears under the <strong>Email Marketing</strong> category with the text "Send Action Page data to SendGrid contacts."</p></div>
4. Choose the Action Page scope:
   * Keep **All Action Pages** checked to include every Action Page, including pages you add later. (Optional) In **Exclude Pages**, enter a comma-separated list of Action Page IDs with no spaces.
   * Uncheck **All Action Pages** and choose **Selected pages** to pick specific pages.
5. (Optional) In **Team**, choose a Team to limit the connection to that Team's Action Pages. Leave it set to **All teams** to include every Team. See [Teams](https://docs.anedot.com/settings/access/teams.md).
6. Enter your SendGrid API key in **SendGrid API key**.
7. In **List IDs**, enter a List ID in the **Enter List ID** box.
8. To add another list, click **Add** and enter the next List ID. Repeat for each list, up to 10.
9. Click **Create integration**.

The connection is listed in **Settings > Integrations**.

{% hint style="success" %}
After you connect, submit a test on a covered Action Page with an email address and check **Settings > Integrations > Integration Requests** for a **Success** row. Then find the contact in SendGrid.
{% endhint %}

## Manage Your Connection

### Edit Your Connection

You can change the Action Page scope, **Team**, **Name** and **Enabled** on an existing connection.

To edit your connection:

1. Go to **Settings > Integrations**.
2. Click **Edit** on the SendGrid connection.
3. Update the Action Page scope, **Team**, **Name** or **Enabled**.
4. Click **Save integration**.

New settings apply to records sent from then on. Editing doesn't resend records already sent, and unchecking **Enabled** stops sending.

{% hint style="info" %}
The Edit form also shows a **Credentials/details JSON** box. Leave it as it is.
{% endhint %}

The API key and List IDs aren't shown or changed in the Edit form. To use a different API key or different List IDs, delete the connection and connect again with the new values. See [Reconnect Or Delete Your Connection](https://docs.anedot.com/integrations/email-marketing-communication/sendgrid.md#reconnect-or-delete-your-connection).

### Push Unsent Records

**Push unsent** resends failed or never-sent submissions for a date range.

* The range can be up to 31 days.
* The start date must be within the last 12 months.
* Wait about five minutes between pushes.
* Only failed or unsent submissions are sent. Successful ones aren't sent again.

For full steps, see [Push Unsent in Webhooks (API)](https://docs.anedot.com/integrations/integration-automation-tools/webhooks.md#push-unsent).

### Reconnect Or Delete Your Connection

To delete your connection:

1. Go to **Settings > Integrations**.
2. Click **Delete** on the SendGrid connection.
3. Confirm the prompt "Delete this integration?".

Anedot stops sending to SendGrid. Contacts already in SendGrid aren't changed.

To reconnect, follow the steps in [Connect Anedot to SendGrid](https://docs.anedot.com/integrations/email-marketing-communication/sendgrid.md#connect-anedot-to-sendgrid) again.

{% hint style="info" %}
Submissions already sent successfully with the same API key aren't sent again after you reconnect, even if you enter different List IDs.
{% endhint %}

## Data Relays

### What Anedot Sends

Anedot sends one record per Action Page submission in the connection's scope.

* Donation Pages, Event Pages and Lead Pages are all sent.
* Lead Page submissions are sent when they're submitted. Donation Page and Event Page submissions are sent once the donation or payment is completed.
* For each submission, Anedot adds or updates a SendGrid marketing contact with the email address, first name, last name and address fields in [Field Mapping](https://docs.anedot.com/integrations/email-marketing-communication/sendgrid.md#field-mapping), and adds the contact to the lists whose IDs you entered.
* Anedot fills SendGrid's reserved contact fields only. It doesn't set SendGrid custom fields.
* If a donor submits more than once, each submission is sent separately.
* Recurring donation payments, commitment changes (such as a cancellation), refunds and donation status changes aren't sent. See [Commitments](https://docs.anedot.com/finance/management-and-reporting/commitments.md).
* Abandoned Actions and updates to a submission aren't sent.

If the email address already exists in SendGrid, SendGrid updates the contact with the values Anedot sends. SendGrid accepts contacts for processing, so a new or updated contact can take a moment to appear.

### Records Anedot Skips

Anedot doesn't send these records, and they don't show a row in **Settings > Integrations > Integration Requests**:

* A submission with no email address.
* A submission that was already sent successfully to any SendGrid connection with the same API key, including a connection you deleted and connected again, even if the List IDs differ.
* A Donation Page submission whose donation isn't completed yet. It's sent when it completes.
* Any submission while **Enabled** is unchecked.
* Recurring donation payments.
* Submissions from Action Pages outside the connection's Action Page or Team scope.

### Delivery And Retries

Each submission sent shows a row in **Settings > Integrations > Integration Requests** with its status (**Success**, **Failure** or **Error**), the request and the response. The stored request doesn't include your API key. See [Integration Requests](https://docs.anedot.com/integrations/relay-data-troubleshooting/integration-requests.md).

* **Success**: SendGrid accepted the contact for processing. The contact can take a moment to appear in SendGrid.
* **Failure**: SendGrid rejected the record, and Anedot doesn't try that submission again. Fix the cause, then use [Push Unsent Records](https://docs.anedot.com/integrations/email-marketing-communication/sendgrid.md#push-unsent-records).
* **Error**: Anedot couldn't reach SendGrid and tries again automatically.

Users with the **Integration sync failed** notification turned on get an email when a row shows **Failure**. See [Notifications](https://docs.anedot.com/get-started/security/notifications.md).

{% hint style="warning" %}
Repeated authorization errors, where SendGrid rejects the API key, turn the connection off. A successful send resets this. If the connection stops sending, delete it and connect again with a working API key.
{% endhint %}

## Find Your Data in SendGrid

To find a contact from Anedot:

1. Go to **Marketing > Contacts** in SendGrid. You can also search a specific list or your **All Contacts** list.
2. Enter the person's email address in the **Search by identifier** field.
3. Click **Search**.
4. Click the contact's email address to open the contact's details.

The contact details show the reserved fields Anedot filled and the lists the contact belongs to.

{% hint style="info" %}
Search isn't case sensitive. A partial search needs at least the first three characters of the email address.
{% endhint %}

## Field Mapping

| Anedot Value              | SendGrid Field          | Notes                                                                        |
| ------------------------- | ----------------------- | ---------------------------------------------------------------------------- |
| Email                     | `email`                 | Required by SendGrid to identify the contact.                                |
| First name                | `first_name`            | Sent empty when the submission has no first name.                            |
| Last name                 | `last_name`             | Sent empty when the submission has no last name.                             |
| Street address            | `address_line_1`        |                                                                              |
| Address line 2            | `address_line_2`        |                                                                              |
| City                      | `city`                  |                                                                              |
| State, province or region | `state_province_region` | A two-letter state code for US addresses. Free text for other countries.     |
| ZIP or postal code        | `postal_code`           |                                                                              |
| Country                   | `country`               | A two-letter code, such as US.                                               |
| The List IDs you enter    | `list_ids`              | An array of 36-character List IDs. SendGrid accepts up to 10 in one request. |

* **Not sent**: Phone, amount, fund, donation date, source code, UTM codes, referrer, Action Page custom fields and hidden fields aren't sent to SendGrid.
* **Hidden fields**: Hidden field values from the Action Page aren't sent, even when a hidden field uses a SendGrid field name. See [Hidden Fields](https://docs.anedot.com/action-pages/page-builder/hidden-fields.md).
* **Address**: Blank address parts are sent empty. When an address is present without a country, the country is sent as US.

## Payload Data

These are the request and response bodies shown in **Settings > Integrations > Integration Requests**. The stored request is the JSON body. It doesn't include your API key.

### Request Body

This example is a Donation Page submission with one List ID.

```json
{
  "list_ids": ["0f1e2d3c-aaaa-bbbb-cccc-1234567890ab"],
  "contacts": [{
    "address_line_1": "1340 Poydras Street",
    "address_line_2": "Suite 1770",
    "city": "New Orleans",
    "country": "US",
    "email": "annie.dot@example.com",
    "first_name": "Annie",
    "last_name": "Dot",
    "postal_code": "70112",
    "state_province_region": "LA"
  }]
}
```

### Success Response (Status 202)

SendGrid answers with status 202 and a `job_id` when it accepts the contact for processing.

```json
{
  "job_id": "01f0a230-b384-4125-aad2-c29513ae11e3"
}
```

### Failure Response (Status 401)

A 401 response means SendGrid didn't accept the API key.

```json
{
  "errors": [{
    "field": null,
    "message": "unauthorized"
  }]
}
```

## Troubleshooting

### No Row in Integration Requests

Check each of these:

* The Action Page is in the connection's scope, and in its Team if one is set.
* **Enabled** is checked.
* The submission has an email address.
* The donation is completed.
* The submission wasn't already sent to a SendGrid connection with the same API key.

See [Records Anedot Skips](https://docs.anedot.com/integrations/email-marketing-communication/sendgrid.md#records-anedot-skips).

### Rows Show Failure

Open the row in **Settings > Integrations > Integration Requests** and read SendGrid's response. A 401 response with the message `unauthorized` means the API key is wrong or was replaced in SendGrid. Also check that each List ID is the 36-character ID of a list in this SendGrid account, and that you entered no more than 10 List IDs.

Fix the cause, then use [Push Unsent Records](https://docs.anedot.com/integrations/email-marketing-communication/sendgrid.md#push-unsent-records). If the API key or List IDs were wrong, delete the connection and connect again with the right values first.

### Contact Hasn't Appeared Yet

A **Success** row means SendGrid accepted the contact for processing, and the contact can take a moment to appear. Search **Marketing > Contacts** by the person's email address.

### Some Fields Are Empty in SendGrid

Anedot only sends the contact fields in [Field Mapping](https://docs.anedot.com/integrations/email-marketing-communication/sendgrid.md#field-mapping). Hidden fields and custom fields from the Action Page aren't sent. The name fields are empty when the submission has no name.

### Connection Stopped Sending

Check that **Enabled** is checked on the connection. If the SendGrid API key was changed, or repeated authorization errors turned the connection off, delete the connection and connect again with a working API key.

If the issue continues, contact our Support team at <help@anedot.com>.

## Related Articles

* [Integrations](https://docs.anedot.com/integrations.md)
* [Integration Requests](https://docs.anedot.com/integrations/relay-data-troubleshooting/integration-requests.md)
* [Push Unsent in Webhooks (API)](https://docs.anedot.com/integrations/integration-automation-tools/webhooks.md#push-unsent)
* [Notifications](https://docs.anedot.com/get-started/security/notifications.md)
* [Permission Sets](https://docs.anedot.com/settings/access/permission-sets.md)
* [Teams](https://docs.anedot.com/settings/access/teams.md)
* [Commitments](https://docs.anedot.com/finance/management-and-reporting/commitments.md)
* [Hidden Fields](https://docs.anedot.com/action-pages/page-builder/hidden-fields.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.anedot.com/integrations/email-marketing-communication/sendgrid.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
