# Sendgrid

## 1. How to connect to Sendgrid?

You can follow the following steps to build a connection with your Sendgrid. If you need any helps to set up your integration, please [contact us](/master.md#how-to-contact-us).

1\. Go to the **Resources** page and click the **Add Resource** button.

2\. In the "Select a data source" step, select **Sendgrid** under **Apps**.

3\. In the "Configure the data source" step, enter the following information:

* **`Start Date (UTC)`**: Retrieve data from a specific date and time. The date should be defined in  UTC date and time, such as 2017-01-25T00:00:00Z.
* **`API Token`**: The value of the API token generated. See [here](#2.-how-to-get-sendgrid-api-key) to get an API token.

4\. In the "Select the tables", choose tables that you want to connect. See [here](#4.-available-tables) for more details on each table.

5\. Click **Finish Setup**. You will see a  <img src="/files/-MgBo4LSmdK4OS-NqLZy" alt="" data-size="line"> icon next to your Sendgrid resource. It may take a few minutes to several hours depending on the data size and the number of your tables. Once your APP's data is ready, you will receive a notification email.&#x20;

## 2. How to get Sendgrid API key?

1\. Log into your Sendgrid account, navigate to **Settings** on the left navigation bar, and then select **API Keys**.

2\. Click **Create API Key**.

3\. Give your API key a name and select **Restricted Access** with the following permission:

* Read-only access to all resources
* Full access to marketing resources

![](/files/-MftX-ZLPwxK15uZWfcE)

4\. Click **Create & View.**&#x20;

5\. Copy your API key and save it somewhere safe. (You will only be shown your API key one time. Please store it somewhere safe as we will not be able to retrieve or restore it.)

![](/files/-MftXFlRF_IcgdtKPu6X)

## 3. How to set up Data Sync?

Acho supports creating schedulers to retrieve the latest data from your Sendgrid account at a certain time interval. To see more details, you can visit [here](https://docs.acho.io/data-sync/untitled).

## 4. Available Tables

* [Blocks](/acho-studio/resources/import-data/sendgrid.md#blocks)
* [Bounces](/acho-studio/resources/import-data/sendgrid.md#bounces)
* [Campaigns](/acho-studio/resources/import-data/sendgrid.md#campaigns)
* [Contacts](/acho-studio/resources/import-data/sendgrid.md#contacts)
* [Global Suppressions](/acho-studio/resources/import-data/sendgrid.md#global-suppressions-global-unsubscriptions)
* [Lists](/acho-studio/resources/import-data/sendgrid.md#lists)
* [Invalid Emails](/acho-studio/resources/import-data/sendgrid.md#invalid-emails)
* [Segments](/acho-studio/resources/import-data/sendgrid.md#segments)
* [State Automations](/acho-studio/resources/import-data/sendgrid.md#stats-automations)
* [Spam Reports](/acho-studio/resources/import-data/sendgrid.md#spam-reports)
* [Suppression Group Members](/acho-studio/resources/import-data/sendgrid.md#suppression-group-members)
* [Suppression Groups](/acho-studio/resources/import-data/sendgrid.md#suppression-groups)
* [Templates](/acho-studio/resources/import-data/sendgrid.md#templates)

#### Blocks

The Blocks table allows you to retrieve all email addresses that are currently on your blocks list. Generally, blocks happen when your email is rejected because of an issue with the message itself rather than an issue with the recipient's address.&#x20;

| Column Name | Type    | Description                                                                      |
| ----------- | ------- | -------------------------------------------------------------------------------- |
| created     | Integer | A Unix timestamp indicating when the email address was added to the blocks list. |
| email       | String  | The email address that was added to the block list.                              |
| reason      | String  | An explanation for the reason of the block.                                      |
| status      | String  | The status of the block.                                                         |

#### Bounces

The table retrieves all of your bounced emails. An email is considered [bounced](https://sendgrid.com/docs/glossary/bounces/) when the message is undeliverable and then returned to the server that sent it. Bounced emails can be either permanent or temporary failures to deliver the message.

| Column Name | Type    | Description                                                                      |
| ----------- | ------- | -------------------------------------------------------------------------------- |
| created     | Integer | A Unix timestamp indicating when the email address was added to the blocks list. |
| email       | String  | The email address that was added to the block list.                              |
| reason      | String  | An explanation for the reason of the block.                                      |
| status      | String  | The status of the block.                                                         |

#### Campaigns

#### Contacts

| Column Name             | Type           | Description                                                        |
| ----------------------- | -------------- | ------------------------------------------------------------------ |
| id                      | Integer        | The generated ID for the contact.                                  |
| address\_line\_1        | string         | The first line of the address.                                     |
| address\_line\_2        | string         | An optional second line for the address.                           |
| alternate\_emails       | array\[string] | Additional emails associated with the contact.                     |
| city                    | string         | The contact's city.                                                |
| country                 | string         | The contact's country. Can be a full name or an abbreviation.      |
| email                   | string         | The contact's primary email. This is required to be a valid email. |
| first\_name             | string         | The contact's personal name.                                       |
| last\_name              | string         | The contact's family name.                                         |
| postal\_code            | string         | The contact's ZIP code or other postal code.                       |
| state\_province\_region | string         | The contact's state, province, or region.                          |
| whatsapp                | String         |                                                                    |
| line                    | String         |                                                                    |
| facebook                | String         |                                                                    |
| list\_ids               | Array\[String] |                                                                    |
| \_metadata              | Object         |                                                                    |
| unique\_name            | String         |                                                                    |
| updated\_at             | String         |                                                                    |
| created\_at             | String         |                                                                    |
| custom\_fields          | Object         |                                                                    |

####

#### Global Suppressions (Global unsubscriptions)

This table retrieves a list of emails in the global suppressions (unsubscrptions) group. A global suppression is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send.

| Column Name | Type    | Description                                                    |
| ----------- | ------- | -------------------------------------------------------------- |
| created     | Integer | A Unix timestamp indicating when the recipient was added       |
| email       | String  | The email address of the recipient who is globally suppressed. |

#### Lists

Lists are static collections of Marketing Campaigns contacts.&#x20;

| Column Name | Type   | Description                     |
| ----------- | ------ | ------------------------------- |
| id          | STRING | The generated ID for your list. |
| name        | STRING | <p>The name you gave your list. |

</p><p></p>         |
| contact\_count | INTEGER | The number of contacts currently stored on the list. |
| \_metadata     | Object  |                                                      |

#### Invalid Emails

The table retrieves a list of all invalid email addresses. An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards (such as addresses without the “@” sign) or the email does not exist at the recipient’s mail server.

| Column Name | Type    | Description                                                                              |
| ----------- | ------- | ---------------------------------------------------------------------------------------- |
| created     | Integer | A Unix timestamp indicating when the email address was added to the invalid emails list. |
| email       | String  | The email address that was marked as invalid.                                            |
| reason      | String  | The reason that the email address was marked as invalid.                                 |

#### Segments

This table allows you to retrieve information for all segments. Segments are similar to contact lists, except they update dynamically over time as information stored about your contacts or the criteria used to define your segments changes. When you segment your audience, you are able to create personalized Automation emails and Single Sends that directly address the wants and needs of your particular audience.

| Column Name          | Type    | Description                                                                                                                                                                                       |
| -------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id                   | String  | The generated uuid for a specific segment.                                                                                                                                                        |
| contact\_count       | Integer | The number of contacts in the segment.                                                                                                                                                            |
| created\_at          | String  | ISO8601 of created timestamp.                                                                                                                                                                     |
| name                 | String  | The name of the segment.                                                                                                                                                                          |
| parent\_list\_id     | String  | The id of the list if this segment is a child of a list.                                                                                                                                          |
| sample\_updated\_at  | String  | ISO8601 timestamp the sample was last updated.                                                                                                                                                    |
| updated\_at          | String  | ISO8601 timestamp the object was last updated.                                                                                                                                                    |
| next\_sample\_update | String  | ISO8601 string that is equal to `sample_updated_at` plus an internally calculated offset that depends on how often contacts enter or exit segments as the scheduled pipeline updates the samples. |

#### Stats Automations

| Name        | Type   | Description                                                                                                                                                                                                |
| ----------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id          | String | This is the ID of the Automation you are requesting stats for.                                                                                                                                             |
| aggregation | String | This describes the time unit to which the stat is rolled up. It is based on the `aggregated_by` parameter included in the request. It can be "total" or the date (in YYYY-MM-DD format) the stats are for. |
| step\_id    | String | This is the ID of the step if the stats were requested to be grouped by `step_id`.                                                                                                                         |
| stats       | Object |                                                                                                                                                                                                            |

#### Spam Reports

This table retrieves all spam reports. Spam Reports are triggered when a recipient marks one of your emails as spam. Spam reports can only be gathered from Internet Service Providers (ISPs) that provide a feedback loop.

| Column Name | Type    | Description                                                                     |
| ----------- | ------- | ------------------------------------------------------------------------------- |
| created     | Integer | A Unix timestamp that indicates when the recipient marked your message as spam. |
| email       | String  | The email address of the recipient that marked your message as spam.            |
| ip          | String  | The IP address that the message was sent from.                                  |

#### Suppression Group Members

This table retrieves all suppressed email addresses and their suppression groups. Suppressions are recipient email addresses that are added to unsubscribe groups. Once a recipient's address is on the suppressions list for an unsubscribe group, they will not receive any emails that are tagged with that unsubscribe group.

| Column Name | Type    | Description                                                                            |
| ----------- | ------- | -------------------------------------------------------------------------------------- |
| email       | String  | The email addresses you added to the unsubscribe group                                 |
| group\_id   | Integer | The ID of the suppression group.                                                       |
| created\_at | Integer | A Unix timestamp indicating when the email address was added to the suppression group. |
| group\_bane | String  | The name of the suppression group.                                                     |

#### Suppression Groups

Suppression groups, or unsubscribe groups, are specific types or categories of emails from which you would like your recipients to be able to unsubscribe. For example: Daily Newsletters, Invoices, and System Alerts are all potential suppression groups. This table retrieves information for all of your suppression groups.

| Column Name | Type    | Description                                         |
| ----------- | ------- | --------------------------------------------------- |
| id          | Integer | The ID of the suppression group.                    |
| name        | String  | The name of the suppression group.                  |
| description | String  | A brief description of the suppression group.       |
| is\_default | boolean | Indicates if this is the default suppression group. |

#### Templates

This endpoint allows you to create a transactional template. An HTML template that can establish a consistent design for transactional emails. Transactional templates are templates created specifically for transactional email and are not to be confused with Marketing Campaigns designs.

| Column Name | Type           | Description                                                             |
| ----------- | -------------- | ----------------------------------------------------------------------- |
| id          | String         | The ID of the transactional template.                                   |
| name        | String         | The name for the transactional template.                                |
| versions    | Array\[Object] | The different versions of this transactional template.                  |
| generation  | String         | Defines the generation of the template.                                 |
| updated\_at | String         | The date and time that this transactional template version was updated. |


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.acho.io/acho-studio/resources/import-data/sendgrid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
