Send phone notifications from CI, cron, or a shell script
POST a text message with curl to the pushbag ping endpoint. A Notifications key in the Authorization header sends the message to its owner’s personal channel.
Prepare credentials for a background process
On your workstation, install the CLI with npm install -g @pushbag/cli. Run pushbag auth login, visit the printed key page, and create a Notifications key. Save it with pushbag auth set YOUR_KEY for local testing. Supply the value separately through the runner’s secret store. Cron may start with a different home directory and a much smaller environment than the shell you use to test a script.
Install the Android app on Google Play or the iPhone app and sign in as the owner of Personal. A successful command-line test prints Sent to CHANNEL_ID (MESSAGE_ID); the actual IDs identify the destination and message. Compare the test title in the dashboard with the alert on the phone. This helps distinguish a failed publish from a phone with notifications disabled.
Send one message from the runner
Set PUSHBAG_API_KEY from your CI secret store or cron environment. Give the key permission to publish to your personal channel.
curl --fail-with-body --silent --show-error https://ping.pushbag.dev/ \
-H "Authorization: Bearer $PUSHBAG_API_KEY" \
-H 'Content-Type: text/plain' \
--data-binary 'Nightly backup finished'
A successful POST returns HTTP 202. Its JSON body has this shape, with the identifiers supplied by the server:
{"id":"MESSAGE_ID","channelId":"CHANNEL_ID","receipt":"RECEIPT"}
Log the receipt with the backup run ID. If the server accepted the message but nobody saw an alert, inspect that channel in the dashboard before running the backup again. A 202 confirms that the server stored the message and the pending delivery, not that the phone displayed it.
Place the call after the backup exits successfully. To report a failure, send a different message on the error path and preserve the job’s original exit status.
Check the same destination locally
With the CLI installed, use the same key and send a message before wiring up the schedule.
pushbag notify "Runner delivery test" --title "Nightly backup"
For a shared channel, post to https://ping.pushbag.dev/CHANNEL_ID with the channel ID and a key allowed to publish there.
Preserve the backup result
A failed backup followed by a successful notification can make a shell script exit successfully by mistake. Capture the status before formatting the message. In this example, supply the path to your backup program as the first argument and a unique backup run ID as the second. Persist that ID if your scheduler retries delivery of the same result.
backup_status=0
"$1" || backup_status=$?
curl --fail-with-body --silent --show-error https://ping.pushbag.dev/ \
-H "Authorization: Bearer $PUSHBAG_API_KEY" \
-H "Idempotency-Key: backup-$2-result" \
-H 'Content-Type: text/plain' \
--data-binary "Backup $2 finished with exit status $backup_status" ||
printf '%s\n' 'Could not publish backup result' >&2
exit "$backup_status"
Use a run ID you can find again in the backup logs. For a job with separate start and finish messages, give each event its own key. Changing the payload and reusing the original key is refused. If the endpoint rejects a publish, check whether the key permits the requested destination before retrying.
Include a destination or a file
To take the operator directly to a log, send a JSON object with a message and a click URL. For a text-only job the body can stay as short as the first example. Raise priority when the next step is time-sensitive. A CLI sender that reports --payload must contain a JSON object. has received a list or scalar instead. Put the message, click URL and priority inside one object.
A job that generates a detailed recovery report can upload it using a Both key. Pass --private --notify for the owner’s copy and keep the returned version link beside the run ID. An alert to a named channel can reference the file, but reading the channel alone does not grant access to a private report.
Frequently asked questions
Do I need Node.js on the runner?
No. The ping endpoint accepts HTTP requests directly. Use curl on the runner and the CLI only where you want it.
What happens if a scheduled run retries the POST?
Send a stable Idempotency-Key header for the same event and payload. Use a different key for a different outcome or a new run.
Can cron publish without my terminal profile?
Yes. Give the scheduled process its own environment variable with the key value. The HTTP request reads that variable directly.
How do I open the failed build from my phone?
Set click in the JSON body to the full run URL. The phone opens that destination, where the build provider still enforces its own sign-in.