Skip to content

Ntfy Notifications

Overview

Ntfy is an easy to use messaging service that supports both public cloud usage (https://ntfy.sh) and self-hosted private servers.

Apprise supports both insecure (ntfy://) and secure (ntfys://) schemas.


Ntfy can send notifications through the following modes:

Valid syntax is as follows:

  • ntfy://{topic}
  • ntfy://{host}/{topic}
  • ntfy://{host}:{port}/{topics}
  • ntfy://{user}@{host}/{topics}
  • ntfy://{user}@{host}:{port}/{topics}
  • ntfy://{user}:{password}@{host}/{topics}
  • ntfy://{user}:{password}@{host}:{port}/{topics}
  • ntfy://{token}@{hostname}/{topics}

The secure versions:

  • ntfys://{topic}
  • ntfys://{host}/{topic}
  • ntfys://{host}:{port}/{topics}
  • ntfys://{user}@{host}/{topics}
  • ntfys://{user}@{host}:{port}/{topics}
  • ntfys://{user}:{password}@{host}/{topics}
  • ntfys://{user}:{password}@{host}:{port}/{topics}
  • ntfys://{token}@{hostname}/{topics}

You can specify more than one topic:

  • ntfy://{user}:{password}@{hostname}/{topic1}/{topic2}
Variable Required Description
user No The user account to authenticate with.
password No The password used for authentication.
hostname No The ntfy server to send notifications to.
port No Defaults to 80 for ntfy:// and 443 for ntfys://.
topic Yes At least one topic must be defined.
to No Another way to list the topics to notify, separated by a comma. This is an alias of topic.
token No Authorization token (auto-detected if provided in URL).
mode No Server mode. Auto-detected. Possible values: private, cloud.
auth No basic (default) or token.
email No Associate an email address with the ntfy post.
xtags No ntfy message tags (sent as the X-Tags header) to associate with the notification. Use comma and/or space to specify more than one. The legacy tags= parameter is still accepted as a backward-compatible alias. These are not to be confused with Apprise tags; see here for more details.
attach No URL pointing to a remote attachment to reference.
filename No Override the attachment filename.
click No Hyperlink users are directed to when clicking the notification.
priority No One of max, high, default, low, or min. Defaults to default.
actions No ntfy action button definitions.
delay No Delay message delivery.
image No Defaults to Yes; includes image preview when available.
avatar_url No Override the Apprise icon with a custom image URL.

If your Ntfy server is behind an HTTPS (Secure) hosted setup, then you simply use ntfys://:

Variable Description
overflow Controls messages that exceed a service’s documented limit. The default is upstream.
👉 upstream: Send one message without splitting or truncating it for that limit.
👉 truncate: Keep the portion that fits and discard the rest.
👉 split: Prefer a readable break, fall back to a hard boundary, and send every part in order.
Splitting undeclared or structured content is best effort. Use upstream when the body must remain one intact document.
format This 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.
verify External 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.
redirect By default, Apprise will follow HTTP redirects (3xx responses) issued by the remote server, matching the behaviour of the underlying requests library. If you want to prevent custom headers and credentials from being forwarded to destinations that differ from the original URL, set this to no. By default it is set to yes.
cto This 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.
rto This 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.
emojis Enable 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.
tz Identify 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.
retry The number of additional delivery attempts to make after the first failure before giving up. Accepts an integer in the range 0 to 10. The default is 0 (no retries – a single attempt is made). When combined with wait, Apprise pauses the specified number of seconds between each attempt.
wait The number of seconds to pause between retry attempts. Accepts a decimal value in the range 0.0 to 20.0; integer values are promoted to float automatically. The default is 0.5. This value is only meaningful when retry is greater than zero – a service with retry=0 makes exactly one attempt regardless of the wait value.
optional When set to yes, a delivery failure for this service is silently absorbed. The overall notify() call still evaluates as true even if this endpoint was unreachable, provided that every required (non-optional) service in the same batch succeeded. Setting this flag does not skip delivery or bypass retry logic – all configured retry attempts are still made before the failure is absorbed. By default this is set to no, meaning every failure is propagated to the caller.

The xtags= parameter above refers to ntfy message tags only (sent as the X-Tags header). The legacy tags= spelling is still accepted for backward compatibility but xtags= is preferred going forward.

These tags are sent directly to the ntfy server and appear as labels or emojis on the delivered notification.

They are not the same as Apprise routing tags.

Apprise routing tags are configured in your Apprise configuration file (using tag: or tags: in YAML) and control which notification services are triggered. They have no effect on the X-Tags header sent to the ntfy server.

Below is an example of a Ntfy message being sent that includes tags:

Terminal window
apprise -vv -t "Failure" -b "Something went wrong" \
"ntfy://localhost/mytopic?priority=high&xtags=warning"

Below is an example that furthers onto the above by showing multiple (Ntfy) tags are supported too:

Terminal window
apprise -vv -t "Alert" -b "Disk space low" \
"ntfy://localhost/mytopic?priority=high&xtags=warning,storage"

Apprise YAML configuration files can sometimes introduce confusion since they also use tags. Below shows the clear separation between Apprise tag: and ntfy xtags=.

apprise.yaml
urls:
- ntfy://localhost/mytopic?priority=high&xtags=warning:
tag: ntfy-alert

In the example above:

  • xtags=warning: Ntfy message tag (sets the X-Tags: warning header)

  • tag: ntfy-alert: Apprise routing tag; this would later be expected to be triggered by:

    Terminal window
    apprise -vv -t "Alert" -b "Disk space low" \
    --tag=ntfy-alert --config=apprise.yaml

Send a notification to your own Ntfy server:

Terminal window
# Assuming our {hostname} is myserver.example.ca
# Assuming our {topic} is topic1
apprise -vv -t "Test Message Title" -b "Test Message Body" \
ntfy://myserver.example.ca/topic1

We can also send a notification to the open and free ntfy.sh server:

Terminal window
# Assuming our {topic} is topic1
apprise -vv -t "Test Message Title" -b "Test Message Body" \
ntfy://topic1

Ntfy also supports Markdown; if you want to leverage this, simply add ?format=markdown to your Apprise URL; eg:

Terminal window
# Assuming our {hostname} is localhost
# Assuming our {topic} is great-place
# Assuming we want to leverage the markdown support
apprise -vv -t "Test Message Title" -b "# Markdown Support" \
"ntfy://localhost/great-place?format=markdown"

Secure HTTPS usage:

Terminal window
# Assuming our SECURE {hostname} is localhost
# Assuming our {topic} is great-topic
apprise -vv -t "Test Secure Message Title" -b "Test Message Body" \
ntfys://localhost/great-topic

Using ntfy action buttons:

Terminal window
apprise -vv -t "Title" -b "Message content" \
ntfy://ntfy.selfhostedexample.com/mytopic?actions=view%2CGoogle%2Chttps://www.google.com%3Bview%2CBing%2Chttps://www.bing.com
Questions or Feedback?

Documentation

Notice a typo or an error?

Technical Issues

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

Made with love from Canada