SpamRule
SpamRule
Section titled “SpamRule”Defines a spam filter rule for message classification.
This object can be configured from the WebUI under Settings › Spam Filter › Rules
Fields
Section titled “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"
Section titled “@type: "Any"”Any
condition
Section titled “condition”Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamGenericVariable.
Type:
String· read-onlyShort name for the rule
description
Section titled “description”Type:
String?Description for the rule
enable
Section titled “enable”Type:
Boolean· default:trueWhether to enable this rule
priority
Section titled “priority”Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Url"
Section titled “@type: "Url"”URL
condition
Section titled “condition”Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamUrlVariable.
Type:
String· read-onlyShort name for the rule
description
Section titled “description”Type:
String?Description for the rule
enable
Section titled “enable”Type:
Boolean· default:trueWhether to enable this rule
priority
Section titled “priority”Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Domain"
Section titled “@type: "Domain"”Domain
condition
Section titled “condition”Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamGenericVariable.
Type:
String· read-onlyShort name for the rule
description
Section titled “description”Type:
String?Description for the rule
enable
Section titled “enable”Type:
Boolean· default:trueWhether to enable this rule
priority
Section titled “priority”Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Email"
Section titled “@type: "Email"”condition
Section titled “condition”Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamEmailVariable.
Type:
String· read-onlyShort name for the rule
description
Section titled “description”Type:
String?Description for the rule
enable
Section titled “enable”Type:
Boolean· default:trueWhether to enable this rule
priority
Section titled “priority”Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Ip"
Section titled “@type: "Ip"”IP
condition
Section titled “condition”Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamIpVariable.
Type:
String· read-onlyShort name for the rule
description
Section titled “description”Type:
String?Description for the rule
enable
Section titled “enable”Type:
Boolean· default:trueWhether to enable this rule
priority
Section titled “priority”Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Header"
Section titled “@type: "Header"”Header
condition
Section titled “condition”Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamHeaderVariable.
Type:
String· read-onlyShort name for the rule
description
Section titled “description”Type:
String?Description for the rule
enable
Section titled “enable”Type:
Boolean· default:trueWhether to enable this rule
priority
Section titled “priority”Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
@type: "Body"
Section titled “@type: "Body"”Body
condition
Section titled “condition”Type:
Expression· requiredExpression that returns the tag to assign to the message.
Available variables:
SpamGenericVariable.
Type:
String· read-onlyShort name for the rule
description
Section titled “description”Type:
String?Description for the rule
enable
Section titled “enable”Type:
Boolean· default:trueWhether to enable this rule
priority
Section titled “priority”Type:
Integer· default:500· max: 99999 · min: -99999The priority of the rule
JMAP API
Section titled “JMAP API”The SpamRule object is available via the urn:stalwart:jmap capability.
x:SpamRule/get
Section titled “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
Section titled “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
Section titled “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": {} } } } }, "c1" ] ], "using": [ "urn:ietf:params:jmap:core", "urn:stalwart:jmap" ] }'Update
Section titled “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": { "description": "updated value" } } }, "c1" ] ], "using": [ "urn:ietf:params:jmap:core", "urn:stalwart:jmap" ] }'Destroy
Section titled “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
Section titled “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 |
stalwart-cli wraps the same JMAP calls. See the CLI reference for installation, authentication, and general usage.
stalwart-cli get SpamRule id1Create
Section titled “Create”stalwart-cli create SpamRule/Any \ --field 'condition={"else":"Example","match":{}}'stalwart-cli query SpamRulestalwart-cli query SpamRule --where name=exampleUpdate
Section titled “Update”stalwart-cli update SpamRule id1 --field description='updated value'Delete
Section titled “Delete”stalwart-cli delete SpamRule --ids id1Nested types
Section titled “Nested types”Expression
Section titled “Expression”A conditional expression with match rules and a default value.
Type:
ExpressionMatch[]List of conditions and their corresponding results
Type:
String· requiredElse condition
ExpressionMatch
Section titled “ExpressionMatch”A single condition-result pair in an expression.
Type:
String· requiredIf condition
Type:
String· requiredThen clause
Expression references
Section titled “Expression references”The following expression contexts are used by fields on this page:
SpamGenericVariable(Variables)SpamUrlVariable(Variables)SpamEmailVariable(Variables)SpamIpVariable(Variables)SpamHeaderVariable(Variables)