|
@@ -1,6 +1,7 @@
|
|
|
# Publishing
|
|
|
-Publishing messages can be done via HTTP PUT or POST. Topics are created on the fly by subscribing or publishing to them.
|
|
|
-Because there is no sign-up, **the topic is essentially a password**, so pick something that's not easily guessable.
|
|
|
+Publishing messages can be done via HTTP PUT/POST or via the [ntfy CLI](install.md). Topics are created on the fly by
|
|
|
+subscribing or publishing to them. Because there is no sign-up, **the topic is essentially a password**, so pick
|
|
|
+something that's not easily guessable.
|
|
|
|
|
|
Here's an example showing how to publish a simple message using a POST request:
|
|
|
|
|
@@ -9,6 +10,11 @@ Here's an example showing how to publish a simple message using a POST request:
|
|
|
curl -d "Backup successful π" ntfy.sh/mytopic
|
|
|
```
|
|
|
|
|
|
+=== "ntfy CLI"
|
|
|
+ ```
|
|
|
+ ntfy publish mytopic "Backup successful π"
|
|
|
+ ```
|
|
|
+
|
|
|
=== "HTTP"
|
|
|
``` http
|
|
|
POST /mytopic HTTP/1.1
|
|
@@ -67,6 +73,16 @@ a [title](#message-title), and [tag messages](#tags-emojis) π₯³ π. Here's an
|
|
|
ntfy.sh/phil_alerts
|
|
|
```
|
|
|
|
|
|
+=== "ntfy CLI"
|
|
|
+ ```
|
|
|
+ ntfy publish \
|
|
|
+ --title "Unauthorized access detected" \
|
|
|
+ --tags warning,skull \
|
|
|
+ --priority urgent \
|
|
|
+ mytopic \
|
|
|
+ "Remote access to phils-laptop detected. Act right away."
|
|
|
+ ```
|
|
|
+
|
|
|
=== "HTTP"
|
|
|
``` http
|
|
|
POST /phil_alerts HTTP/1.1
|
|
@@ -143,6 +159,13 @@ you can set the `X-Title` header (or any of its aliases: `Title`, `ti`, or `t`).
|
|
|
curl -H "t: Dogs are better than cats" -d "Oh my ..." ntfy.sh/controversial
|
|
|
```
|
|
|
|
|
|
+=== "ntfy CLI"
|
|
|
+ ```
|
|
|
+ ntfy publish \
|
|
|
+ -t "Dogs are better than cats" \
|
|
|
+ controversial "Oh my ..."
|
|
|
+ ```
|
|
|
+
|
|
|
=== "HTTP"
|
|
|
``` http
|
|
|
POST /controversial HTTP/1.1
|
|
@@ -216,6 +239,13 @@ You can set the priority with the header `X-Priority` (or any of its aliases: `P
|
|
|
curl -H p:4 -d "A high priority message" ntfy.sh/phil_alerts
|
|
|
```
|
|
|
|
|
|
+=== "ntfy CLI"
|
|
|
+ ```
|
|
|
+ ntfy publish \
|
|
|
+ -p 5 \
|
|
|
+ phil_alerts An urgent message
|
|
|
+ ```
|
|
|
+
|
|
|
=== "HTTP"
|
|
|
``` http
|
|
|
POST /phil_alerts HTTP/1.1
|
|
@@ -320,6 +350,13 @@ them with a comma, e.g. `tag1,tag2,tag3`.
|
|
|
curl -H ta:dog -d "Dogs are awesome" ntfy.sh/backups
|
|
|
```
|
|
|
|
|
|
+=== "ntfy CLI"
|
|
|
+ ```
|
|
|
+ ntfy publish \
|
|
|
+ --tags=warning,mailsrv13,daily-backup \
|
|
|
+ backups "Backup of mailsrv13 failed"
|
|
|
+ ```
|
|
|
+
|
|
|
=== "HTTP"
|
|
|
``` http
|
|
|
POST /backups HTTP/1.1
|
|
@@ -395,6 +432,13 @@ to be delivered in 3 days, it'll remain in the cache for 3 days and 12 hours. Al
|
|
|
curl -H "Delay: 1639194738" -d "Unix timestamps are awesome" ntfy.sh/itsaunixsystem
|
|
|
```
|
|
|
|
|
|
+=== "ntfy CLI"
|
|
|
+ ```
|
|
|
+ ntfy publish \
|
|
|
+ --at="tomorrow, 10am" \
|
|
|
+ hello "Good morning"
|
|
|
+ ```
|
|
|
+
|
|
|
=== "HTTP"
|
|
|
``` http
|
|
|
POST /hello HTTP/1.1
|
|
@@ -473,6 +517,11 @@ For instance, assuming your topic is `mywebhook`, you can simply call `/mywebhoo
|
|
|
curl ntfy.sh/mywebhook/trigger
|
|
|
```
|
|
|
|
|
|
+=== "ntfy CLI"
|
|
|
+ ```
|
|
|
+ ntfy trigger mywebhook
|
|
|
+ ```
|
|
|
+
|
|
|
=== "HTTP"
|
|
|
``` http
|
|
|
GET /mywebhook/trigger HTTP/1.1
|
|
@@ -510,6 +559,13 @@ Here's an example with a custom message, tags and a priority:
|
|
|
curl "ntfy.sh/mywebhook/publish?message=Webhook+triggered&priority=high&tags=warning,skull"
|
|
|
```
|
|
|
|
|
|
+=== "ntfy CLI"
|
|
|
+ ```
|
|
|
+ ntfy publish \
|
|
|
+ -p 5 --tags=warning,skull \
|
|
|
+ mywebhook "Webhook triggered"
|
|
|
+ ```
|
|
|
+
|
|
|
=== "HTTP"
|
|
|
``` http
|
|
|
GET /mywebhook/publish?message=Webhook+triggered&priority=high&tags=warning,skull HTTP/1.1
|
|
@@ -559,6 +615,13 @@ are still delivered to connected subscribers, but [`since=`](subscribe/api.md#fe
|
|
|
curl -H "Cache: no" -d "This message won't be stored server-side" ntfy.sh/mytopic
|
|
|
```
|
|
|
|
|
|
+=== "ntfy CLI"
|
|
|
+ ```
|
|
|
+ ntfy publish \
|
|
|
+ --no-cache \
|
|
|
+ mytopic "This message won't be stored server-side"
|
|
|
+ ```
|
|
|
+
|
|
|
=== "HTTP"
|
|
|
``` http
|
|
|
POST /mytopic HTTP/1.1
|
|
@@ -624,6 +687,13 @@ to `no`. This will instruct the server not to forward messages to Firebase.
|
|
|
curl -H "Firebase: no" -d "This message won't be forwarded to FCM" ntfy.sh/mytopic
|
|
|
```
|
|
|
|
|
|
+=== "ntfy CLI"
|
|
|
+ ```
|
|
|
+ ntfy publish \
|
|
|
+ --no-firebase \
|
|
|
+ mytopic "This message won't be forwarded to FCM"
|
|
|
+ ```
|
|
|
+
|
|
|
=== "HTTP"
|
|
|
``` http
|
|
|
POST /mytopic HTTP/1.1
|