Skip to main content
Version: 0.16

Alert

Defines an alert rule triggered by metric conditions.

Enterprise feature

This object is only available with an Enterprise license.

This object can be configured from the WebUI under Settings › Telemetry › Alerts

Fields

condition

Type: Expression · required

The condition that triggers the alert.

emailAlert

Type: AlertEmail · required

Email notification settings

eventAlert

Type: AlertEvent · required

Event notification settings

enable

Type: Boolean · default: true

Enable or disable the alert

JMAP API

The Alert object is available via the urn:stalwart:jmap capability.

x:Alert/get

This is a standard Foo/get method as defined in RFC 8620, Section 5.1.

This method requires the sysAlertGet permission.

curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:Alert/get",
{
"ids": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

x:Alert/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 sysAlertCreate permission.

curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:Alert/set",
{
"create": {
"new1": {
"condition": {
"else": "Example",
"match": []
},
"emailAlert": {
"@type": "Disabled"
},
"enable": true,
"eventAlert": {
"@type": "Disabled"
}
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

Update

This operation requires the sysAlertUpdate permission.

curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:Alert/set",
{
"update": {
"id1": {
"condition": {
"else": "Example",
"match": []
}
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

Destroy

This operation requires the sysAlertDestroy permission.

curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:Alert/set",
{
"destroy": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

x:Alert/query

This is a standard Foo/query method as defined in RFC 8620, Section 5.5.

This method requires the sysAlertQuery permission.

curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:Alert/query",
{
"filter": {}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

CLI

stalwart-cli wraps the same JMAP calls. See the CLI reference for installation, authentication, and general usage.

Fetch

stalwart-cli get alert id1

Create

stalwart-cli create alert \
--field 'condition={"else":"Example","match":[]}' \
--field 'emailAlert={"@type":"Disabled"}' \
--field 'eventAlert={"@type":"Disabled"}' \
--field enable=true

Query

stalwart-cli query alert

Update

stalwart-cli update alert id1 --field description='Updated'

Delete

stalwart-cli delete alert --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 · required

Else condition

ExpressionMatch

A single condition-result pair in an expression.

if

Type: String · required

If condition

then

Type: String · required

Then clause

AlertEmail

Defines email notification settings for alerts.

  • Disabled: Disabled. No additional fields.
  • Enabled: Enabled. Carries the fields of AlertEmailProperties.

AlertEmailProperties

Alert email notification settings.

body

Type: Text · required

The body of the email

fromAddress

Type: EmailAddress · required

The email address of the sender

fromName

Type: String?

The name of the sender

subject

Type: String · required

The subject of the email

to

Type: EmailAddress[] · min items: 1

The email address of the recipient(s)

AlertEvent

Defines event notification settings for alerts.

  • Disabled: Disabled. No additional fields.
  • Enabled: Enabled. Carries the fields of AlertEventProperties.

AlertEventProperties

Alert event notification settings.

eventMessage

Type: Text?

The message of the event to trigger