Skip to main content

Mailgun

Mailgun is a transactional email API service for sending, receiving, and tracking emails at scale. It provides REST endpoints for domain management, event and analytics tracking, suppression list management, and message delivery, letting you integrate email operations into your data flows.

Mailgun icon

Power end-to-end data operations for your Mailgun API with Nexla. Our bi-directional Mailgun connector is purpose-built for Mailgun, making it simple to ingest data, sync it across systems, and deliver it anywhere — all with no coding required. Nexla turns API-sourced data into ready-to-use, reusable data products and makes it easy to send data to Mailgun or any other destination. With comprehensive monitoring, lineage tracking, and access controls, Nexla keeps your Mailgun workflows fast, secure, and fully governed.

Features

Type: API

SourceDestination

  • Seamless API Integration: Connect to any endpoint as source or destination without coding, with automatic data product creation
  • Visual Composition & Chaining: Build complex integrations using visual templates, chain API calls, and compose workflows with data validation and filtering
  • API Proxy: Expose curated slices of your data securely with a secure and customizable API proxy that validates and transforms data on the fly
  • Request optimization with intelligent batching, retry, and caching to minimize API calls and costs

Prerequisites

Before creating a Mailgun credential, you need a Mailgun account and your account's private API key. Mailgun authenticates every API request using HTTP Basic Auth, where the username is api and the password is your private API key.

To obtain your Mailgun API key, follow these steps:

  1. Sign in to your Mailgun account at app.mailgun.com.

  2. Click your account menu in the upper-right corner and select API Keys, or navigate to Account Settings > API Keys.

  3. Locate the Private API key and click the eye icon to reveal it, then copy the key and store it securely. The private key grants access to account and domain operations, so it should be kept confidential.

  4. Determine the correct base URL for your account region. Use https://api.mailgun.net if your account is hosted in the US region, or https://api.eu.mailgun.net if your account is hosted in the EU region. Your account region is shown in your Mailgun dashboard.

Mailgun issues two categories of keys: account API keys, which can view and modify most aspects of your account and domains, and domain sending keys, which are limited to sending messages for a single domain. The connector uses HTTP Basic Auth for all endpoints, so an account API key is required for management and reporting endpoints.

For complete information about API keys, authentication, and base URLs, see the Mailgun Authentication documentation.

Authenticate

Credentials required

HTTP Basic Authentication using your Mailgun API key. The API key is passed as the username; password is left empty.

FieldRequiredSecretDescription
Username Or API KeyYesYesYour username or personal API Key
PasswordYesYesYour password
Base URLYesNoThe base URL for the Mailgun API. Use https://api.mailgun.net for US region or https://api.eu.mailgun.net for EU region.

Create a credential in Nexla

  1. After selecting the data source/destination type, click the Add Credential tile to open the Add New Credential overlay.

  2. Enter a name for the credential in the Credential Name field and a short, meaningful description in the Credential Description field.

  3. Enter your Mailgun API credentials in the Username Or API Key and Password fields. Following Mailgun's HTTP Basic Auth scheme, enter api as the username and your private API key as the password. Both values are stored securely and used to authenticate all requests to the Mailgun API.

  4. Enter the Base URL for your account region. Use https://api.mailgun.net for the US region or https://api.eu.mailgun.net for the EU region. This URL is used as the prefix for all endpoint requests.

  5. Click the Save button at the bottom of the overlay. The newly added credential will now appear in a tile on the Authenticate screen during data source/destination creation.

Use as a data source

To create a new data flow, navigate to the Integrate section, and click the New Data Flow button. Select the Mailgun connector tile, then select the credential that will be used to connect to Mailgun, and click Next; or, create a new Mailgun credential for use in this flow.

Endpoint templates

Nexla provides pre-built templates that can be used to rapidly configure data sources to ingest data from common Mailgun endpoints. Select the endpoint from which this source will fetch data from the Endpoint pulldown menu. Available endpoint templates are listed in the expandable boxes below.

[Rest API] List Domains

Returns a list of all domains configured in your Mailgun account.

  • This endpoint retrieves every sending domain accessible to your API key. Results are paginated, and Nexla automatically fetches subsequent pages until all records have been ingested.

[Rest API] Get Domain

Retrieve details for a specific sending domain by name.

  • Provide the domain name in the Domain Name field. This endpoint returns the configuration and status details for that single domain.

[Rest API] List Events

Returns a list of events (e.g., deliveries, bounces, complaints) for your Mailgun account.

  • This endpoint uses cursor-based pagination. Nexla follows the next-page link returned by the API to retrieve the full event stream.

[Rest API] List Bounces

Returns a list of permanent delivery failures (bounces) for a given domain.

  • Provide the sending domain in the Domain field. Results are paginated, and Nexla automatically fetches subsequent pages until all records have been ingested.

[Rest API] List Unsubscribes

Returns a list of addresses that have unsubscribed from your mailing list for a given domain.

  • Provide the sending domain in the Domain field. Results are paginated, and Nexla automatically fetches subsequent pages until all records have been ingested.

[Rest API] List Complaints

Returns a list of email addresses that have filed spam complaints against your domain.

  • Provide the sending domain in the Domain field. Results are paginated, and Nexla automatically fetches subsequent pages until all records have been ingested.

[Rest API] List Routes

