Docs / Routing Rules & Folders

Guide 5 of 8

Routing Rules & Folders

Folders organise emails within an inbox. Routing rules automatically move incoming emails into folders based on conditions — sender, subject, alias tag, or attachment presence. Rules are evaluated after delivery and affect organisation only, not whether an email is accepted.


Create a Folder

Every inbox starts with an INBOX folder. You can create additional folders to separate different types of email — for example, one folder per flow you're testing.

Via web UI: Open the inbox → Folders → New Folder → enter a name → Create.

Via SDK:

TypeScript
const folder = await mf.folders.create({
  inbox: '[email protected]',
  name: 'password-reset',
});

console.log(folder.id);

Create a Routing Rule

Rules follow an IF/THEN structure: when a condition matches, move the email to a folder and optionally mark it as read. The first matching rule wins — subsequent rules are not evaluated. Supported condition fields: from, subject, aliasTag, hasAttachment.

Via web UI: Open the inbox → Routing Rules → New Rule → set condition + action → Save.

Via SDK:

TypeScript
await mf.routing.create({
  inbox: '[email protected]',
  condition: {
    field: 'subject',
    operator: 'contains',
    value: 'verification',
  },
  action: {
    moveToFolder: 'password-reset',
    markAsRead: true,
  },
});
Note: Rules are evaluated after delivery — they affect organisation, not delivery. Delivery is controlled by inbox status and alias isActive.

Rule Ordering

Rules are evaluated in priority order. Lower priority numbers are evaluated first. In the web UI, drag and drop rules to reorder them. Via the API, update the priority field.

TypeScript
// Update a rule's priority (lower = evaluated first)
await mf.routing.update({
  ruleId: 'rule_abc123',
  priority: 1,
});

Fetch Emails from a Folder

Filter email list calls by folder name to retrieve only emails that have been routed to a specific folder.

TypeScript
const result = await mf.emails.list({
  inbox: '[email protected]',
  folder: 'password-reset',
});

console.log(result.items.length); // number of emails in this folder