skirl

Any webhook

A tool that posts JSON to an address you give it, and has no ntfy option and no steps of its own here, can send to Skirl's Any webhook address. Its template, generic, reads the title, the text, the priority and the link from the field names tools usually use, so the message reads well with nothing written. When it does not, Listen for a real message builds a template for the tool by clicking.

Setting it up#

In the app these steps are under Connect a system → Any webhook, or a topic's Send to this topic tab, with the address, topic and a token filled in; New token makes the token.

Any tool that posts JSON: the generic template finds the title, the text, the priority and the link among the usual field names, so it reads as a message with no template written. Send the token as a Bearer header, or add &auth= as in the Slack-compatible URL when the tool cannot send headers.

  • URL: https://notify.example.com/webhooks?template=generic
  • Header name: Authorization
  • Header value: Bearer tk_replace_with_your_token

The address here shows example values (https://notify.example.com, the topic webhooks, tk_replace_with_your_token): copy it from the app, where yours are filled in.

  • Give the tool the URL, and the token as a header: Authorization with the value Bearer and the token.
  • A tool that cannot send a header can carry the token in the address instead, with &auth= as in the Slack-compatible address (Slack-compatible webhooks). Then treat the whole address as a secret.
  • The address names the template after ?template=. The template also answers to the name auto, which always means generic, this server's own copy of it too. Under the address, the app lists the other templates this server has; an admin can write one in Admin → Templates (Templates).

To try it from any machine:

curl -fsS -H "Authorization: Bearer tk_replace_with_your_token" -H "Content-Type: application/json" -d '{"title":"Backup done","message":"14 VMs, no errors.","severity":"info","url":"https://nas.example.com/backups/1"}' "https://notify.example.com/webhooks?template=generic"

It arrives titled "Backup done", with the text "14 VMs, no errors.", at priority 2, and tapping it opens the address in url.

What a message looks like#

Healthchecks.io's webhook when a check goes down, as Healthchecks.io documents it:

Database Backup
Runs ~/db-backup.sh

Priority 4 · Tags: warning

When the check is up again, the same message is replaced, at priority 2 with the tag white_check_mark (✅).

Docker Hub's webhook for an image push (Docker Hub's own example) has no field with a text, so the message lists the fields it has:

exampleuser/testhook
push_data.pushed_at: 1417566161
push_data.pusher: trustedbuilder
push_data.tag: latest
repository.comment_count: 0
repository.date_created: 1417494799
repository.full_description: Docker Hub based automated build from a GitHub repo
repository.is_official: false
repository.is_private: true
repository.is_trusted: true
repository.name: testhook
repository.namespace: exampleuser
repository.owner: exampleuser
…and 2 more

Priority 3

Skirl's tests run the generic template on the webhooks of 17 tools, among them Uptime Kuma, Sonarr, Proxmox VE, TrueNAS, Zabbix, Sentry, Netdata, Tailscale, Gatus and Watchtower.

What it looks for#

Where it looks#

It reads the fields at the top of the JSON, then inside these fields one level down, and inside those again: data, event, alert, payload, attributes, object_attributes, issue, monitor, check, incident, notification, object, push_data, repository. Field names match whatever their capitals (Title, title, TITLE).

For each part it tries the names below in the order given. Each name is looked for at the top first, then one level down, then two; the first that holds something wins. So a better name further down wins over a worse one at the top.

The title#

title, subject, summary, alertname, alert_name, description_title, full_name, repo_name, name, alert, host, event, eventType, event_type, type, action.

It must be text or a number, and not a word that names a format (mrkdwn, markdown, plain_text, plain, text, html, json). It is made one line, and shortened to 250 characters.

The text#

message, text, body, description, description_text, content, msg, details, reason, output, log, desc: text or a number, and not the field the title came from. A text wrapped whole in a code fence (three backticks before and after, as some Slack-style tools send it) loses the fence.

When no field holds a text, the message lists the plain values it has, one a line as name: value: those inside the fields above first, deepest first, then the top level. It leaves out the title's field, addresses, empty values and values of several lines, shortens each value to 200 characters, and stops after 12 lines with "…and 3 more" (how many it left out).

The message is at most 4,096 bytes: a longer text is cut and ends with "…".

The priority and the tag#

priority, severity, level, status, state, urgency, action, in that order: the first that says something it knows sets the priority.

  • A number from 1 to 5 is that priority, in any of these but status and state (a status of 0 or 1 means down or up, not a priority).
  • A word, whatever its capitals:
