Skip to content

Matrix Notifications

Overview

By default, Apprise communicates directly with your Matrix server using the official Client API.

Alternatively, you may use webhook mode instead of the Matrix Client API. Webhook usage is enabled by specifying ?mode=matrix, ?mode=slack, or ?mode=hookshot depending on the webhook service you have configured.

Valid syntax is as follows:

Using a username and password:

  • matrix://{user}:{password}@{hostname}/#{room_alias}
  • matrixs://{user}:{password}@{hostname}/!{room_id}

Using a pre-generated access token (no username or password required):

  • matrix://{token}@{hostname}/#{room_alias}
  • matrixs://{token}@{hostname}/!{room_id}

You may also supply the token as a query parameter:

  • matrixs://{hostname}/#{room_alias}?token={token}

Room aliases are prefixed with #. You may specify multiple room aliases by separating them with a forward slash:

  • matrixs://{user}:{password}@{hostname}/#{room_alias}
  • matrixs://{user}:{password}@{hostname}/#{room_alias1}/#{room_alias2}
  • matrixs://{token}@{hostname}/#{room_alias1}/#{room_alias2}

Room IDs are prefixed with !. You may specify multiple room IDs in the same way:

  • matrixs://{user}:{password}@{hostname}/!{room_id}
  • matrixs://{user}:{password}@{hostname}/!{room_id1}/!{room_id2}
  • matrixs://{token}@{hostname}/!{room_id1}/!{room_id2}

To send a direct message (DM) to a Matrix user, prefix the target with @. You may optionally include the homeserver component on the target:

  • matrixs://{user}:{password}@{hostname}/@{target_user}
  • matrixs://{user}:{password}@{hostname}/@{target_user}:{homeserver}
  • matrixs://{token}@{hostname}/@{target_user}
  • matrixs://{token}@{hostname}/@{target_user}:{homeserver}

You may notify multiple DM users in a single URL:

  • matrixs://{user}:{password}@{hostname}/@{user1}/@{user2}
  • matrixs://{token}@{hostname}/@{user1}/@{user2}

