Phone alerts from scripts, cron jobs and CI
Every anypush channel has a URL. A script, a cron job, a CI run or a smart home sends it an HTTP POST, and your Android phone gets the alert. If a job stops calling, an overdue alert tells you that too.
One URL. Any language.
Send it a POST
- Send
- POST text, or JSON with title, message, priority and url. Or use the headers X-Title, X-Priority and X-Url.
- Answer
- 202 with the message id: anypush saved the message and is sending it to your phones.
- Retry
- An Idempotency-Key makes a retry within 24 hours count once.
- Limits
- Up to 64 KiB a message, 60 a minute per channel.
export ANYPUSH_URL=https://api.anypush.app/h/your-token
curl -H 'X-Title: Deploy finished' \
-H 'X-Priority: high' \
-H 'X-Url: https://ci.example.com/run/42' \
-d 'web@4f2a91c is live' \
"$ANYPUSH_URL" HTTP/2 202 {"duplicate":false,"id":1042}
- name: Notify on failure
if: failure()
run: |
curl -sS -H "X-Priority: high" \
-H "X-Url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
-d "${{ github.workflow }} failed on ${{ github.ref_name }}" \
${{ secrets.ANYPUSH_URL }} import json, os, urllib.request
def notify(message, title="", priority="normal"):
req = urllib.request.Request(
os.environ["ANYPUSH_URL"],
data=json.dumps({"message": message, "title": title,
"priority": priority}).encode(),
headers={"Content-Type": "application/json"},
)
urllib.request.urlopen(req, timeout=10)
notify("Training finished: loss 0.031", title="gpu-box") The app fills in your own URL in recipes for cron, GitHub Actions, Home Assistant, Python, PowerShell, iPhone Shortcuts, Zapier, IFTTT and Make.
When a job goes quiet
The run that never happens reaches you too.
Give the channel an overdue alert: the longest silence you allow, from 1 hour on Free or 5 minutes on Plus, up to 31 days. Let the job send a message after every good run. If nothing arrives in time, you get one alert, about a minute after the silence runs out. The next message clears it.
# crontab, with an overdue alert of 1 day on the channel
ANYPUSH_URL=https://api.anypush.app/h/your-token
0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 -H 'X-Priority: low' -d 'backup ok' "$ANYPUSH_URL" # configuration.yaml
rest_command:
anypush:
url: !secret anypush_url
method: POST
content_type: application/json
payload: '{"title": "{{ title }}", "message": "{{ message }}"}' Questions
Is the URL a secret?
Yes. Anyone with it can send to the channel, so keep it out of public code, repositories and logs: put it in an environment variable or your CI's secrets. If it leaks, delete the channel and make a new one, and the old URL stops working at once.
What does the 202 answer mean?
That anypush accepted and saved the message and is sending it to your phones. It does not prove that a phone showed it. The message waits in the app's inbox either way, for 7 days (30 on Plus).
How late can an overdue alert be?
About a minute. anypush looks at every channel's deadline each minute, on both plans. The plan only sets how short the allowed silence can be.
Can quiet hours hold back an alert?
Quiet hours make ordinary messages arrive silently. A message sent with priority high, and every overdue alert, still comes through.
Should this be my only monitoring?
For anything critical, no. Alerts are best effort, and a phone can delay or silence them. Use anypush beside your other monitoring, not instead of it.
Also with anypush: emails that arrive as phone alerts, a QR doorbell, and how anypush compares with Pushover, ntfy and Healthchecks.io.
Get anypush
Free to start, no ads. Android 7 and up.