Define a list of routes to handle incoming emails. When a message matches a route expression, Mailgun can forward it on to your application via HTTP or another email address, or store the message temporarily (3 days) for subsequent retrieval.
Adds a new route to the account
{ "priority": 0, "description": "it's a new route", "expression": "match_recipient('.*@gmail.com')", "action": [ "forward(\"http://myhost.com/messages/\")", "stop()" ] }
{- "message": "Route has been created",
- "route": {
- "id": "4f3bad2335335426750048c6",
- "priority": 0,
- "description": "it's a new route",
- "expression": "match_recipient('.*@gmail.com')",
- "actions": [
- "forward(\"http://myhost.com/messages/\")"
], - "created_at": "Wed, 15 Feb 2012 13:03:31 GMT"
}
}
Get the list of routes. Note that routes are defined globally, per account, not per domain.
{- "total_count": 1,
- "items": [
- {
- "id": "4f3bad2335335426750048c6",
- "priority": 0,
- "description": "Sample route",
- "expression": "match_recipient(\".*@samples.mailgun.org\")",
- "actions": [
- "forward(\"http://myhost.com/messages/\")",
- "stop()"
], - "created_at": "Wed, 15 Feb 2012 13:03:31 GMT"
}
]
}
Returns a detailed view of the route
OK
Not Found
{- "route": {
- "id": "4f3bad2335335426750048c6",
- "priority": 0,
- "description": "Sample route",
- "expression": "match_recipient(\".*@samples.mailgun.org\")",
- "actions": [
- "forward(\"http://myhost.com/messages/\")",
- "stop()"
], - "created_at": "Wed, 15 Feb 2012 13:03:31 GMT"
}
}
Updates a given route. All parameters are optional. This only updates the specified fields, leaving others unchanged.
id | string Unique identifier of the route |
priority | integer Smaller number indicates higher priority. Higher priority routes are handled first. |
description | string An arbitrary string. |
expression | string The filtering rule. |
action | Array of strings This action is executed when the expression evaluates to True. You can pass multiple parameters. |
{ "priority": 0, "description": "Sample route", "expression": "match_recipient(\".*@samples.mailgun.org\")", "action": [ "forward(\"http://myhost.com/messages/\")", "stop()" ] }
{- "message": "Route has been updated",
- "route": {
- "id": "4f3bad2335335426750048c6",
- "priority": 0,
- "description": "Sample route",
- "expression": "match_recipient(\".*@samples.mailgun.org\")",
- "actions": [
- "forward(\"http://myhost.com/messages/\")",
- "stop()"
], - "created_at": "Wed, 15 Feb 2012 13:03:31 GMT"
}
}
Checks if an address matches at least one route.
OK
object | |||||||||||||
|
Not Found
{- "route": {
- "id": "4f3bad2335335426750048c6",
- "priority": 0,
- "description": "Sample route",
- "expression": "match_recipient(\".*@samples.mailgun.org\")",
- "actions": [
- "forward(\"http://myhost.com/messages/\")",
- "stop()"
], - "created_at": "Wed, 15 Feb 2012 13:03:31 GMT"
}
}