Skip to content

Create a route

Request

Adds a new route to the account

Security
basicAuth
Bodyapplication/x-www-form-urlencoded
priorityinteger

Smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0.

descriptionstring

An arbitrary string.

expressionstringrequired

The filtering rule.

actionArray of strings

This action is executed when the expression evaluates to True. You can pass multiple parameters.

curl -i -X POST \
  -u '<username>:<password>' \
  https://api.mailgun.net/v3/routes \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d priority=0 \
  -d 'description=it'\''s a new route' \
  -d 'expression=match_recipient('\''.*@gmail.com'\'')' \
  -d 'action=["forward(\"http://myhost.com/messages/\")","stop()"]'

Responses

OK

Bodyapplication/json
messagestring

A string describing the result of the operation

routeobject(RouteResponse)

The created route

Response
{ "message": "Route has been created", "route": { "id": "4f3bad2335335426750048c6", "priority": 0, "description": "it's a new route", "expression": "match_recipient('.*@gmail.com')", "actions": [], "created_at": "Wed, 15 Feb 2012 13:03:31 GMT" } }