Priority Words
5 critical, crit, fatal, emergency, emerg, panic, disaster, urgent
4 error, err, failed, failure, fail, down, high, major, firing, problem, alerting, unhealthy, unreachable
3 warning, warn, degraded, average, medium, moderate
2 info, information, informational, notice, low, minor, ok, resolved, up, success, succeeded, successful, recovered, passed, healthy, clear, cleared
1 debug, trace
  • When the name of what happened says it is over, the priority is 2 whatever the level says: a word resolved, recovered, restored or cleared in eventType, event_type, event, type, action, alert_event or notification_type (Sonarr's HealthRestored, ALERT_RESOLVED).

The tag is ✅ (white_check_mark) when the priority's word, or else the word in a status, state or action field, is one of ok, resolved, up, success, succeeded, successful, recovered, passed, healthy, clear or cleared (or the name of what happened says it is over), and ⚠️ (warning) when it is one of critical, crit, fatal, emergency, emerg, panic, disaster, error, err, failed, failure, fail, down, firing, problem, alerting, warning, warn, degraded, unhealthy or unreachable. Other words give no tag.

url, link, html_url, href, web_url, permalink, dashboardURL, panelURL, generatorURL, uri, absolute_url, alert_url, repo_url: only an address that starts with http:// or https:// and has no spaces. Tapping the message opens it.

A recovery replacing its alert#

When the JSON has exactly one id (one value among id, uuid, alert_id, alertId, incident_id, incidentId, monitor_id, monitorID, check_id, fingerprint, groupKey) and exactly one state that fires and recovers (status, state or action saying firing, resolved, down, up, problem, ok, recovered, alerting or triggered), the message gets a sequence id made from that id. The recovery then replaces the alert instead of arriving as a second message. With no id, two ids or two states, each arrives on its own.

A list, a form, or text#

  • A list at the top: its first five items in one message, one a line ("• title — text"), then how many more ("…and 2 more"); the title is the first item's with how many there are ("· 7 items"); the priority is the highest, the link the first one found. A list of one is read as that one item.
  • A form (application/x-www-form-urlencoded, as Home Assistant's REST notify sends): its fields, read as above. A field that holds JSON is read as that JSON. A body with no content type that looks like name=value&… is read as a form too.
  • Anything else is the message itself: its text, as it is. Send plain text as text/plain. Text labelled as a form (curl's -d does that) is read as form fields, so a text with no = in it arrives as "Fields: " and the text.

When it finds nothing#

  • An empty object, {}: "An empty message."
  • An empty list, []: "An empty list."
  • An empty body, or null: "triggered", as for any message with no text.
  • Only a title ({"name": "Nightly backup"}): the title becomes the text, with no title.
  • No text and no plain values, only nested ones: "Fields: " and the top-level names, such as "Fields: a, d".
  • No priority it knows: the default, 3. No link, no tag, no sequence id: none.

What the tool sends besides the body#

What the tool states outright wins over what the template works out. A title, priority, tags, link, text or sequence id sent as a header or in the address, by the names any message takes (Title, priority and tags), is used as sent:

Part Header In the address
Title X-Title, Title title=, t=
Priority X-Priority, Priority priority=, prio=, p=
Tags X-Tags, Tags, Tag tags=, tag=, ta=
Link X-Click, Click click=
Text X-Message, Message message=, m=
Sequence id X-Sequence-ID, Sequence-ID, SID sequence-id=, sid=

The template works out only the parts the tool leaves out. Tags the tool sends take the place of the template's tag. For example, ?template=generic&p=2&title=Backup makes the message titled "Backup" at priority 2, whatever the body says.

This is the generic template's way, and that of a template's parts left to auto (Templates). Any other template sets its own title, text and priority over the tool's, as in ntfy; see What a template can set.

When nothing arrives#

  1. Send a test from the tool, and look at what Skirl answered in the tool's log.
  2. 401 or 403. The Authorization header is missing or wrong (401: a wrong, rotated or revoked token; 403: a token for another topic, or none for a private topic).
  3. 400, "template file not found". The name after ?template= is not a template this server has.
  4. The message arrives but reads badly. Listen for a real message catches what the tool sends and builds a template by clicking.
  5. There is no answer at all: A sender gets no message through.

This page on GitHub