---
title: "Add an inbound mail rule"
method: POST
path: "/api/emails/{address}/rules"
tags: ["Email"]
---

# Add an inbound mail rule

`POST /api/emails/{address}/rules`

## Request

- Base URL: `https://domani.run`
- URL: `https://domani.run/api/emails/{address}/rules`
- Auth: HTTP bearer

Add a rule that runs on inbound messages matching a field (from/to/subject/body). Actions: drop, mark_read, forward (action_arg = address), webhook_only (skip forward-to), label (action_arg = label). Rules apply in priority order (lower first); first match wins.

## Path parameters

- `address` string, required

## Request body

- object
  - `match_field` 'from' | 'to' | 'subject' | 'body', required
  - `match_op` 'contains' | 'equals' | 'regex', required
  - `match_value` string, required
  - `action` 'drop' | 'mark_read' | 'forward' | 'webhook_only' | 'label' | 'escalate', required
  - `action_arg` string: Forward address (for forward), label value (for label), or reason shown to the human (for escalate)
  - `priority` integer: Lower runs first (default 0)
  - `enabled` boolean: Default true

## Response `201`

Rule created

- MailRule: An inbound filtering rule for a mailbox
  - `id` string
  - `priority` integer: Lower runs first
  - `match_field` 'from' | 'to' | 'subject' | 'body'
  - `match_op` 'contains' | 'equals' | 'regex'
  - `match_value` string
  - `action` 'drop' | 'mark_read' | 'forward' | 'webhook_only' | 'label' | 'escalate'
  - `action_arg` string, nullable
  - `enabled` boolean
  - `created_at` string, date-time

---

[API](https://skmtc.dev/domani/apis/domani-run-api.md) · [All operations](https://skmtc.dev/domani/apis/domani-run-api/llms.txt) · [OpenAPI document](https://skmtc.dev/domani/apis/domani-run-api/revisions/7679f8159533?raw)
