Skip to content

Mailgun Forwards API

Overview

The Forwards API is a streamlined way to configure inbound email processing on your Mailgun account. It is designed as a simpler, more scalable alternative to Mailgun's existing Routes service — purpose-built for the common case of forwarding incoming email to one or more destinations.

Where Routes offer broad, script-like flexibility (filtering, storing, stopping, and chaining actions), the Forwards API focuses on doing one thing well: matching an incoming recipient address and routing that email onward. This narrower scope means less configuration overhead and better performance at scale.


Why Forwards Instead of Routes?

RoutesForwards API
Use caseComplex, multi-action inbound processingSimple email forwarding
ConfigurationExpression-based filter syntaxWildcard match patterns
ActionsForward, store, stopForward to recipients, URLs, or store
ScaleDegrades with rule volumeDesigned to scale with large rule sets
Best forAdvanced routing logicStraightforward recipient-based forwarding

Use the Forwards API when you need to forward inbound email based on recipient address and don't require complex conditional logic. Stick with Routes if you need multi-action pipelines or expression-based filtering.


Wildcard Matching

Each forward rule includes a match pattern that is evaluated against the recipient address of every incoming email. Matching is case-insensitive and supports * as a wildcard for any sequence of characters.

PatternMatches
support@mg.example.comOnly that exact address
support*@mg.example.comAny address starting with support
*@mg.example.comAll addresses on the domain (catch-all)

Note: Only * and literal characters are supported — this is not a regex match. A pattern like a.*@example.com matches addresses starting with a. (literal dot), not any character after a.


The Forward Rule Object

All API endpoints that return a forward rule share this structure:

FieldTypeDescription
idstringUnique identifier for the rule
account_idstringThe Mailgun account this rule belongs to
domain_namestringThe domain the rule is scoped to
domain_idstringUnique identifier of the associated domain
matchstringThe wildcard pattern matched against incoming recipient addresses
forward.urlsarrayWebhook URLs that receive matching emails
forward.recipientsarrayEmail addresses that receive forwarded copies
forward.storestringWebhook URL notified on arrival, with a link to retrieve the message
created_atstringISO 8601 timestamp of rule creation
updated_atstringISO 8601 timestamp of the last update