/domains/{name}/mail/filters
0.1.0Unchanged since publicationCreate a mail filter for the domain or one of its mailboxes
mailallscope defaults to domain. To create a mailbox filter, set scope to account and supply the mailbox's local part in local. Domain filters run before each mailbox's filters. Supply a name of 1 to 64 printable ASCII characters.
Supply 1 to 20 rule objects in rules. Each rule has field, op and value. field can be from, to, subject, header or body. Use header to match any of the usual message headers. op can be contains, not-contains, equals, begins, ends or matches. The matches operator uses shell-style patterns with * and ?. value must contain 1 to 256 characters without ASCII control characters. match defaults to all, which requires every rule to match. Use any to require at least one match.
The action object contains an action field. For folder and redirect, also supply target. folder delivers the message to the target folder, creates it if needed and ends filtering for the message. The folder name must contain 1 to 128 characters without ASCII control characters. discard drops the message. redirect sends a copy to the target email address and keeps the original. For a mailbox filter, the target email address must differ from the mailbox's own. stop skips the remaining filters in the current list.
Filters run in position order, starting at 1. Use position to insert the filter and shift later filters down. position cannot exceed 100. Omit position or give a position past the end to append the filter. The API returns 400 for invalid filter settings. UrbeStack compiles the filter with Pigeonhole before saving it and reports any compilation error. The 201 response contains the new filter in filter.
Administrators, the domain's owner and the owner's reseller can call this operation with a token that has the mail scope.
As a command
Run as root on the serverParameters
namepath ·DomainNameRequiredactionMailFilterActionRequirednamestring, up to 64 charactersRequiredrulesarray of MailFilterRuleRequiredlocalLocalPartmatchstring, one of all, anypositioninteger, 1 to 100scopestring, one of domain, accountExample
See the API overview for how to set $API and $TOKEN.curl -sS -X POST "$API/domains/example.com/mail/filters" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"action": {
"action": "folder",
"target": "https://example.com/new"
},
"local": "info",
"match": "all",
"name": "alice",
"position": 1,
"rules": [
{
"field": "from",
"op": "contains",
"value": 8443
}
],
"scope": "domain"
}'201 Created{
"filter": {
"action": {
"action": "folder",
"target": "https://example.com/new"
},
"address": "info@example.com",
"created_at": "2026-09-09T10:15:00Z",
"domain": "example.com",
"id": 1,
"name": "alice",
"position": 1,
"rules": {}
}
}Errors
23 errors, each a status and a sentence400<what> must be a whole number from 0 to <max>400<what> must be text without control characters, 1 to <max> characters400A filter needs one to twenty rules400A rule is an object with field, op and value400A rule's field is one of from, to, subject, header, body400A rule's operator is one of contains, not-contains, equals, begins, ends, matches400At most <FILTER_MAX> filters here400Domain name required400Domain name too long400Invalid IPv4 address400Invalid IPv6 address400Invalid domain name400Invalid mail address400Invalid mail address: local part over 64 characters400Invalid mail address: no local part400Invalid mail address: the local part may hold letters, digits, dots, _ + and -400Invalid port400Invalid setting key400The action is an object with action and, for folder and redirect, target400The action is folder, discard, redirect or stop400match is all or any401Authentication required404Setting '<key>' not foundurbestack.com/docs/api/post-domains-name-mail-filters/