Control how email flows
Routing rules let you automatically forward, label, store, or trigger webhooks based on attributes of each incoming message. Rules are evaluated in priority order — the first match wins.
Every email that arrives at a Mailpipe mailbox is run through the routing pipeline. Rules are tested in ascending priority order (lower number = higher priority). As soon as a rule matches, its actions execute and evaluation stops — unless you set continue_on_match: true.
Filter by sender, recipient, subject line, or any header
Forward, call a webhook, store, label, or discard
First match wins — order your rules carefully
Each rule is a JSON object containing a conditions array and an actions array. All conditions in the array must match (logical AND) for the rule to fire.
{
"name": "My Rule",
"priority": 10,
"continue_on_match": false,
"conditions": [
{
"field": "from" | "to" | "subject" | "header",
"operator": "equals" | "contains" | "starts_with" | "ends_with" | "matches_regex",
"value": "string to match",
// Only required when field = "header":
"header_name": "X-Custom-Header"
}
],
"actions": [
{
"type": "forward" | "webhook" | "store" | "label" | "discard",
// type-specific fields — see Actions below
}
]
}Attributes you can match against
fromSender address (e.g. billing@stripe.com)toRecipient address — any address in To, CC, or BCCsubjectEmail subject lineheaderArbitrary header — specify header_name alongside valueWhat happens when conditions are met
forwardRe-deliver the message to another email address
Requires: to (string)
webhookPOST the full message payload to an HTTPS endpoint
Requires: url (string)
storeSave to a specific mailbox (overrides default)
Requires: mailbox_id (string)
labelApply one or more labels for dashboard organisation
Requires: labels (string[])
discardDrop the message silently — nothing is stored or forwarded
No extra fields required
Send a POST request to /api/v1/routing/rules with your rule definition. Mailpipe validates the structure and activates the rule immediately.
curl -X POST "https://api.mailpipe.dev/v1/routing/rules" \
-H "Authorization: Bearer mp_live_your-api-key-here" \
-H "Content-Type: application/json" \
-d '{
"name": "Support ticket intake",
"priority": 10,
"conditions": [
{ "field": "to", "operator": "ends_with", "value": "@support.yourdomain.com" }
],
"actions": [
{ "type": "webhook", "url": "https://your-app.com/webhooks/mailpipe" },
{ "type": "label", "labels": ["support", "needs-triage"] }
]
}'{
"id": "rule_xyz789",
"name": "Support ticket intake",
"priority": 10,
"enabled": true,
"conditions": [ ... ],
"actions": [ ... ],
"created_at": "2025-01-15T12:00:00Z"
}/v1/routing/rulesList all routing rules, ordered by priority/v1/routing/rulesCreate a new routing rule/v1/routing/rules/:idRetrieve a single rule by ID/v1/routing/rules/:idUpdate rule fields or reorder priority/v1/routing/rules/:idPermanently delete a ruleAny email whose subject contains the word "invoice" or "receipt" is automatically forwarded to an external finance address.
{
"name": "Forward invoices to finance",
"priority": 20,
"conditions": [
{
"field": "subject",
"operator": "matches_regex",
"value": "(?i)(invoice|receipt|payment|billing)"
}
],
"actions": [
{ "type": "forward", "to": "finance@yourcompany.com" },
{ "type": "label", "labels": ["billing"] }
]
}When email arrives on your support@ address, call your helpdesk webhook to open a new ticket automatically.
{
"name": "Open support ticket",
"priority": 10,
"conditions": [
{ "field": "to", "operator": "equals", "value": "support@yourdomain.com" }
],
"actions": [
{
"type": "webhook",
"url": "https://your-helpdesk.com/api/webhooks/new-ticket",
"headers": {
"X-Source": "mailpipe"
}
},
{ "type": "label", "labels": ["support"] }
]
}Drop any email from a known spam domain before it reaches your inbox.
{
"name": "Block spammer domain",
"priority": 1,
"conditions": [
{ "field": "from", "operator": "ends_with", "value": "@spammydomain.example" }
],
"actions": [
{ "type": "discard" }
]
}Rules with a lower priority number are evaluated first. If two rules share the same priority, they are ordered by creation date (oldest first). You can reorder rules at any time using the PATCH /v1/routing/rules/:id endpoint.
curl -X PATCH "https://api.mailpipe.dev/v1/routing/rules/rule_xyz789" \
-H "Authorization: Bearer mp_live_your-api-key-here" \
-H "Content-Type: application/json" \
-d '{ "priority": 5 }'| Priority | Rule | Notes |
|---|---|---|
| 1 | Block spammer domain | Evaluated first — discards before further processing |
| 10 | Open support ticket | Only reached if rule 1 did not match |
| 20 | Forward invoices to finance | Catch-all billing rule runs last |
Leave gaps between priority numbers (e.g. 10, 20, 30) so you can insert new rules later without having to renumber everything.