# molted rules

Source: https://molted.email/docs/cli/rules

Manage mailbox rules for automated thread routing

| Command | Description |
| - | - |
| [`molted rules list`](#molted-rules-list) | List rules for a mailbox |
| [`molted rules create`](#molted-rules-create) | Create a mailbox rule |
| [`molted rules get`](#molted-rules-get) | Get a rule by ID |
| [`molted rules update`](#molted-rules-update) | Update a rule |
| [`molted rules delete`](#molted-rules-delete) | Delete a rule |
| [`molted rules reorder`](#molted-rules-reorder) | Reorder rules for a mailbox |

## Agent context

Mailbox rules automatically label inbound emails or archive them based on conditions like sender domain, sender email, or subject keywords.

Rules run once per thread, on the inbound message that starts a new thread; later messages on that thread are not evaluated. They run in position order. When a rule matches and stop\_processing is true (the default: the server stores true unless `--no-stop-processing` is passed), no further rules are evaluated.

### Create a rule to label emails from a domain

```bash
molted rules create --mailbox <mbxId> --name "Acme to Sales" \
  --condition-type sender_domain --condition-operator equals \
  --condition-value acme.com --action-type apply_label \
  --action-value <labelId>
```

### Auto-archive newsletters

```bash
molted rules create --mailbox <mbxId> --name "Archive newsletters" \
  --condition-type subject --condition-operator contains \
  --condition-value "newsletter" --action-type auto_archive
```

### List and reorder rules

```bash
molted rules list --mailbox <mbxId>
molted rules reorder --mailbox <mbxId> --rule-ids id1,id2,id3
```

- **Condition types:** sender\_domain, sender\_email, subject
- **Operators:** equals, contains, ends\_with, matches\_pattern (all case-insensitive; matches\_pattern is a SQL LIKE pattern over the whole value: % matches any run of characters, \_ matches one character)
- **Action types:** apply\_label (requires `--action-value <labelId>`, a label of the rule's mailbox; see molted labels), move\_to\_folder (its old name), auto\_archive

Related: [`molted mailboxes`](https://molted.email/docs/cli/mailboxes.md), [`molted threads`](https://molted.email/docs/cli/threads.md), [`molted labels`](https://molted.email/docs/cli/labels.md)

## Commands

### molted rules list

List rules for a mailbox

```bash
molted rules list [options]
```

| Option | Description | Default |
| - | - | - |
| `--mailbox <id>` | Mailbox ID (required) (required) | |

### molted rules create

Create a mailbox rule

```bash
molted rules create [options]
```

| Option | Description | Default |
| - | - | - |
| `--mailbox <id>` | Mailbox ID (required) (required) | |
| `--name <name>` | Rule name (required) (required) | |
| `--condition-type <type>` | Condition type (required; one of: sender\_domain, sender\_email, subject) | |
| `--condition-operator <op>` | Operator (required; one of: equals, contains, ends\_with, matches\_pattern) | |
| `--condition-value <val>` | Value to match (required) (required) | |
| `--action-type <type>` | Action type (required; one of: apply\_label, move\_to\_folder, auto\_archive) | |
| `--action-value <val>` | Action value (label ID for apply\_label / move\_to\_folder) | |
| `--position <n>` | Position in rule order | `0` |
| `--stop-processing` | Stop processing after match (the default when neither flag is passed) | |
| `--no-stop-processing` | Continue processing after match | |

### molted rules get

Get a rule by ID

```bash
molted rules get <id>
```

| Argument | Description | Required |
| - | - | - |
| `<id>` | | yes |

### molted rules update

Update a rule

```bash
molted rules update [options] <id>
```

| Argument | Description | Required |
| - | - | - |
| `<id>` | | yes |

| Option | Description | Default |
| - | - | - |
| `--name <name>` | Rule name | |
| `--condition-type <type>` | Condition type (one of: sender\_domain, sender\_email, subject) | |
| `--condition-operator <op>` | Condition operator (one of: equals, contains, ends\_with, matches\_pattern) | |
| `--condition-value <val>` | Condition value | |
| `--action-type <type>` | Action type (one of: apply\_label, move\_to\_folder, auto\_archive) | |
| `--action-value <val>` | Action value | |
| `--enabled` | Enable the rule | |
| `--no-enabled` | Disable the rule | |
| `--position <n>` | Position | |
| `--stop-processing` | Stop processing after match | |
| `--no-stop-processing` | Continue processing after match | |

### molted rules delete

Delete a rule

```bash
molted rules delete <id>
```

| Argument | Description | Required |
| - | - | - |
| `<id>` | | yes |

### molted rules reorder

Reorder rules for a mailbox

```bash
molted rules reorder [options]
```

| Option | Description | Default |
| - | - | - |
| `--mailbox <id>` | Mailbox ID (required) (required) | |
| `--rule-ids <ids>` | Comma-separated rule IDs in desired order (required) (required) | |

See [CLI overview](https://molted.email/docs/cli.md) for global options, credentials and output format.
