Examples
Replace YOUR_KEY with the key from Settings in the app.
curl
curl -H 'X-ZapaPush-Key: YOUR_KEY' -d 'Disk full on db-1' https://api.zapapush.com/send
With a description, from a file or a command's output:
df -h / | curl -H 'X-ZapaPush-Key: YOUR_KEY' --data-binary @- https://api.zapapush.com/send
Here the first line of df's output becomes the subject. To set your own, put it first:
{ echo "Disk report for $(hostname)"; df -h /; } |
curl -H 'X-ZapaPush-Key: YOUR_KEY' --data-binary @- https://api.zapapush.com/send
Shell: alert when a command fails
#!/bin/sh
# Usage: alert-on-fail.sh <command...>
if ! output=$("$@" 2>&1); then
printf '%s\n%s\n' "Failed on $(hostname): $*" "$output" |
curl -s -H "X-ZapaPush-Key: $ZAPAPUSH_KEY" --data-binary @- https://api.zapapush.com/send
fi
In cron:
0 3 * * * ZAPAPUSH_KEY=YOUR_KEY /usr/local/bin/alert-on-fail.sh /usr/local/bin/backup.sh
Python
Standard library only. Set a User-Agent: Python's default one is often blocked by firewalls.
import urllib.request
def zapapush(subject, description=""):
urllib.request.urlopen(urllib.request.Request(
"https://api.zapapush.com/send",
data=f"{subject}\n{description}".encode(),
headers={"X-ZapaPush-Key": "YOUR_KEY", "User-Agent": "my-script"},
), timeout=10)
zapapush("Disk full on db-1", "/var is 95% used")
With requests:
import requests
requests.post("https://api.zapapush.com/send",
headers={"X-ZapaPush-Key": "YOUR_KEY"},
json={"subject": "Disk full on db-1", "description": "/var is 95% used"},
timeout=10)
Home Assistant
Add a REST command to configuration.yaml, then restart Home Assistant:
rest_command:
zapapush:
url: https://api.zapapush.com/send
method: post
headers:
X-ZapaPush-Key: YOUR_KEY
content_type: application/json
payload: >-
{{ {"subject": subject, "description": description | default("")} | to_json }}
Use it as an action in any automation:
action: rest_command.zapapush
data:
subject: "Front door open"
description: "Opened at {{ now().strftime('%H:%M') }}"
Node.js
await fetch("https://api.zapapush.com/send", {
method: "POST",
headers: { "X-ZapaPush-Key": "YOUR_KEY" },
body: "Disk full on db-1\n/var is 95% used",
});
PowerShell
Invoke-RestMethod -Method Post -Uri https://api.zapapush.com/send `
-Headers @{ "X-ZapaPush-Key" = "YOUR_KEY" } -Body "Disk full on db-1"
Tools without headers
Anything that can call a URL (uptime monitors, routers, NAS boxes) can use the key in the path:
https://api.zapapush.com/send/YOUR_KEY?m=NAS+degraded
That URL contains your key, so keep it out of places others can read.