# How to integrate Twilio SendGrid

Use integration with [Twilio SendGrid](https://sendgrid.com/) to automatically sync client data from B2CORE and use it in SendGrid for managing email lists, sending transactional and marketing emails, and tracking email performance.

{% hint style="info" %}
Before proceeding with the instructions, you must have signed up for SendGrid and have an active account.
{% endhint %}

## How to configure a connection to SendGrid

To configure a connection to SendGrid in the B2CORE Back Office:

{% stepper %}
{% step %}
Navigate to **System** > **External connections**.
{% endstep %}

{% step %}
Click **+Create** in the upper-right page corner.
{% endstep %}

{% step %}
On the **Create connection** page, fill in the following fields:

* In the **Name** field, enter a name for the connection. The name must be unique.
* In the **Caption** field, enter a caption that will be applied to the connection in the Back Office.
* In the **Provider** dropdown, select **SendGrid**.
  {% endstep %}

{% step %}
Click **Save** to create the connection.

The **SendGrid** connection will appear in the list of external connections.
{% endstep %}

{% step %}
Click **Edit** to enter the connection details and complete the following fields:

* In the **API URL** field, enter the base URL for your SendGrid region:

  * `https://api.sendgrid.com/v3/` — for SendGrid accounts registered in the **US region**.
  * `https://api.eu.sendgrid.com/v3/` — for SendGrid accounts registered in the **EU region**.

  You can find your **Base URL** in SendGrid by navigating to **Settings** > **Account Details**.
* In the **API key** field, enter your SendGrid API key.

  The **API key** can be generated in SendGrid by navigating to **Settings** > **API Keys** and creating a key with the required permissions:

  * **Full access** — access to all SendGrid functionalities.
  * **Restricted access** — limited access only to selected functionalities, for example, access to **Marketing Campaigns** or contact lists.
    {% endstep %}

{% step %}
Check the connection status.

If the connection is inactive (**No** is displayed in the **Enabled** field), activate it by setting the **Enabled** dropdown to **Yes**.
{% endstep %}

{% step %}
Click **Save** to apply the changes.
{% endstep %}
{% endstepper %}

After configuring the connection, all clients listed under **Clients** > **General** in the B2CORE Back Office will be automatically synced with SendGrid and added as contacts. Any further updates to their personal details will also be synced with SendGrid.

## Overview of client data synced with SendGrid

The following required and optional client fields can be synced from B2CORE to SendGrid contacts:

### Required fields

The following required client fields are always synced from B2CORE to SendGrid:

* **Email**
* **First name**
* **Last name**

### Optional fields

The following optional fields, which can be useful for business processes, are synced from B2CORE to SendGrid if they are specified in the client details in the B2CORE Back Office:

* **Address**
* **City**
* **State**
* **Postal code**
* **Country**
* **Phone** — if multiple phone numbers are specified for a client in the B2CORE Back Office, the confirmed number is sent to SendGrid; if none is confirmed, the most recently updated number is used.

## How to add custom fields for syncing from B2CORE to SendGrid

You can sync additional fields from B2CORE to SendGrid, such as a client’s **Status**, **Client type**, **Verification level**, and **Jurisdiction** to reflect them in SendGrid contacts.

In **SendGrid**, add these fields:

{% stepper %}
{% step %}
Sign in to your SendGrid account.
{% endstep %}

{% step %}
In the **Marketing Campaigns** section, click **Marketing** > **Contacts** > **Custom Fields**.
{% endstep %}

{% step %}
Click **Create Custom Field**.
{% endstep %}

{% step %}
Enter the field name, select the appropriate field type, and specify other parameters.
{% endstep %}

{% step %}
Save the changes to add the new custom field.
{% endstep %}
{% endstepper %}

In the **B2CORE Back Office**, set up field mapping:

{% stepper %}
{% step %}
Navigate to **System** > **External connections**.
{% endstep %}

{% step %}
Find the connection configured for SendGrid and click **Edit** to open the connection details.
{% endstep %}

{% step %}
Set up the field mapping by selecting the corresponding fields created in SendGrid for **Status**, **Client type**, **Verification level**, and **Jurisdiction**.

<figure><img src="/files/AP24AX1ngXqZh4GVgl7g" alt="Set up field mapping"><figcaption><p>Set up field mapping</p></figcaption></figure>
{% endstep %}

{% step %}
Click **Save** to apply the changes.
{% endstep %}
{% endstepper %}

Once the fields are added and mapped, the client’s **Status**, **Client type**, **Verification level**, and **Jurisdiction** are automatically synced from B2CORE and displayed in SendGrid contacts. If one or more fields aren't mapped, they won't be synced to SendGrid contacts.

## How to sync clients from B2CORE to specific lists in SendGrid

Lists in SendGrid are the Marketing Campaigns feature that helps you organize contacts and manage email campaigns.

In SendGrid, create one or more lists:

{% stepper %}
{% step %}
Sign in to your SendGrid account.
{% endstep %}

{% step %}
Go to **Marketing** > **Contacts** > **Lists & Segments**
{% endstep %}

{% step %}
Click **Create List**.
{% endstep %}

{% step %}
Enter the list name.
{% endstep %}

{% step %}
Click **Save** to create the list.
{% endstep %}
{% endstepper %}

In the B2CORE Back Office, select the list for syncing:

{% stepper %}
{% step %}
Sign in to the B2CORE Back Office.
{% endstep %}

{% step %}
Navigate to **System** > **External connections**.
{% endstep %}

{% step %}
Find the connection configured for SendGrid and click **Edit** to open the connection details.
{% endstep %}

{% step %}
In the **List** dropdown, select the desired list created in SendGrid. This will ensure all synced clients from B2CORE are added to that list.

If no list is selected, synced clients won't be added to any list.

<figure><img src="/files/UBd5ZA8e1HeBes8obr9w" alt="Select the SendGrid list to sync clients from B2CORE"><figcaption><p>Select the SendGrid list to sync clients from B2CORE/p></p></figcaption></figure>
{% endstep %}

{% step %}
Click **Save** to apply the changes.
{% endstep %}
{% endstepper %}

Once the list added and mapped, all clients from B2CORE will be automatically synced to the specified list in SendGrid. Any new registrations or updates to existing clients will also reflect in the same list.


---

# 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.b2core.b2broker.com/how-to-articles/manage-communication-platforms/how-to-integarte-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.
