--- title: How to use my hosted ntfy instance visibility: public --- One really cool thing I'm happy to have [self-hosted](https://ntfy.maddiem4.cc/) is [ntfy.sh](https://ntfy.sh/), which makes it easy to privately and securely get push notifications on my devices when tasks complete. I'd like to document how to use this, since other members of my household will likely need it, and I don't want to forget either! Fundamentally, you want something like this in your `~/.bashrc`: ```bash export NTFY_TOKEN="tk_blahblahblah" export NTFY_DEFAULT_TOPIC="maddie-alerts" ntfy() { local msg="$1" local topic="$2" if [ -z "$topic" ]; then topic="$NTFY_DEFAULT_TOPIC" fi curl -d "$msg" \ -H "Authorization: Bearer $NTFY_TOKEN" \ "https://ntfy.maddiem4.cc/$topic" } ``` Once you have that in your shell, you can do stuff like: ```bash ntfy "Send this alert to my default topic" ntfy "And now an alert for a specific topic" specific-topic ``` It's those _exports_ you'll want to customize. Your default topic can be whatever you want (as long as you have access to it). But what about the token? Well, you have to ask me, and here's what I end up having to do on the host machine. ```bash ssh indiana.local cd ~/projects/personal_site docker-compose exec -it ntfy ntfy user add --role=admin yourname # if necessary docker-compose exec -it ntfy ntfy token add --label yourcomputer yourname ``` You'll need to pick a password. I don't want to know it, but make sure it's written down. You'll need it for [subscribing via the phone app](https://docs.ntfy.sh/subscribe/phone/?h=phone) too. Once you've put it in during the user creation prompt, I can give you the resulting token for use in your `.bashrc`.