Payload templates
The JSON template is the request body. Write any JSON shape and fill it with {{placeholders}}.
Every rule has a JSON template. When a notification matches, each {{placeholder}} is replaced with its value and the result is sent as the request body. The template is the payload: what you write is exactly what your server receives.
The default template#
New rules start with seven core fields:
{
"rule": "{{ruleName}}",
"package": "{{packageName}}",
"app": "{{appName}}",
"title": "{{title}}",
"text": "{{text}}",
"timestamp": "{{timestamp}}",
"notificationKey": "{{notificationKey}}"
}The Include in payload chips above the editor edit the default top-level JSON keys. Turning one off removes its key, and turning it on inserts its default placeholder; this can reformat the object. They don't rewrite renamed or nested fields, and leave the template unchanged if it can't be parsed as a JSON object. Edit custom shapes directly.
Placeholder syntax#
- Write
{{name}}. Spaces inside the braces are allowed:{{ title }}works too. - Names are case-sensitive and use letters, digits,
_and., for example{{battery.level}}. - The full list is on the Variables page. In the app, tap Insert variable… to pick one.
- Use
{{secrets.NAME}}to insert a value from the secrets vault.
Values are JSON-escaped, not quoted#
Every value is escaped so it is safe inside a JSON string: quotes become \", newlines become \n, and so on. NotifyHook does not add the surrounding quotes. You decide whether a value is a string or a raw number or boolean:
{
"title": "{{title}}",
"receivedAtMs": {{time.epochMs}},
"battery": {{battery.level}},
"charging": {{battery.charging}}
}{
"title": "Alex: \"see you at 8\"",
"receivedAtMs": 1794818467512,
"battery": 84,
"charging": false
}If a value is missing, an unquoted placeholder renders as nothing and the body becomes invalid JSON, like "battery": ,. This happens with unknown names, variables the phone can't provide, and Pro variables on the free tier. Quote the placeholder ("{{battery.level}}") if it might be empty, and convert the type on your server.
Missing and unknown values#
- Unknown names using valid placeholder syntax, such as
{{titlle}}, render as an empty string. Unsupported syntax, such as{{text | lower}}, is left literally in the output. - A notification without a title or text gives an empty string for that field.
- Pro-only variables render as an empty string on the free tier.
- The app doesn't check that your template is valid JSON. Use Test webhook to check it against your endpoint.
Shaping for a service#
Because the template is free-form, you can match whatever JSON an API expects. You can nest objects, rename keys, add constants and build strings:
{
"source": "android",
"event": {
"id": "{{event.uuid}}",
"at": "{{time.iso}}"
},
"message": "[{{appName}}] {{title}}: {{text}}",
"device": "{{device.model}}"
}For ready-made examples, see the recipes for Discord, Slack and ntfy.
Full message or collapsed preview#
{{text}} uses the newest MessagingStyle message if available, otherwise expanded big text, otherwise the collapsed preview. {{textPreview}} always uses the source app's collapsed preview. Neither can recover content the source app or Android withholds. For the shorter form, change the default text field to:
{
"title": "{{title}}",
"text": "{{textPreview}}"
}Template limits#
Templates substitute values; they aren't a scripting language. There are no conditions, loops, default-value expressions, substring operations, automatic truncation or base64 conversion. Do those on your receiver. There are no attachment/image placeholders or multipart uploads. JSON escaping does not escape a chat service's Markdown or mentions; use the service's controls or sanitize on your receiver.
Templates and retries#
The body is rendered once, when the notification arrives. Retries resend the same body, so {{time.*}} and {{event.uuid}} keep their original values. Secrets are the exception: they are read again at send time. Editing a template affects new notifications only. See Delivery & retries.