Push
Open push setupNotifications arrive in the browser that subscribed, even when the tab is closed. The subscription id is the only secret needed to send to it.
Get a subscription
- Open the push page in the browser or device that should receive notifications.
- Allow notifications. A service worker is registered and the browser is subscribed.
- Copy the subscription id and one of the
curlcommands shown there.
Send a notification
curl -X POST https://tools.worotyns.ovh/push/send \
-H "content-type: application/json" \
-d '{"subscription": "SUBSCRIPTION_ID", "title": "Service is down", "message": "Check servers", "url": "https://example.com"}'
Plain text is simpler: the request body becomes the message. title and url are optional query parameters.
curl -d "Backup finished" "https://tools.worotyns.ovh/push/send/SUBSCRIPTION_ID?title=NAS&url=https://nas.local"
# GET works too, for simple webhooks
curl "https://tools.worotyns.ovh/push/send/SUBSCRIPTION_ID?message=Done&title=Build"
# with an icon
curl -d "Backup finished" "https://tools.worotyns.ovh/push/send/SUBSCRIPTION_ID?title=NAS&icon=https%3A%2F%2Fexample.com%2Ficon.png"
Optional fields
| Field | Where | Meaning |
|---|---|---|
url | JSON, ?url= | Opened when the notification is clicked. |
icon | JSON, ?icon= | Small icon next to the text; HTTPS URL or same-origin path. |
badge | JSON, ?badge= | Monochrome icon for the Android status bar. |
image | JSON, ?image= | Large image below the text (Chrome, Android). |
Icons must be reachable over HTTPS from the device. Without icon, the tools icon is used.
API
| Method | Path | Purpose |
|---|---|---|
GET | /push/vapid | Public VAPID key as JSON. |
POST | /push/subscription | Register a browser PushSubscription; returns {"success":true,"subscription":"ID"}. |
GET | /push/subscription | Find an id by ?endpoint=.... |
POST | /push/subscription/change | Rotate the endpoint, keeping the id. |
DELETE | /push/subscription | Remove by {"endpoint":"..."}. |
POST | /push/send | Send a JSON notification. |
POST and GET | /push/send/{id} | Send a text notification. |
Status codes
| Code | Meaning |
|---|---|
200 | Sent. |
404 | Unknown subscription. |
410 | Subscription expired; it is deleted automatically. |
413 | Message too large (plaintext max ~3000 bytes). |
502 | The push service rejected the message. |
The browser UI lives under /push/, so its service worker scope is /push/. Subscription rotation is handled by web/push/sw.js, so ids survive browser restarts. Push requires HTTPS.