Sending push notifications with ntfy
Using Other Clients
Curl isn't the only usable tool to send notifications to your ntfy server. The ntfy
binary operates both as a server and a client. Earlier, I used the ntfy client to create users and give them access to specific topics. I executed the ntfy
binary in the Docker container, which was the same binary as the one running as a server. You can also install the binary as a DEB or RPM package from the ntfy releases [7] on GitHub. After this, define your custom host and the default username and password in ~/.config/ntfy/client.yml
:
default-host: https://ntfy.example.com default-user: admin default-password: password
You can then publish a message to a topic with
$ ntfy publish mytopic "This is my message"
And subscribe to a topic with
$ ntfy subscribe mytopic
The command will stay listening indefinitely, printing a JSON representation of every message published to the topic. Additionally, a command can be executed for every incoming message, for instance:
$ ntfy subscribe backup 'notify-send "$message"'
The ntfy documentation [8] provides numerous examples. It also shows how to publish or subscribe to topics using several programming languages. For instance, the Python code in Listing 7 sends a notification regarding a backup error through the Requests [9] library.
Listing 7
Sending a ntfy Message from Python
01 import requests 02 03 requests.post("http://ntfy.example.com/backup", 04 data="Backup unsuccessful", 05 headers={ 06 "Authorization": "Basic YmFja3VwOnBhc3N3b3Jk", 07 "Title": "Backup failure", 08 "Priority": "urgent", 09 "Tags": "warning,skull" 10 })
The Authorization header uses Base64 to encode the colon-separated username:password
pair. You can generate this encoded string with
echo "Basic $(echo -n 'backup:password' | base64)"
Conclusion
Ntfy is a powerful tool for sending notifications from various sources while staying in complete control. I didn't cover all of ntfy's functionality in this article. For instance, ntfy can forward messages via email using a configured SMTP server. Ntfy can also run a lightweight SMTP server. With this setup, users can send emails to an email address specific to a topic to publish messages to that topic. This is a useful feature for services that support notifications via email but not via HTTP.
You can also use ntfy to send topics via an HTTP GET
request if a program doesn't support HTTP POST
. Other options include publishing messages as JSON if a program doesn't allow you to add custom headers to HTTP requests, scheduling the delivery of messages, and using message templates. All these features are extensively documented on ntfy's website, including many examples for integrations with other software.
Infos
- ntfy: https://ntfy.sh
- Caddy: https://caddyserver.com
- F-Droid: https://f-droid.org
- curl: https://curl.se
- Markdown: https://www.markdownguide.org
- Android broadcast intent: https://developer.android.com/develop/background-work/background-tasks/broadcasts
- ntfy releases: https://github.com/binwiederhier/ntfy/releases
- ntfy documentation: https://docs.ntfy.sh
- Requests: https://requests.readthedocs.io
« Previous 1 2 3 4
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

News
-
Linux Kernel 6.17 is Available
Linus Torvalds has announced that the latest kernel has been released with plenty of core improvements and even more hardware support.
-
Kali Linux 2025.3 Released with New Hacking Tools
If you're a Kali Linux fan, you'll be glad to know that the third release of this famous pen-testing distribution is now available with updates for key components.
-
Zorin OS 18 Beta Available for Testing
The latest release from the team behind Zorin OS is ready for public testing, and it includes plenty of improvements to make it more powerful, user-friendly, and productive.
-
Fedora Linux 43 Beta Now Available for Testing
Fedora Linux 43 Beta ships with Gnome 49 and KDE Plasma 6.4 (and other goodies).
-
USB4 Maintainer Leaves Intel
Michael Jamet, one of the primary maintainers of USB4 and Thunderbolt drivers, has left Intel, leaving a gaping hole for the Linux community to deal with.
-
Budgie 10.9.3 Now Available
The latest version of this elegant and configurable Linux desktop aligns with changes in Gnome 49.
-
KDE Linux Alpha Available for Daring Users
It's official, KDE Linux has arrived, but it's not quite ready for prime time.
-
AMD Initiates Graphics Driver Updates for Linux Kernel 6.18
This new AMD update focuses on power management, display handling, and hardware support for Radeon GPUs.
-
AerynOS Alpha Release Available
With a choice of several desktop environments, AerynOS 2025.08 is almost ready to be your next operating system.
-
AUR Repository Still Under DDoS Attack
Arch User Repository continues to be under a DDoS attack that has been going on for more than two weeks.