Returns a list of all routes defined in your Mailgun account for handling incoming emails.

  • This endpoint retrieves every inbound routing rule in your account. Results are paginated, and Nexla automatically fetches subsequent pages until all records have been ingested.

[Rest API] Get Route

Retrieve details for a specific Mailgun inbound email routing rule by ID.

  • Provide the route identifier in the Route ID field. This endpoint returns the definition of that single route.

[Rest API] List Mailing Lists

Returns a list of all mailing lists configured in your Mailgun account.

  • This endpoint retrieves every mailing list accessible to your API key. Results are paginated, and Nexla automatically fetches subsequent pages until all records have been ingested.

[Rest API] List Mailing List Members

Returns a list of members in a specific Mailgun mailing list.

  • Provide the mailing list address in the List Address field. Results are paginated, and Nexla automatically fetches subsequent pages until all records have been ingested.

[Rest API] List Webhooks

Retrieve all account-level webhooks configured in Mailgun.

  • This endpoint returns the full set of account-level webhooks in a single request.

[Rest API] List IPs

Returns a list of all dedicated IP addresses allocated to your Mailgun account.

  • This endpoint returns the full set of dedicated IPs assigned to your account in a single request.

[Rest API] Query Email Metrics

Query filtered email metrics for an account, including delivery, open, click, and bounce rates by dimension.

  • This endpoint returns aggregated analytics for your account. Results are paginated, and Nexla automatically fetches subsequent pages until all records have been ingested.

Once the selected endpoint template has been configured, click the Test button to the right of the endpoint selection menu to retrieve a sample of the data that will be fetched. Sample data will be displayed in the Endpoint Test Result panel on the right, allowing you to verify that the source is configured correctly before saving.

Manual configuration

Mailgun data sources can also be manually configured to ingest data from any valid Mailgun API endpoint, including endpoints not covered by the pre-built templates, chained API calls, or custom request parameters. Select the Advanced tab at the top of the configuration screen, and follow the instructions in Connect to Any API to configure the API method, endpoint URL, date/time and lookup macros, path to data, metadata, and request headers.

Once all of the relevant settings have been configured, click the Create button in the upper right corner of the screen to save and create the new Mailgun data source. Nexla will now begin ingesting data from the configured endpoint and will organize any data that it finds into one or more Nexsets.

Use as a destination

Click the + icon on the Nexset that will be sent to the Mailgun destination, and select the Send to Destination option from the menu. Select the Mailgun connector from the list of available destination connectors, then select the credential that will be used to connect to Mailgun, and click Next; or, create a new Mailgun credential for use in this flow.

Endpoint templates

Nexla provides pre-built templates that can be used to rapidly configure destinations to send data to common Mailgun endpoints. Select the endpoint to which data will be sent from the Endpoint pulldown menu. Then, click on the template in the list below to expand it, and follow the instructions to configure additional endpoint settings.

[Rest API] Send Email Message

Send an email message via Mailgun for a specific domain.

  • Provide the sending domain in the Domain field. Each record from your Nexset is sent as an email message through that domain, with the message contents supplied in the request body.

[Rest API] Create Domain

Create a new sending domain in Mailgun.

  • Each record from your Nexset is sent as a request to create a new sending domain. The request body should contain the domain properties required by the Mailgun API.

[Rest API] Delete Domain

Delete a sending domain from Mailgun.

  • Provide the domain name in the Domain field. Each record from your Nexset triggers deletion of the specified sending domain.

[Rest API] Create Webhook

Create an account-level webhook to receive real-time email event notifications.

  • Each record from your Nexset is sent as a request to register a new account-level webhook. The request body should contain the webhook event type and target URL required by the Mailgun API.

[Rest API] Create Route

Create a new inbound email routing rule in Mailgun.

  • Each record from your Nexset is sent as a request to create a new route. The request body should contain the route expression, priority, and actions required by the Mailgun API.

[Rest API] Add Member to Mailing List

Add a member to a Mailgun mailing list.

  • Provide the mailing list address in the List Address field. Each record from your Nexset is added as a member to that mailing list, with the member details supplied in the request body.

[Rest API] Delete Bounce

Remove a specific bounce record from your Mailgun domain's suppression list.

  • Provide the sending domain in the Domain field and the bounced address in the Email Address field. Each record from your Nexset removes the specified bounce record from the domain's suppression list.

[Rest API] Delete Unsubscribe

Remove a specific unsubscribe record from your Mailgun domain's suppression list.

  • Provide the sending domain in the Domain field and the address in the Email Address field. Each record from your Nexset removes the specified unsubscribe record from the domain's suppression list.

Manual configuration

Mailgun destinations can also be manually configured to send data to any valid Mailgun API endpoint. Select the Advanced tab at the top of the configuration screen, and follow the instructions in Connect to Any API to configure the API method, data format, endpoint URL, request headers, attribute exclusions, record batching, and response webhooks.

Mailgun APIs expect specific field formats for each operation. Ensure the records in your Nexset include all fields required by the target endpoint, such as recipient, sender, and message content for message sending.

Save & activate

Once all endpoint settings have been configured, click the Done button in the upper right corner of the screen to save and create the destination. To send the data to the configured Mailgun endpoint, open the destination resource menu, and select Activate.

The Nexset data will not be sent to the Mailgun endpoint until the destination is activated. Destinations can be activated immediately or at a later time, providing full control over data movement.