MOLTED EMAIL

Mailbox Rules

Auto-route, archive, or flag inbound messages based on sender, subject, or other conditions.

Mailbox rules automatically process inbound messages as they arrive. Each rule defines a condition (what to match) and an action (what to do). Rules run in priority order and can optionally stop processing further rules when matched.

Rules are managed via the Agent Runtime API using your Bearer token.

Create a rule

POST https://agentic-mailbox.molted.email/v1/rules?tenantId=YOUR_TENANT_ID
curl
curl -X POST "https://agentic-mailbox.molted.email/v1/rules?tenantId=YOUR_TENANT_ID" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mailboxId": "MAILBOX_UUID",
    "name": "Archive newsletters",
    "conditionType": "sender_domain",
    "conditionOperator": "ends_with",
    "conditionValue": "newsletter.example.com",
    "actionType": "auto_archive",
    "enabled": true,
    "stopProcessing": false
  }'
Response
{
  "id": "rule_uuid",
  "mailboxId": "MAILBOX_UUID",
  "name": "Archive newsletters",
  "conditionType": "sender_domain",
  "conditionOperator": "ends_with",
  "conditionValue": "newsletter.example.com",
  "actionType": "auto_archive",
  "actionValue": null,
  "enabled": true,
  "position": 0,
  "stopProcessing": false
}

Condition types

TypeMatches against
sender_domainThe domain portion of the sender's email address.
sender_emailThe full sender email address.
subjectThe message subject line.

Condition operators

OperatorDescription
equalsExact match (case-insensitive).
containsSubstring match.
matches_patternGlob-style pattern match.
ends_withSuffix match.

Actions

ActionactionValueDescription
move_to_folderFolder nameMove the message to the specified folder.
auto_archiveNot requiredArchive the message immediately.

Request fields

FieldTypeRequiredDescription
mailboxIdstringYesUUID of the mailbox to attach the rule to.
namestringYesHuman-readable label for the rule.
conditionTypestringYesWhat to match against.
conditionOperatorstringYesHow to compare.
conditionValuestringYesThe value to compare against.
actionTypestringYesWhat to do when the condition matches.
actionValuestringNoAdditional value for the action (e.g., folder name).
enabledbooleanNoWhether the rule is active. Defaults to true.
positionintegerNoSort order. Lower values run first.
stopProcessingbooleanNoStop evaluating further rules when this one matches. Defaults to false.

List rules

GET https://agentic-mailbox.molted.email/v1/rules?tenantId=YOUR_TENANT_ID&mailboxId=MAILBOX_UUID
curl
curl "https://agentic-mailbox.molted.email/v1/rules?tenantId=YOUR_TENANT_ID&mailboxId=MAILBOX_UUID" \
  -H "Authorization: Bearer YOUR_API_KEY"

Get a rule

GET https://agentic-mailbox.molted.email/v1/rules/:id?tenantId=YOUR_TENANT_ID

Update a rule

PATCH https://agentic-mailbox.molted.email/v1/rules/:id?tenantId=YOUR_TENANT_ID
curl
curl -X PATCH "https://agentic-mailbox.molted.email/v1/rules/RULE_UUID?tenantId=YOUR_TENANT_ID" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"enabled": false}'

All fields from the create request are optional for updates.

Delete a rule

DELETE https://agentic-mailbox.molted.email/v1/rules/:id?tenantId=YOUR_TENANT_ID
curl
curl -X DELETE "https://agentic-mailbox.molted.email/v1/rules/RULE_UUID?tenantId=YOUR_TENANT_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"

Reorder rules

Rules are evaluated in ascending position order. Use the reorder endpoint to set the evaluation order explicitly.

POST https://agentic-mailbox.molted.email/v1/rules/reorder?tenantId=YOUR_TENANT_ID
curl
curl -X POST "https://agentic-mailbox.molted.email/v1/rules/reorder?tenantId=YOUR_TENANT_ID" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mailboxId": "MAILBOX_UUID",
    "ruleIds": ["rule-uuid-1", "rule-uuid-2", "rule-uuid-3"]
  }'

Rules are assigned positions in the order of the ruleIds array (first element = position 0).

Stop processing

When stopProcessing: true is set on a rule, evaluation halts after the rule matches. This is useful for high-priority rules that should take exclusive action.

Authorization

Rules require manage scope on the mailbox. Read operations require read scope. See Authentication for key scoping details.

  • Mailboxes -- create and manage mailboxes
  • Inbound -- how inbound messages are classified and routed