Room aliases (#), room IDs (!), and DM users (@) can be freely mixed and matched in any order in a single URL:

  • matrixs://{user}:{password}@{hostname}/#{room_alias}/@{target_user}
  • matrixs://{user}:{password}@{hostname}/#{room_alias}/!{room_id}/@{target_user}
  • matrixs://{token}@{hostname}/#{room_alias}/!{room_id}/@{target_user}

Matrix supports both:

  • Room aliases (prefixed with #)
  • Room IDs (prefixed with !)

Room identifiers may include a homeserver component (for example :example.com). In Matrix, room aliases are typically written with a homeserver, and room IDs are generally expected to include one as well.

Examples:

  • #general
  • #general:example.com
  • !abc123
  • !abc123:example.com

By default, Apprise enforces a homeserver on room identifiers when it is missing.

If you provide:

  • #room: it is internally interpreted as #room:{hostname}
  • !room: it is internally interpreted as !room:{hostname}

If you explicitly include a homeserver component, Apprise honours it exactly as specified.

You may disable homeserver enforcement by specifying ?hsreq=no. In this setting:

  • #room is used exactly as provided.
  • !room is used exactly as provided.

hsreq applies only to room identifiers (# and !). DM user targets (@) are not affected — they always have the authenticated homeserver applied when no explicit homeserver is included in the target.

This is intended for environments where a reverse proxy, non-standard server behaviour, or strict URL routing makes :homeserver suffixing undesirable.

If you are using room IDs (prefixed with !), note that many Matrix deployments expect fully-qualified room IDs. If your server rejects !room:{hostname} but accepts !room as-is, hsreq=no may be required.

For example; given:

matrix://user:pass@localhost/#room/!abc123

With default behaviour (hsreq=yes):

  • #room becomes #room:localhost
  • !abc123 becomes !abc123:localhost

With enforcement disabled:

matrix://user:pass@localhost/#room/!abc123?hsreq=no
  • #room is used as #room
  • !abc123 is used as !abc123

In both cases, a DM target such as @alice would become @alice:localhost regardless of hsreq.

When specifying the ?mode= argument, the plugin switches entirely to webhook behaviour and the syntax changes:

  • matrix://{user}:{token}@{hostname}?mode=matrix
  • matrixs://{token}@{hostname}:{port}?mode=matrix
  • matrix://{user}:{token}@{hostname}?mode=slack&format=markdown
  • matrixs://{token}@{hostname}?mode=slack&format=markdown
  • matrix://{user}:{token}@{hostname}?mode=hookshot
  • matrixs://{user}:{token}@{hostname}?mode=hookshot&path=/webhook

When using matrix-hookshot, the webhook path is configurable and defaults to /webhook:

  • matrixs://{user}:{token}@{hostname}?mode=hookshot
  • matrixs://{user}:{token}@{hostname}?mode=hookshot&path=/public-hooks

If you use t2bot.io, you may use:

  • matrix://{t2bot_webhook_token}
  • matrix://{user}@{t2bot_webhook_token}

Or directly:

  • https://webhooks.t2bot.io/api/v1/matrix/hook/{t2bot_webhook_token}
VariableRequiredDescription
hostname*YesThe Matrix server you wish to connect to.
t2bot_webhook_token*YesUsed when leveraging t2bot webhook mode. Acts as hostname in this case.
userNoThe user to authenticate (and/or register) with the Matrix server.
passwordNoThe password to authenticate (and/or register) with the Matrix server.
tokenNoA pre-generated Matrix access token. Use this instead of user and password when your server disables password login (for example, SSO-only deployments). May also be supplied as ?token= in the URL. When used without a username, place the token in the user position: matrix://{token}@{hostname}/.
portNoThe server port Matrix is listening on. By default matrixs:// uses port 443, while matrix:// uses port 80.
room_aliasNoThe room alias to join and notify. It is recommended to prefix with #.
room_idNoThe room ID to join and notify. You must prefix this with !.
thumbnailNoDisplays an image before each notification identifying the notification type. Default is False.
modeNoEnables webhook mode. Valid values are matrix, slack, t2bot, and hookshot.
pathNoUsed with hookshot mode to define the public webhook path. Defaults to /webhook. For example, if your hookshot instance is exposed at https://hookshot.example/public-hooks/{token}, then set ?mode=hookshot&path=/public-hooks.
msgtypeNoMatrix message type: text or notice. Default is text.
versionNoOverrides the Matrix Client API version. Supported values are 2 and 3. Default is 3. May also be supplied as ?v=.
hsreqNoWhen enabled (the default), Apprise automatically appends the authenticated homeserver to room identifiers that do not already include one. For example, #room becomes #room:hostname. Set to no to disable this and use room identifiers exactly as provided.
e2eeNoControls end-to-end encryption using the Matrix Olm/MegOLM protocol. When enabled (the default), Apprise automatically detects whether each room has encryption configured and encrypts both messages and attachments for those that do, while sending others as plain text. When Apprise creates a new room with e2ee=yes, it sets m.room.encryption at creation time so the room is encrypted from the very first message. Requires the cryptography Python package and a matrixs:// (HTTPS) connection. Not supported in webhook mode. Set to no to always send unencrypted and to skip E2EE room creation. Default is yes.
target_userNoA Matrix user ID to notify via direct message. Must be prefixed with @, for example @alice or @alice:homeserver. Apprise looks up (or creates) a DM room with that user automatically. Not supported in webhook mode.
discoveryNoWhen enabled (the default), Apprise performs a .well-known/matrix/client server-discovery lookup on first use to resolve the actual homeserver base URL. Set to no to skip discovery and connect directly to the specified hostname. Automatically disabled in webhook mode. Default is yes.
VariableDescription
overflowThis parameter can be set to either split, truncate, or upstream. This determines how Apprise delivers the message you pass it. By default this is set to upstream
👉 upstream: Do nothing at all; pass the message exactly as you received it to the service.
👉 truncate: Ensure that the message will fit within the service’s documented upstream message limit. If more information was passed then the defined limit, the overhead information is truncated.
👉 split: similar to truncate except if the message doesn’t fit within the service’s documented upstream message limit, it is split into smaller chunks and they are all delivered sequentially there-after.
formatThis parameter can be set to either text, html, or markdown. Some services support the ability to post content by several different means. The default of this varies (it can be one of the 3 mentioned at any time depending on which service you choose). You can optionally force this setting to stray from the defaults if you wish. If the service doesn’t support different types of transmission formats, then this field is ignored.
verifyExternal requests made to secure locations (such as through the use of https) will have certificates associated with them. By default, Apprise will verify that these certificates are valid; if they are not then no notification will be sent to the source. In some occasions, a user might not have a certificate authority to verify the key against or they trust the source; in this case you will want to set this flag to no. By default it is set to yes.
ctoThis stands for Socket Connect Timeout. This is the number of seconds Requests will wait for your client to establish a connection to a remote machine (corresponding to the connect()) call on the socket. The default value is 4.0 seconds.
rtoThis stands for Socket Read Timeout. This is the number of seconds the client will wait for the server to send a response. The default value is 4.0 seconds.
emojisEnable Emoji support (such as providing :+1: would translate to 👍). By default this is set to no.
Note: Depending on server side settings, the administrator has the power to disable emoji support at a global level; but default this is not the case.
tzIdentify the IANA Time Zone Database you wish to operate as. By default this is detected based on the configuration the server hosting Apprise is running on. You can set this to things like America/Toronto, or any other properly formated Timezone describing your area.

Send a secure Matrix notification using a username and password:

Terminal window
# Assuming {hostname} is matrix.example.com
# Assuming {user} is nuxref
# Assuming {password} is abc123
# Notify #general and #apprise
apprise -vv -t "Test Message Title" -b "Test Message Body" \
matrixs://nuxref:abc123@matrix.example.com/#general/#apprise

Send a notification using a pre-generated access token (useful when password login is disabled on the server):

Terminal window
# Assuming {hostname} is matrix.example.com
# Assuming {token} is syt_abc123...
apprise -vv -t "Test Message Title" -b "Test Message Body" \
"matrixs://syt_abc123@matrix.example.com/#general"

Disable homeserver enforcement:

Terminal window
apprise -vv -t "Test Message Title" -b "Test Message Body" \
matrixs://nuxref:abc123@matrix.example.com/!abc123?hsreq=no

Use API v2 (required for attachments in some deployments):

Terminal window
apprise -vv -t "Test Message Title" -b "Test Message Body" \
matrixs://nuxref:abc123@matrix.example.com/#general?v=2

E2EE is enabled by default when the cryptography package is installed and the room supports it. To explicitly disable E2EE (always send unencrypted):

Terminal window
apprise -vv -t "Test Message Title" -b "Test Message Body" \
"matrixs://nuxref:abc123@matrix.example.com/#general?e2ee=no"

Send a direct message to a Matrix user:

Terminal window
# Assuming {hostname} is matrix.example.com
# Assuming {user} is nuxref, {password} is abc123
# DM @bob on the same homeserver
apprise -vv -t "Test Message Title" -b "Test Message Body" \
matrixs://nuxref:abc123@matrix.example.com/@bob

Send a direct message using a pre-generated access token:

Terminal window
# Assuming {hostname} is matrix.example.com
# Assuming {token} is syt_abc123...
apprise -vv -t "Test Message Title" -b "Test Message Body" \
"matrixs://syt_abc123@matrix.example.com/@bob"

Send a t2bot.io webhook request:

Terminal window
# Assuming {webhook} is ABCDEFG12345
apprise -vv -t "Test Message Title" -b "Test Message Body" \
matrix://ABCDEFG12345

Send a matrix-hookshot webhook request:

Terminal window
# Assuming {hostname} is hookshot.example.com
# Assuming {token} is ABCDEFG12345
apprise -vv -t "Test Message Title" -b "Test Message Body" \
"matrixs://apprise:ABCDEFG12345@hookshot.example.com?mode=hookshot"

If your hookshot instance is exposed behind a custom public webhook path:

Terminal window
apprise -vv -t "Test Message Title" -b "Test Message Body" \
"matrixs://apprise:ABCDEFG12345@hookshot.example.com?mode=hookshot&path=/public-hooks"
Questions or Feedback?

Documentation

Notice a typo or an error? Report it or contribute a fix .

Technical Issues

Having trouble with the code? Open an issue on GitHub:

Made with love from Canada