> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Linking Mailgun as a source Canonical URL: https://posthog.com/docs/data-pipelines/sources/mailgun > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.posthog.com` instead of `https://app.posthog.com` (app host for links). ## On this page - [Adding a data source](#adding-a-data-source) - [Available tables](#available-tables) - [Sync limitations](#sync-limitations) - [Configuration](#configuration) - [Supported tables](#supported-tables) ![](https://res.cloudinary.com/dmukukwp6/image/upload/texture_tan_9608fcca70) ![](https://res.cloudinary.com/dmukukwp6/image/upload/texture_tan_dark_a92b0e022d) Let AI connect your sources for you Skip the manual setup — run this in your project and the wizard auto-detects your databases and APIs and connects them to PostHog. `npx @posthog/wizard warehouse` ![PostHog Wizard hedgehog](https://res.cloudinary.com/dmukukwp6/image/upload/wizard_3f8bb7a240.png) ![](https://res.cloudinary.com/dmukukwp6/image/upload/wizard_3f8bb7a240.png)Let AI connect your sources for you The Mailgun connector syncs your transactional and bulk email data into PostHog, including events, bounces, complaints, unsubscribes, templates, and more. ## Adding a data source 1. Go to the [sources tab](https://app.posthog.com/data-management/sources) of the data pipeline section in PostHog. 2. Click **\+ New source** and then click **Link** next to Mailgun. 3. Enter your **Private API key**. You can find this in the [Mailgun dashboard](https://app.mailgun.com/settings/api_security) under **Settings** > **API security**. 4. Select your **Region** — choose **US** (`api.mailgun.net`) or **EU** (`api.eu.mailgun.net`) to match where your Mailgun account is hosted. 5. Click **Next**. 6. Select the tables you want to sync, set the sync method and frequency, then click **Import**. Once the syncs are complete, you can start using Mailgun data in PostHog. ## Available tables | Table | Description | Sync method | | --- | --- | --- | | `allowlist` | Allowlisted email addresses or domains that Mailgun never adds to the bounce list, per domain | Full refresh | | `bounces` | Bounced email addresses per domain | Full refresh | | `complaints` | Spam complaint addresses per domain | Full refresh | | `domains` | Sending domains configured in your Mailgun account | Full refresh | | `events` | Email events such as deliveries, opens, clicks, and bounces | Incremental | | `logs` | Account-wide message events from the Logs API (accepted, delivered, failed, opened, clicked) | Incremental | | `mailing_list_members` | Members of mailing lists | Full refresh | | `mailing_lists` | Mailing lists | Full refresh | | `subaccounts` | Subaccounts under the Mailgun account | Full refresh | | `tags` | Tags per domain | Full refresh | | `templates` | Email templates per domain | Full refresh | | `unsubscribes` | Unsubscribed addresses per domain | Full refresh | **Incremental** tables sync only new records on each run. **Full refresh** tables reload all data on each sync. ## Sync limitations - **Incremental sync for events and logs** – Only the `events` and `logs` tables support incremental syncing using the `timestamp` field. All other tables use full refresh because those Mailgun API endpoints don't expose a server-side time filter. - **Event retention limits** – Mailgun retains events for a limited period depending on your plan (1 day on free plans, up to 30 days on paid plans). The initial events sync is bounded by your plan's retention window. - **30-minute event lag** – Events sync with a 30-minute lag to account for Mailgun's eventual consistency. Recent events within this window appear on the next sync. - **30-day lookback for logs** – The `logs` table reads from the account-wide Logs API with a 30-day lookback window. Like the `events` table, it syncs with a 30-minute lag for consistency. - **Domain-scoped data** – Most tables (`events`, `bounces`, `complaints`, `unsubscribes`, `allowlist`, `tags`, `templates`) are scoped per sending domain. The source automatically enumerates all your domains and syncs data for each one. A `domain` column is added to these tables so records stay unique across domains. - **List-scoped data** – The `mailing_list_members` table is scoped per mailing list. A `list_address` column identifies which list each member belongs to. ## Configuration | Option | Type | Required | | --- | --- | --- | | `Private API key` | password | Yes | | `Region` | select | Yes | ## Supported tables | Table | Description | Sync method | Incremental field | Primary key | | --- | --- | --- | --- | --- | | `domains` | A sending domain configured on the Mailgun account. | Full refresh | — | — | | `events` | An event in the Mailgun event log (delivered, opened, clicked, bounced, etc.) for a domain. | Incremental, Full refresh | timestamp | — | | `bounces` | A bounced recipient address recorded for a domain in Mailgun's suppression list. | Full refresh | — | — | | `complaints` | A spam complaint recorded for a domain in Mailgun's suppression list. | Full refresh | — | — | | `unsubscribes` | An unsubscribed recipient address recorded for a domain in Mailgun's suppression list. | Full refresh | — | — | | `allowlist` | An address or domain on a sending domain's allowlist, which Mailgun never adds to the bounce list. | Full refresh | — | — | | `mailing_lists` | A mailing list configured on the Mailgun account, addressable by a single list address. | Full refresh | — | — | | `mailing_list_members` | A member of a mailing list on the Mailgun account. | Full refresh | — | — | | `tags` | A tag used to categorize and track messages for a domain in Mailgun. | Full refresh | — | — | | `templates` | A stored, reusable message template for a domain in Mailgun. | Full refresh | — | — | | `subaccounts` | A subaccount under the Mailgun account, used to separate sending for different teams or customers. | Full refresh | — | — | | `metrics` | Daily sending, delivery and engagement metrics for the whole Mailgun account. | Incremental, Full refresh | time | — | | `domain_metrics` | Daily sending, delivery and engagement metrics for each sending domain. | Incremental, Full refresh | time | — | | `tag_metrics` | Daily sending, delivery and engagement metrics for each message tag. | Incremental, Full refresh | time | — | | `country_metrics` | Daily engagement metrics for each country, from the IP of the opening or clicking recipient. Non-engagement counts fall under Unknown. | Incremental, Full refresh | time | — | | `recipient_provider_metrics` | Daily sending, delivery and engagement metrics for each recipient mailbox provider, such as Gmail or Outlook 365. | Incremental, Full refresh | time | — | | `logs` | A message event from the account-wide Logs API, such as an accepted, delivered, failed, opened or clicked message. | Incremental, Full refresh | timestamp | — | | `webhook_events` | An event pushed by a Mailgun webhook (accepted, delivered, opened, clicked, failed, complained, unsubscribed). Same shape as an events row, but kept past Mailgun's retention window and without a sending domain, which webhook payloads don't carry. | Webhook only | — | — |