Sendgrid
This page contains the setup guide and reference information for the Sendgrid source connector.
Prerequisites
- API Key
Setup guide
Step 1: Set up Sendgrid
- Sendgrid Account
- Create Sendgrid API Key with the following permissions:
- Read-only access to all resources
- Full access to marketing resources
Step 2: Set up the Sendgrid connector in Airbyte
For Airbyte Cloud:
- Log into your Airbyte Cloud account.
- In the left navigation bar, click Sources. In the top-right corner, click +new source.
- On the Set up the source page, enter the name for the Sendgrid connector and select Sendgrid from the Source type dropdown.
- Enter your
apikey
. - Enter your
start_time
. - Click Set up source.
For Airbyte OSS:
- Navigate to the Airbyte Open Source dashboard.
- Set the name for your source.
- Enter your
apikey
. - Enter your
start_time
. - Click Set up source.
Supported sync modes
The Sendgrid source connector supports the following sync modes:
Supported Streams
- Campaigns
- Lists
- Contacts
- Stats automations
- Segments
- Single Sends
- Templates
- Global suppression (Incremental)
- Suppression groups
- Suppression group members
- Blocks (Incremental)
- Bounces (Incremental)
- Invalid emails (Incremental)
- Spam reports
Connector-specific features & highlights, if any
We recommend creating a key specifically for Airbyte access. This will allow you to control which resources Airbyte should be able to access. The API key should be read-only on all resources except Marketing, where it needs Full Access.
Sendgrid provides two different kinds of marketing campaigns, "legacy marketing campaigns" and "new marketing campaigns". Legacy marketing campaigns are not supported by this source connector.
If you are seeing a 403 FORBIDDEN error message for https://api.sendgrid.com/v3/marketing/campaigns
, it might be because your SendGrid account uses legacy marketing campaigns.
Performance considerations
The connector is restricted by normal Sendgrid requests limitation.
Build instructions
Build your own connector image
This connector is built using our dynamic built process.
The base image used to build it is defined within the metadata.yaml file under the connectorBuildOptions
.
The build logic is defined using Dagger here.
It does not rely on a Dockerfile.
If you would like to patch our connector and build your own a simple approach would be:
- Create your own Dockerfile based on the latest version of the connector image.
FROM airbyte/source-sendgrid:latest
COPY . ./airbyte/integration_code
RUN pip install ./airbyte/integration_code
# The entrypoint and default env vars are already set in the base image
# ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
# ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
Please use this as an example. This is not optimized.
- Build your image:
docker build -t airbyte/source-sendgrid:dev .
# Running the spec command against your patched connector
docker run airbyte/source-sendgrid:dev spec
Customizing our build process
When contributing on our connector you might need to customize the build process to add a system dependency or set an env var.
You can customize our build process by adding a build_customization.py
module to your connector.
This module should contain a pre_connector_install
and post_connector_install
async function that will mutate the base image and the connector container respectively.
It will be imported at runtime by our build process and the functions will be called if they exist.
Here is an example of a build_customization.py
module:
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
# Feel free to check the dagger documentation for more information on the Container object and its methods.
# https://dagger-io.readthedocs.io/en/sdk-python-v0.6.4/
from dagger import Container
async def pre_connector_install(base_image_container: Container) -> Container:
return await base_image_container.with_env_variable("MY_PRE_BUILD_ENV_VAR", "my_pre_build_env_var_value")
async def post_connector_install(connector_container: Container) -> Container:
return await connector_container.with_env_variable("MY_POST_BUILD_ENV_VAR", "my_post_build_env_var_value")
Changelog
Version | Date | Pull Request | Subject |
---|---|---|---|
0.4.1 | 2023-10-13 | 31377 | Use our base image and remove Dockerfile |
0.4.0 | 2023-05-19 | 23959 | Add unsubscribe_groups stream |
0.3.1 | 2023-01-27 | 21939 | Fix contacts missing records; Remove Messages stream |
0.3.0 | 2023-01-25 | 21587 | Make sure spec works as expected in UI - make start_time parameter an ISO string instead of an integer interpreted as timestamp (breaking, update your existing connections and set the start_time parameter to ISO 8601 date time string in UTC) |
0.2.16 | 2022-11-02 | 18847 | Skip the stream on 400, 401 - authorization required with log message |
0.2.15 | 2022-10-19 | 18182 | Mark the sendgrid api key secret in the spec |
0.2.14 | 2022-09-07 | 16400 | Change Start Time config parameter to datetime string |
0.2.13 | 2022-08-29 | 16112 | Revert back to Python CDK |
0.2.12 | 2022-08-24 | 15911 | Bugfix to allowing reading schemas at runtime |
0.2.11 | 2022-08-19 | 15800 | Bugfix to allow reading sentry.yaml at runtime |
0.2.10 | 2022-08-17 | 15734 | Fix yaml based on the new schema validator |
0.2.9 | 2022-08-11 | 15257 | Migrate to config-based framework |
0.2.8 | 2022-06-07 | 13571 | Add Message stream |
0.2.7 | 2021-09-08 | 5910 | Add Single Sends Stats stream |
0.2.6 | 2021-07-19 | 4839 | Gracefully handle malformed responses from the API |