> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Move from SendGrid Canonical URL: https://posthog.com/docs/workflows/migrate/sendgrid > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.i.posthog.com` instead of `https://us.i.posthog.com` (ingestion host), and use `https://eu.posthog.com` instead of `https://app.posthog.com` (app host for links). ## On this page - [What moves](#what-moves) - [Run the import](#run-the-import) - [Switch your sending](#switch-your-sending) PostHog imports your SendGrid suppressions, unsubscribe groups, templates, and Single Sends in one background import. Or let your agent do it. Connect the [PostHog MCP](https://posthog.com/docs/workflows/mcp.md): ### Install the PostHog MCP ``` npx @posthog/wizard mcp add ``` [](https://claude.ai/directory/connectors/posthog)[](https://chatgpt.com/plugins/plugin_asdk_app_699caef2d680819188727b0ddbb349dd)[](https://posthog.com/docs/model-context-protocol/cursor.md)[](https://posthog.com/docs/model-context-protocol/vscode.md)[](https://posthog.com/docs/model-context-protocol/codex.md) Then ask: Ask your agentwith the [PostHog MCP](https://posthog.com/docs/workflows/mcp.md)[migrating-from-email-providers](https://posthog.com/docs/workflows/skills.md) “Move our email from SendGrid to PostHog.” Copy ## What moves | From SendGrid | In PostHog | | --- | --- | | Bounces and invalid addresses | [Suppression list](https://posthog.com/docs/workflows/email/suppression.md). Blocks all email. | | Spam reports | Suppression list. Blocks marketing email. SendGrid blocks all email to them. | | Global unsubscribes | Opted out of all marketing email | | Unsubscribe groups, and who left each | Marketing [categories](https://posthog.com/docs/workflows/email/opt-outs.md) and opt-outs | | Dynamic and legacy templates, and Design Library designs | Templates. Only the active version imports. | | Single Sends | Templates. Nothing sends, and anything scheduled stays scheduled in SendGrid. | | Verified senders, authenticated domains, and contact lists | A list, so you know what to set up | SendGrid's API only shares stats for automations, so rebuild them as [automations](https://posthog.com/docs/workflows/automations.md). Blocks, webhooks, API keys, stats, send history, and inactive template versions stay in SendGrid. ## Run the import 1. Create a **restricted** API key in [SendGrid](https://app.sendgrid.com/settings/api_keys) with read access to what you import: suppressions, unsubscribe groups, templates, the Design Library, marketing, and sender authentication. Each step in PostHog lists the scopes it needs. PostHog checks the key before it starts, and names any scope a selected step is missing. It deletes the key when the import ends. 2. Go to [**Messaging** > **Opt-outs**](https://app.posthog.com/workflows/opt-outs) and click **Import from another tool**. 3. Pick **SendGrid**, paste the key, pick what to import, and click **Start import**. ![The SendGrid import, with the key field and the list of steps and their scopes](https://res.cloudinary.com/dmukukwp6/image/upload/w_1600,c_limit,q_auto,f_auto/sendgrid_import_light_d19c2e9b59.png) A key belongs to one account, so import each subuser with its own key. ## Switch your sending ### 1\. Set up your domain [Set up your domain](https://posthog.com/docs/workflows/domain.md) in PostHog, and publish its DNS records. PostHog needs its own records, even for a domain that already sends through SendGrid. Keep SendGrid's records until nothing sends through it. ### 2\. Move your transactional email Change your code one email at a time, starting with a low-risk one. You need a [project secret API key](https://posthog.com/docs/workflows/transactional/send-from-code.md#create-an-api-key). These examples use Node.js. Each [SDK page](https://posthog.com/docs/workflows/installation/quick-start.md#install-an-sdk) has the same send in its language. If your code writes the HTML, send it as it is. Name the email with a `templateKey`, so PostHog groups its metrics and logs. Before, with SendGrid: ```javascript import sgMail from "@sendgrid/mail" sgMail.setApiKey(process.env.SENDGRID_API_KEY) await sgMail.send({ from: "Hedgebox ", to: "jane@example.com", subject: "Reset your password", html, }) ``` After, with PostHog: ```javascript import { PostHog } from "posthog-node" const posthog = new PostHog("", { host: "https://us.i.posthog.com", secretKey: process.env.POSTHOG_PROJECT_SECRET_API_KEY, }) const { error } = await posthog.emails.send({ from: "Hedgebox ", to: "jane@example.com", templateKey: "password-reset", subject: "Reset your password", html, distinctId: userId, }) ``` If you send a SendGrid template, the import copied it into PostHog. The import doesn't make it transactional, because it can't tell which templates your app sends, and a transactional email skips opt-outs and the frequency cap. Open it in the [email library](https://posthog.com/docs/workflows/email/library.md), [make it transactional](https://posthog.com/docs/workflows/transactional/templates.md#use-an-existing-template), and copy its template ID from its **API** tab. The values that you sent in `dynamicTemplateData` become its variables. Before, with SendGrid: ```javascript await sgMail.send({ from: "Hedgebox ", to: "jane@example.com", templateId: "d-1a2b3c4d5e6f", dynamicTemplateData: { first_name: "Jane", plan: "Pro" }, }) ``` After, with PostHog: ```javascript const { error } = await posthog.emails.send({ to: "jane@example.com", templateId: "", templateData: { first_name: "Jane", plan: "Pro" }, distinctId: userId, }) ``` A send to an address on the [suppression list](https://posthog.com/docs/workflows/email/suppression.md) fails with `recipient_suppressed`. Don't retry it. ### 3\. Rebuild your automations The import doesn't bring over SendGrid automations. Rebuild each one with the imported templates, and turn it off in SendGrid when its PostHog automation goes live. ### Watch for - **Global unsubscribes:** SendGrid stops transactional email to these people. PostHog doesn't, so receipts and password resets still reach them. - **Images:** the import keeps each image's address. An image that SendGrid hosts stops loading once you close your SendGrid account, so copy it into PostHog first. Ask your agentwith the [PostHog MCP](https://posthog.com/docs/workflows/mcp.md)[migrating-from-email-providers](https://posthog.com/docs/workflows/skills.md) “Copy the images that SendGrid hosts in our imported templates into PostHog, and point the templates at the copies.” Copy See [switch over safely](https://posthog.com/docs/workflows/migrate.md#switch-over-safely) for the full checklist.