You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some services let you specify a webhook URL but do not let you modify the webhook body (e.g. GitHub, Grafana). Instead of using a separate
944
+
bridge program to parse the webhook body into the format ntfy expects, you can include a templated message and/or a templated title
945
+
which will be populated based on the fields of the webhook body (so long as the webhook body is valid JSON).
946
+
947
+
Enable templating by setting the `X-Template` header (or its aliases `Template` or `tpl`) to `yes`, or (more appropriately for webhooks)
948
+
by setting the `?template=yes` query parameter. Then, include templates in your message and/or title by including paths to the
949
+
appropriate JSON fields surrounded by `${` and `}`, e.g. `${alert.title}` or `${error.desc}`, depending on your JSON payload.
950
+
951
+
Please refer to the [GJSON docs](https://github.com/tidwall/gjson/blob/master/SYNTAX.md) for supported JSON path syntax, as well as
952
+
[gjson.dev](https://gjson.dev/) to test your templates.
953
+
954
+
=== "HTTP"
955
+
``` http
956
+
POST /mytopic HTTP/1.1
957
+
Host: ntfy.sh
958
+
X-Message: Error message: ${error.desc}
959
+
X-Title: ${hostname}: A ${error.level} error has occurred
960
+
X-Template: yes
961
+
962
+
{"hostname": "philipp-pc", "error": {"level": "severe", "desc": "Disk has run out of space"}}
963
+
```
964
+
965
+
The example above would send a notification with a title "philipp-pc: A severe error has occurred" and a message "Error message: Disk has run out of space".
966
+
967
+
For Grafana webhooks, you might find it helpful to use the headers `X-Title: Grafana alert: ${title}` and `X-Message: ${message}`.
968
+
Alternatively, you can include the params in the webhook URL. For example, by
969
+
appending `?template=yes&title=Grafana alert: ${title}&message=${message}` to the URL.
@@ -3557,34 +3588,6 @@ ntfy server plays the role of the Push Gateway, as well as the Push Provider. Un
3557
3588
!!! info
3558
3589
This is not a generic Matrix Push Gateway. It only works in combination with UnifiedPush and ntfy.
3559
3590
3560
-
### Message and Title Templates
3561
-
Some services let you specify a webhook URL but do not let you modify the webhook body (e.g., Grafana). Instead of using a separate
3562
-
bridge program to parse the webhook body into the format ntfy expects, you can include a templated message and/or a templated title
3563
-
which will be populated based on the fields of the webhook body (so long as the webhook body is valid JSON).
3564
-
3565
-
Enable templating by setting the `X-Template` header (or its aliases `Template` or `tpl`) to "yes". Then, include templates
3566
-
in your message and/or title (no other fields can be filled with a template at this time) by including paths to the
3567
-
appropriate JSON fields surrounded by `${` and `}`. See an example below.
3568
-
See [GJSON docs](https://github.com/tidwall/gjson/blob/master/SYNTAX.md) for supported JSON path syntax.
3569
-
[https://gjson.dev/](https://gjson.dev/) is a great resource for testing your templates.
3570
-
3571
-
=== "HTTP"
3572
-
``` http
3573
-
POST /mytopic HTTP/1.1
3574
-
Host: ntfy.sh
3575
-
X-Message: Error message: ${error.desc}
3576
-
X-Title: ${hostname}: A ${error.level} error has occurred
3577
-
X-Template: yes
3578
-
3579
-
{"hostname": "philipp-pc", "error": {"level": "severe", "desc": "Disk has run out of space"}}
3580
-
```
3581
-
3582
-
The example above would send a notification with a title "philipp-pc: A severe error has occurred" and a message "Error message: Disk has run out of space".
3583
-
3584
-
For Grafana webhooks, you might find it helpful to use the headers `X-Title: Grafana alert: ${title}` and `X-Message: ${message}`.
3585
-
Alternatively, you can include the params in the webhook URL. For example, by
3586
-
appending `?template=yes&title=Grafana alert: ${title}&message=${message}` to the URL.
3587
-
3588
3591
## Public topics
3589
3592
Obviously all topics on ntfy.sh are public, but there are a few designated topics that are used in examples, and topics
3590
3593
that you can use to try out what [authentication and access control](#authentication) looks like.
0 commit comments