The native API (/api/v1)
The web app talks to Skirl through /api/v1, and so can you. Scripts that only
publish and subscribe should use the ntfy-compatible routes instead (POST /<topic>, GET /<topic>/json and the rest, in
ntfy-compat.md): they take tokens and work with every ntfy
client. /api/v1 is for what ntfy has no API for: the inbox and its read
state, devices, deliveries, and running the server.
The route table below is generated from the code: a test fails if a route is added, removed or changes who may call it without this page changing too.
Signing in#
- Session:
POST /api/v1/auth/loginwith{"username": "…", "password": "…"}sets anHttpOnlycookie:__Host-skirl_sessionover HTTPS (with theSecureflag),skirl_sessionover plain HTTP. Every request after that sends it back.POST /api/v1/auth/logoutends the session. - Token:
Authorization: Bearer tk_…(a token from Settings → Access tokens orskirl token create) is accepted only by the routes marked "signed in" below:GET /api/v1/auth/me,GET /api/v1/topics,GET /api/v1/topics/{name},GET /api/v1/topics/{name}/scheduledandGET /api/v1/templates. Everything else needs a session, however wide the token's rights: managing accounts is a browser's job, and a leaked script token cannot change them. - Cross-origin requests are refused on every route that changes something
(403, code 40390): a page on another site cannot act with your cookie.
/api/v1sends no CORS headers. Clients that are not browsers are not affected.
Requests and answers#
JSON in, JSON out (Content-Type: application/json). Unknown fields in a
request body are an error rather than ignored, so a typo does not pass
silently. Times are Unix seconds. Lists that can grow (the inbox, the delivery
log) come in pages: the answer's next is the cursor for the following page,
empty at the end.
Errors#
Every error has ntfy's shape, with the HTTP status repeated:
{"code": 40301, "http": 403, "error": "forbidden", "link": "https://ntfy.sh/docs/publish/"}| Status | When |
|---|---|
| 400 | The request is malformed: a field missing or out of range (error says which) |
| 401 | Not signed in, or the session or token is not valid (code 40101) |
| 403 | Signed in, but not allowed: not an admin, no access to the topic, a token where a session is needed, a cross-origin request |
| 404 | No such user, topic, token, message or device, or one you may not see (code 40401) |
| 409 | It already exists, or a limit is reached: a taken name, the 100-token limit (40992) |
| 413 | The body is too large |
| 429 | A rate limit: Retry-After says how many seconds to wait |
Objects#
User (GET /api/v1/auth/me, GET /api/v1/users/{id})
{"id": 1, "username": "ann", "display_name": "Ann", "role": "admin", "can_create_topics": true,
"created_at": 1795660000, "disabled": false}Topic (GET /api/v1/topics, GET /api/v1/topics/{name}): yours, with your
access and inbox state.
{"name": "backups", "display_name": "Backups", "visibility": "private", "retention_days": 30,
"created_at": 1795660000, "created_by": "ann", "can_read": true, "can_publish": true,
"subscribed": true, "unread": 2, "unread_urgent": 0, "last_message_time": 1795669999,
"muted_until": 0, "min_priority": 1, "can_manage": true}visibility is private, public_read, public_write or public.
muted_until is 0 (not muted), a Unix time, or 253402300799 (until switched
back on).
Message (GET /api/v1/messages, GET /api/v1/messages/{id}): ntfy's
message, plus seq (the inbox's order and cursor), read, and updates
(how many earlier versions an updated message has).
{"id": "hL8eRu7zKp2Q", "time": 1795669999, "expires": 1798261999, "event": "message",
"topic": "backups", "title": "Nightly backup finished", "message": "pve-01 → offsite. 14 VMs, no errors.",
"priority": 3, "tags": ["white_check_mark"], "sequence_id": "hL8eRu7zKp2Q",
"seq": 4127, "read": false, "updates": 0}Optional fields as in ntfy: click, icon, actions (buttons:
{"action": "view", "label": "Open", "url": "…"}), attachment ({"name", "type", "size", "expires", "url"}), content_type (text/markdown).
GET /api/v1/messages takes topic (one topic instead of the whole inbox),
unread=1, min_priority (1 to 5), q (search words: title, message and
tags; the last word may be a prefix), limit (1 to 100) and before (a seq
cursor). It answers {"messages": […], "next": "…"}.
Token (GET /api/v1/tokens): masked. The secret is token, present only
in the answer to POST /api/v1/tokens and POST /api/v1/tokens/{id}/rotate.
{"id": 7, "user": "ann", "name": "publish backups", "prefix": "tk_••••••••4f2a", "topic": "backups",
"can_read": false, "can_publish": true, "created_at": 1795660000}Create one with {"name": "…", "topic": "backups", "can_read": false, "can_publish": true, "expires_in": "30d"} (topic and expires_in
optional).
Device (GET /api/v1/devices): a browser that receives pushes. Its push
endpoint is never sent back.
{"id": 3, "label": "Pixel 9", "platform": "android", "installed": true, "origin": "https://notify.example.com",
"state": "receiving", "created_at": 1795660000, "last_seen_at": 1795669000, "last_received_at": 1795669999,
"endpoint_hash": "…"}state is receiving, waiting or failing, with state_reason in plain
words when it is not receiving.
Delivery (GET /api/v1/messages/{id}/deliveries): one per device.
{"id": 9912, "device_id": 3, "device_label": "Pixel 9", "status": "received", "attempts": 1,
"created_at": 1795669999, "sent_at": 1795669999, "received_at": 1795670000}status is queued, sent, received, skipped or failed; reason says
why for the last two (muted, quiet hours, below the topic's priority, the
subscription gone).
Events (GET /api/v1/events): server-sent events for the signed-in user:
hello first, then message (a new or updated message), read (read state
changed, here or in another tab), topics (the topic list changed),
message_clear and message_delete, each with its object as data; and
changed, {"what": "tokens"} (with "topic" for a topic's own lists), which
says that something shown elsewhere changed, never what: people, tokens,
devices, deliveries, topics, access, scheduled, messages,
templates, settings, quiet or diagnostics. Admin-only changes reach
admins' streams only, a topic's only streams that may read it
(internal/api/live.go). The web app keeps one open per tab.
Diagnostics (GET /api/v1/admin/diagnostics): {"last": <run or null>, "running": bool}. Asking for a run older than five minutes starts a new one in
the background (running: true); its end is a changed event,
diagnostics. The checks also run by themselves after the start, every 30
minutes, and after the address or the proxy settings change.
Compression: the web app's files go out brotli- or gzip-compressed by
Accept-Encoding. Of /api/v1, only answers without message text or
secrets are gzipped (over 1 KB): the topic, people, device and template lists
and the admin figures (internal/api/compress.go says why no others).
Routes#
| Method | Path | Who | |
|---|---|---|---|
| GET | /api/v1/setup/state |
anyone | Whether an admin exists, a setup token is needed, and setup is finished |
| POST | /api/v1/setup/admin |
anyone | Create the first admin (only while there is none); signs them in |
| GET | /api/v1/setup/probe |
admin session | What the server sees of this request (address, scheme, forwarded headers), for the connection test |
| GET | /api/v1/setup/sse |
admin session | A test event stream, for the connection test |
| GET | /api/v1/setup/ws |
admin session | A test WebSocket, for the connection test |
| PUT | /api/v1/setup/address |
admin session | Store the public address |
| PUT | /api/v1/setup/proxy |
admin session | Turn reverse-proxy mode on or off and set the trusted proxies |
| POST | /api/v1/setup/skip |
admin session | Record a check the admin continues without |
| POST | /api/v1/setup/complete |
admin session | Mark setup as finished |
| GET | /api/v1/setup/qr.svg |
admin session | A QR code of the public address, to open on a phone |
| POST | /api/v1/auth/login |
anyone | Sign in with a user name and password; sets the session cookie |
| POST | /api/v1/auth/logout |
anyone | Sign out; clears the session cookie |
| GET | /api/v1/auth/me |
signed in (session or token) | The signed-in user |
| POST | /api/v1/auth/password |
session | Change your password (the current one is required); other sessions end |
| GET | /api/v1/users |
admin session | List people |
| POST | /api/v1/users |
admin session | Add a person |
| GET | /api/v1/users/{id} |
admin session | One person |
| PATCH | /api/v1/users/{id} |
admin session | Change a person: display name, role, password, may create topics, disabled |
| DELETE | /api/v1/users/{id} |
admin session | Delete a person, with their tokens, sessions and devices |
| POST | /api/v1/users/{id}/sessions/revoke |
admin session | Sign a person out everywhere |
| GET | /api/v1/topics |
signed in (session or token) | The topics you may read or publish to, with your access |
| POST | /api/v1/topics |
session | Create a topic |
| GET | /api/v1/topics/{name} |
signed in (session or token) | One topic |
| PATCH | /api/v1/topics/{name} |
session | Change a topic: display name, visibility, retention |
| DELETE | /api/v1/topics/{name} |
session | Delete a topic and its messages |
| GET | /api/v1/topics/{name}/access |
session | Who may read and publish to a topic |
| GET | /api/v1/topics/{name}/scheduled |
signed in (session or token) | Messages waiting for their time |
| DELETE | /api/v1/topics/{name}/scheduled/{id} |
session | Cancel a scheduled message |
| PUT | /api/v1/topics/{name}/access/{username} |
session | Give a person access to a topic |
| DELETE | /api/v1/topics/{name}/access/{username} |
session | Take a person's access away |
| PUT | /api/v1/topics/{name}/subscription |
session | Put a topic in your inbox |
| DELETE | /api/v1/topics/{name}/subscription |
session | Take a topic out of your inbox |
| GET | /api/v1/tokens |
session | Your tokens (masked) |
| POST | /api/v1/tokens |
session | Create a token; the secret is in this answer only |
| PATCH | /api/v1/tokens/{id} |
session | Rename a token |
| DELETE | /api/v1/tokens/{id} |
session | Revoke a token |
| POST | /api/v1/tokens/{id}/rotate |
session | Replace a token's secret; the new one is in this answer only |
| GET | /api/v1/admin/tokens |
admin session | Everyone's tokens (masked) |
| DELETE | /api/v1/admin/tokens/{id} |
admin session | Revoke anyone's token |
| GET | /api/v1/messages |
session | Your inbox: messages of your subscribed topics, newest first, with filters and a cursor |
| POST | /api/v1/messages |
session | Publish from the web app |
| POST | /api/v1/messages/read-all |
session | Mark everything read, in one topic or in all of yours |
| GET | /api/v1/messages/{id} |
session | One message |
| GET | /api/v1/messages/{id}/versions |
session | The earlier versions of a message that was updated |
| POST | /api/v1/messages/{id}/read |
session | Mark a message read |
| POST | /api/v1/messages/{id}/unread |
session | Mark a message unread |
| DELETE | /api/v1/messages/{id} |
session | Delete a message, every version, for everyone: as DELETE /{topic}/{sequence id}, with the right to publish |
| POST | /api/v1/messages/existing |
session | Which of the given message ids (at most 100) are still there for you: the app closes the notifications of the others |
| GET | /api/v1/events |
session | A server-sent event stream of your inbox: new messages, read state, updates and deletions |
| GET | /api/v1/push/key |
session | The server's web push (VAPID) public key |
| GET | /api/v1/push/quiet-hours |
session | Your quiet hours |
| PUT | /api/v1/push/quiet-hours |
session | Set your quiet hours |
| GET | /api/v1/devices |
session | Your devices |
| POST | /api/v1/devices |
session | Register this browser's push subscription |
| PATCH | /api/v1/devices/{id} |
session | Rename a device |
| DELETE | /api/v1/devices/{id} |
session | Remove a device |
| POST | /api/v1/devices/{id}/test |
session | Send a test notification to a device |
| GET | /api/v1/messages/{id}/deliveries |
session | Which of your devices got a message, and when or why not |
| GET | /api/v1/deliveries/{id} |
session | One delivery, for its device's owner or an admin |
| PATCH | /api/v1/topics/{name}/subscription |
session | Mute a topic, or notify only from a priority |
| GET | /api/v1/topics/{name}/capture |
session | What the topic caught while listening for a real message (its managers) |
| POST | /api/v1/topics/{name}/capture |
session | Listen for a real message for 15 minutes |
| DELETE | /api/v1/topics/{name}/capture |
session | Stop listening and forget what was caught |
| POST | /api/v1/topics/{name}/capture/preview |
session | A template rendered against a body, for the topic's managers |
| POST | /api/v1/receipts/{token} |
anyone | A device confirms a push arrived (the one-time token comes inside the push); the body may name its service worker's build |
| POST | /api/v1/receipts/{token}/failure |
anyone | A device's service worker reports a step of its push handler that failed: the step, the error's name and a short message |
| POST | /api/v1/clients/seen |
session | This browser reports its platform and push state, for Diagnostics |
| POST | /api/v1/admin/diagnostics/run |
admin session | Run the diagnostics now |
| GET | /api/v1/admin/diagnostics |
admin session | The last diagnostics run |
| GET | /api/v1/admin/devices |
admin session | Every device, with its state |
| POST | /api/v1/admin/devices/{id}/test |
admin session | Send a test notification to anyone's device |
| GET | /api/v1/admin/deliveries/recent |
admin session | The latest deliveries, for the overview |
| GET | /api/v1/admin/deliveries |
admin session | The delivery log, with filters |
| GET | /api/v1/admin/overview |
admin session | Counts and problems for the admin overview, and how many people are signed in |
| GET | /api/v1/admin/topics |
admin session | Every topic, with message and subscriber counts |
| GET | /api/v1/templates |
signed in (session or token) | Template names and their events, for "Send to this topic" |
| GET | /api/v1/admin/templates |
admin session | Every template, built-in and custom, with its parts, and those the upgrade renamed |
| POST | /api/v1/admin/templates/preview |
admin session | Render a template against a sample (30 a minute) |
| PUT | /api/v1/admin/templates/{name} |
admin session | Create or replace a custom template |
| DELETE | /api/v1/admin/templates/{name} |
admin session | Delete a custom template (a built-in of that name comes back) |
| POST | /api/v1/admin/templates/renamed/dismiss |
admin session | Take the note of the templates the upgrade renamed away, for every admin |
| GET | /api/v1/admin/settings |
admin session | The server's settings |
| PATCH | /api/v1/admin/settings |
admin session | Change settings |