> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pigion.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Routing rules

> Decide yourself which category an email goes to, based on the sender, the domain or the subject.

Pigion sorts every new email into one of [eight categories](https://docs.pigion.ai/email/which-emails-get-a-draft.md). Most of the time that goes right on its own. When it does not, or when you want certain email to always land in the same place, add a routing rule.

A rule always wins from Pigion's own sorting.

## Add a rule

1. Go to **Settings** → **Routing rules**. You can also open the rules from the **Email** page.
2. Choose **Add rule**.
3. Pick the **Field** to match on: **Sender**, **Domain** or **Subject**.
4. Type the **Pattern**.
5. Pick the **Category** the email should go to.
6. Save.

Rules apply to the inbox you selected. With more than one inbox, set rules per inbox.

## Examples

| Field | Pattern | Category | Effect |
| - | - | - | - |
| Sender | `invoices@supplier.com` | Finance | Invoices from that supplier always go to Finance |
| Domain | `newsletter.example.com` | Marketing | Everything from that domain counts as marketing |
| Domain | `bigclient.com` | Reply needed | Email from an important client always lands in Reply needed |
| Subject | `invoice` | Finance | Every email with *invoice* in the subject goes to Finance |

## How rules work

* **Rules run first.** A rule is checked before Pigion's own sorting. When a rule matches, Pigion does not sort that email itself.
* **The first match wins.** With more than one rule, Pigion goes through them from top to bottom and uses the first one that matches.
* **Patterns can be regular expressions.** For example, `^billing@` matches every sender address that starts with *billing@*. A pattern that is not a valid regular expression, or that is too complex, is rejected with a message.
* **Up to 25 rules** per inbox.

## Stop drafts for a sender

Only email in **Reply needed** gets a draft. To stop drafts for a sender, route their email to another category, such as **FYI**.

## Related

* [Which emails get a draft](https://docs.pigion.ai/email/which-emails-get-a-draft.md)
* [Move mail out of your inbox](https://docs.pigion.ai/email/move-mail-out-of-your-inbox.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.