SpamRule
Defines a spam filter rule for message classification.
This object can be configured from the WebUI under Settings › Spam Filter › Rules
Fields
SpamRule is a multi-variant object: each instance has an @type discriminator selecting one of the variants below, and each variant carries its own set of fields.
@type: "Any"
Any
condition
Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamGenericVariable.
name
Type:
String· read-onlyShort name for the rule
description
Type:
String?Description for the rule
enable
Type:
Boolean· default:trueWhether to enable this rule
priority
Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Url"
URL
condition
Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamUrlVariable.
name
Type:
String· read-onlyShort name for the rule
description
Type:
String?Description for the rule
enable
Type:
Boolean· default:trueWhether to enable this rule
priority
Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Domain"
Domain
condition
Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamGenericVariable.
name
Type:
String· read-onlyShort name for the rule
description
Type:
String?Description for the rule
enable
Type:
Boolean· default:trueWhether to enable this rule
priority
Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Email"
condition
Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamEmailVariable.
name
Type:
String· read-onlyShort name for the rule
description
Type:
String?Description for the rule
enable
Type:
Boolean· default:trueWhether to enable this rule
priority
Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Ip"
IP
condition
Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamIpVariable.
name
Type:
String· read-onlyShort name for the rule
description
Type:
String?Description for the rule
enable
Type:
Boolean· default:trueWhether to enable this rule
priority
Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Header"
Header
condition
Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamHeaderVariable.
name
Type:
String· read-onlyShort name for the rule
description
Type:
String?Description for the rule
enable
Type:
Boolean· default:trueWhether to enable this rule
priority
Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Body"
Body
condition
Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamGenericVariable.
name
Type:
String· read-onlyShort name for the rule
description
Type:
String?Description for the rule
enable
Type:
Boolean· default:trueWhether to enable this rule
priority
Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
JMAP API
The SpamRule object is available via the urn:stalwart:jmap capability.
x:SpamRule/get
This is a standard Foo/get method as defined in RFC 8620, Section 5.1.
This method requires the sysSpamRuleGet permission.
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:SpamRule/get",
{
"ids": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'
x:SpamRule/set
This is a standard Foo/set method as defined in RFC 8620, Section 5.3.
Supports create, update, and destroy operations in a single call.
Create
This operation requires the sysSpamRuleCreate permission.
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:SpamRule/set",
{
"create": {
"new1": {
"@type": "Any",
"condition": {
"else": "Example",
"match": []
},
"description": "Example",
"enable": true,
"priority": 500
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'
Update
This operation requires the sysSpamRuleUpdate permission.
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:SpamRule/set",
{
"update": {
"id1": {
"id": "id1"
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'
Destroy
This operation requires the sysSpamRuleDestroy permission.
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:SpamRule/set",
{
"destroy": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'
x:SpamRule/query
This is a standard Foo/query method as defined in RFC 8620, Section 5.5.
This method requires the sysSpamRuleQuery permission.
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:SpamRule/query",
{
"filter": {
"name": "example"
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'
The x:SpamRule/query filter argument accepts the following conditions (combinable with AnyOf / AllOf / Not per RFC 8620):
| Condition | Kind |
|---|---|
name | text |
CLI
stalwart-cli wraps the same JMAP calls. See the CLI reference for installation, authentication, and general usage.
Fetch
stalwart-cli get spam-rule id1
Create
stalwart-cli create spam-rule/any \
--field 'condition={"else":"Example","match":[]}' \
--field description=Example \
--field enable=true \
--field priority=500
Query
stalwart-cli query spam-rule
stalwart-cli query spam-rule --where name=example
Update
stalwart-cli update spam-rule id1 --field description='Updated'
Delete
stalwart-cli delete spam-rule --ids id1
Nested types
Expression
A conditional expression with match rules and a default value.
match
Type:
ExpressionMatch[]List of conditions and their corresponding results
else
Type:
String· requiredElse condition
ExpressionMatch
A single condition-result pair in an expression.
if
Type:
String· requiredIf condition
then
Type:
String· requiredThen clause
Expression references
The following expression contexts are used by fields on this page:
SpamGenericVariable(Variables)SpamUrlVariable(Variables)SpamEmailVariable(Variables)SpamIpVariable(Variables)SpamHeaderVariable(Variables)