Get your free beta license ↗
API operation · mail group
PATCH

/domains/{name}/mail/filters/{id}

First published 3 Oct 20260.1.0Unchanged since publication

Update a mail filter

Who may call it
AdministratorResellerCustomer
Token scope, any of
mailall
Answers200 OK

Supply at least one setting. Each supplied setting replaces its previous value. Supplying rules replaces the entire rule list. You can change match on its own. Use all to require every rule to match or any to require at least one match. If supplied, name must contain 1 to 64 printable ASCII characters. rules and action use the same formats and limits as POST /domains/{name}/mail/filters.

Use position to move the filter within its list. Positions start at 1, and position cannot exceed 100. A position past the end moves the filter to the end. The API returns 400 if no setting is supplied or a setting is invalid, and 404 if id does not identify a filter on the domain. UrbeStack compiles the updated filter with Pigeonhole and reports any compilation error. The 200 response contains the updated 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 server

Parameters

namepath ·DomainNameRequired
idpath ·integerRequired

Request body

JSON ·MailFilterPatch· 5 fields
matchstring, one of all, any
namestring, up to 64 characters
positioninteger, 1 to 100
rulesarray of MailFilterRule

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X PATCH "$API/domains/example.com/mail/filters/1" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "action": {
      "action": "folder",
      "target": "https://example.com/new"
    },
    "match": "all",
    "name": "alice",
    "position": 1,
    "rules": [
      {
        "field": "from",
        "op": "contains",
        "value": 8443
      }
    ]
  }'
Response · 200 OK
{
  "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

27 errors, each a status and a sentence
400--id is required
400<what> must be a whole number from 0 to <max>
400<what> must be text without control characters, 1 to <max> characters
400A filter needs one to twenty rules
400A rule is an object with field, op and value
400A rule's field is one of from, to, subject, header, body
400A rule's operator is one of contains, not-contains, equals, begins, ends, matches
400Domain name required
400Domain name too long
400Invalid IPv4 address
400Invalid IPv6 address
400Invalid domain name
400Invalid id
400Invalid mail address
400Invalid mail address: local part over 64 characters
400Invalid mail address: no local part
400Invalid mail address: the local part may hold letters, digits, dots, _ + and -
400Invalid port
400Invalid setting key
400Nothing to change
400The action is an object with action and, for folder and redirect, target
400The action is folder, discard, redirect or stop
400match is all or any
401Authentication required
404Filter <id> not found
404No such filter: <id>
404Setting '<key>' not found
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.1.0 on 3 Oct 2026.
urbestack.com/docs/api/patch-domains-name-mail-filters-id/