Send a simple message
curl -u <username>:<password> \
-d "Backup finished successfully" \
https://ntfy.mokoenterprises.us/mytopic
Using an access token instead of a password:
curl -H "Authorization: Bearer <token>" \
-d "Backup finished successfully" \
https://ntfy.mokoenterprises.us/mytopic
Create an access token from Account › Access tokens in the web app. When you create a token you can Download as JSON to save its value, label, expiry, and base URL to a file - useful for storing it in a secrets manager, since the raw token isn't shown again later. Existing tokens offer the same JSON download.
Add a title, priority, and tags
curl -u <username>:<password> \
-H "Title: Nightly backup" \
-H "Priority: high" \
-H "Tags: floppy_disk,white_check_mark" \
-d "Backup finished successfully" \
https://ntfy.mokoenterprises.us/mytopic
From Python
import requests
requests.post(
"https://ntfy.mokoenterprises.us/mytopic",
data="Backup finished successfully".encode("utf-8"),
auth=("<username>", "<password>"),
headers={"Title": "Nightly backup", "Priority": "high"},
)
More options
- Priority -
min,low,default,high,max. On a topic set to Important only, subscribers are notified forhighandmaxmessages. - Tags/emojis - the
Tagsheader adds labels and emoji to the notification. - Click action - the
Clickheader opens a URL when the notification is tapped. - Attachments - send a file with the
--data-binaryoption and aFilenameheader. - Email - the
Emailheader forwards the notification to an email address (email delivery is enabled on this instance).
For the full list of publishing options, see the upstream ntfy publishing documentation.