CONNECT APP
Build with Mailgun
Marketing
- API key
MCP
Give your agent Mailgun tools
Every Mailgun action is exposed as an MCP tool on Pipedream's remote server. Point a client at it with your end user's ID and Connect resolves that user's Mailgun account for each tool call — you store no tokens.
// accessToken: mint a short-lived token with the Connect SDK — see the MCP guide
const transport = new StreamableHTTPClientTransport(
new URL("https://remote.mcp.pipedream.net/v3"),
{
requestInit: {
headers: {
Authorization: `Bearer ${accessToken}`,
"x-pd-project-id": "{project_id}",
"x-pd-environment": "production",
"x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
"x-pd-app-slug": "mailgun",
},
},
},
)
const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)
const { tools } = await mcp.listTools()
// e.g. run Create Mailing List Member:
const result = await mcp.callTool({
name: "mailgun-create-mailinglist-member",
arguments: {
list: "Mailing List",
address: "Email Address",
},
})# access_token: mint a short-lived token with the Connect SDK — see the MCP guide
headers = {
"Authorization": f"Bearer {access_token}",
"x-pd-project-id": "{project_id}",
"x-pd-environment": "production",
"x-pd-external-user-id": "{external_user_id}", # any stable ID for this user in your system
"x-pd-app-slug": "mailgun",
}
async with streamablehttp_client("https://remote.mcp.pipedream.net/v3", headers=headers) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
# e.g. run Create Mailing List Member:
result = await session.call_tool("mailgun-create-mailinglist-member", {
"list": "Mailing List",
"address": "Email Address",
})API PROXY
Call the Mailgun API directly
For an endpoint with no pre-built tool, the Connect proxy forwards your request to the Mailgun API with the connected user's credentials attached. You store no tokens and write no refresh logic.
const resp = await pd.proxy.get({
externalUserId: "{external_user_id}", // any stable ID for this user in your system
accountId: "apn_xxxxxxx",
url: "https://api.mailgun.net/v3/domains",
})
// Any allowed Mailgun endpoint works here. Pipedream attaches the
// connected account's credentials to the outgoing request.# The path segment is the target URL, URL-safe base64 encoded:
# https://api.mailgun.net/v3/domains
curl "https://api.pipedream.com/v1/connect/{project_id}/proxy/aHR0cHM6Ly9hcGkubWFpbGd1bi5uZXQvdjMvZG9tYWlucw?external_user_id={external_user_id}&account_id=apn_xxxxxxx" \
-H "Authorization: Bearer {access_token}" \
-H "x-pd-environment: production"SDK
Run Mailgun actions from your backend
Connect a user's Mailgun account once, then run Create Mailing List Member on their behalf from your own code — TypeScript, Python, or plain HTTP.
import { PipedreamClient } from "@pipedream/sdk"
const pd = new PipedreamClient({
projectId: process.env.PIPEDREAM_PROJECT_ID!,
clientId: process.env.PIPEDREAM_CLIENT_ID!,
clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
projectEnvironment: "production",
})
const result = await pd.actions.run({
id: "mailgun-create-mailinglist-member",
externalUserId: "{external_user_id}", // any stable ID for this user in your system
configuredProps: {
mailgun: { authProvisionId: "apn_xxxxxxx" },
list: "Mailing List",
address: "Email Address",
},
})from pipedream import Pipedream
pd = Pipedream(
client_id="{oauth_client_id}",
client_secret="{oauth_client_secret}",
project_id="{project_id}",
project_environment="production",
)
result = pd.actions.run(
id="mailgun-create-mailinglist-member",
external_user_id="{external_user_id}", # any stable ID for this user in your system
configured_props={
"mailgun": {"authProvisionId": "apn_xxxxxxx"},
"list": "Mailing List",
"address": "Email Address",
},
)curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
-H "Content-Type: application/json" \
-H "X-PD-Environment: production" \
-H "Authorization: Bearer {access_token}" \
-d '{
"external_user_id": "{external_user_id}",
"id": "mailgun-create-mailinglist-member",
"configured_props": {
"mailgun": { "authProvisionId": "apn_xxxxxxx" },
"list": "Mailing List",
"address": "Email Address"
}
}'TOOLS
Mailgun actions
On-demand operations your product or agent can configure and run on behalf of a connected user.
-
Create Mailing List Member
actionAdd to an existing mailing list. See the docs hereWritev0.0.3 -
Create Route
actionCreate a new route. See the docs hereWritev0.0.4 -
Delete Mailing List Member
actionDelete a mailing list member by address. See the docs hereWritev0.0.3 -
Get Mailing List Member
actionRetrieve a mailing list member by address. See the docs hereRead-onlyv0.0.3 -
Get Mailing List Members
actionList all mailing list members. See the docs hereRead-onlyv0.0.3 -
List Domain Name Options
actionRetrieves available options for the Domain Name field.Read-onlyv0.0.1 -
List Domains
actionList domains in Mailgun. See the docs hereRead-onlyv0.0.3 -
List Mailing List Options
actionRetrieves available options for the Mailing List field.Read-onlyv0.0.1 -
Send Email
actionSend email with Mailgun. See the docs hereWritev0.1.1 -
Suppress Email
actionAdd email to the Mailgun suppression list. See the docs hereWritev0.0.4 -
Verify Email
actionVerify email address deliverability with Mailgun. See the docs hereRead-onlyv0.0.4
EVENTS
Mailgun triggers
Event sources your backend can deploy for users and receive through a webhook.
-
New Bounce (Instant)
triggerEmit new event when the email recipient could not be reached.Instantv0.0.2 -
New Click (Instant)
triggerEmit new event when the email recipient clicked on a link in the email. Open tracking must be enabled in the Mailgun control panel, and the CNAME record must be pointing to mailgun.org. See more at the Mailgun User's Manual Tracking Messages sectionInstantv0.0.3 -
New Complaint (Instant)
triggerEmit new event when the email recipient clicked on the spam complaint button within their email client. Feedback loops enable the notification to be received by Mailgun.Instantv0.0.2 -
New Delivery (Instant)
triggerEmit new event when an email is sent and accepted by the recipient email server.Instantv0.0.2 -
New Delivery Failure (Instant)
triggerEmit new event when an email can't be delivered to the recipient email server.Instantv0.0.2 -
New Log Data
triggerEmit new event when new data is logged in Mailgun's Control Panel. Occurs for most actions within the associated Mailgun account.v0.0.3 -
New Mailing List
triggerEmit new event when a new mailing list is added to the associated Mailgun account.v0.0.3 -
New Open (Instant)
triggerEmit new event when the email recipient opened the email and enabled image viewing. Open tracking must be enabled in the Mailgun control panel, and the CNAME record must be pointing to mailgun.org. See more at the Mailgun User's Manual Tracking Messages sectionInstantv0.0.2 -
New Permanent Failure (Instant)
triggerEmit new event when an email can't be delivered to the recipient email server due to a permanent mailbox error such as non-existent mailbox.Instantv0.0.2 -
New Temporary Failure (Instant)
triggerEmit new event when an email can't be delivered to the recipient email server due to a temporary mailbox error such as an ESP block. ESP is the Email Service Provider managing the recipient email server.Instantv0.0.3 -
New Unsubscribe (Instant)
triggerEmit new event when the email recipient clicked on the unsubscribe link. Unsubscribe tracking must be enabled in the Mailgun control panel. See more at the Mailgun User's Manual Tracking Messages sectionInstantv0.0.2
- App slug
- mailgun
- Authentication
- API key
- Categories
- Marketing
- Actions
- 11
- Triggers
- 11
- API proxy
- Available