Subscribe with the API
Your programs can receive a topic's messages over HTTP or WebSocket. To publish, see Publish.
JSON stream
curl -s https://usenotif.com/my-backups/json
The connection stays open and each event arrives on one JSON line:
{"id":"cGBLzzR9VgJo","time":1793541469,"event":"open","topic":"my-backups"}
{"id":"IKdMz9CGFTiC","time":1793541470,"event":"message","topic":"my-backups","message":"Copy complete","expires":1793584670}
A keepalive event arrives every 30 seconds to keep the connection open.
SSE stream
The Server-Sent Events format suits EventSource in a browser.
curl -s https://usenotif.com/my-backups/sse
event: open
data: {"id":"m2wCK8blvUwG","time":1793541473,"event":"open","topic":"my-backups"}
id: TgDx1jhsK5LH
data: {"id":"TgDx1jhsK5LH","time":1793541474,"event":"message","topic":"my-backups","message":"Copy complete","expires":1793584674}
message, message_delete and message_clear all arrive without an event: line. Read the event field of the JSON to tell them apart. open and keepalive have an event: line.
Text stream
/raw gives only the text, one message per line. Line breaks in a message are replaced with spaces. A keepalive produces an empty line.
curl -s https://usenotif.com/my-backups/raw
WebSocket
Connect to wss://usenotif.com/my-backups/ws. Each WebSocket message contains one JSON event, in the same format as /json. Filters, since and auth work the same way.
const ws = new WebSocket('wss://usenotif.com/my-backups/ws?since=1h');
ws.onmessage = e => console.log(JSON.parse(e.data));
Several topics
Separate topics with commas, up to 150 per connection.
curl -s https://usenotif.com/my-backups,my-home/json
You must have read access to all these topics. If a single one is refused, the whole request fails.
Read without staying connected
poll=1 returns the stored messages, then closes the connection.
curl -s "https://usenotif.com/my-backups/json?poll=1"
Messages are kept for 12 hours. If the response is over 10 MB per topic, the oldest ones are left out and the response contains the X-Messages-Truncated: 1 header.
Resume from a given point
since chooses the starting point. Without since, a continuous connection only gives new messages, and poll=1 gives everything that is stored.
curl -s "https://usenotif.com/my-backups/json?poll=1&since=1h"
| Value | Effect |
|---|---|
all |
All stored messages |
latest |
The last message only |
none |
No old messages |
10m, 1h, 2 days |
Since this duration |
1793541403 |
Since this Unix timestamp |
8sPiEtwk83R2 |
After this message (ID) |
To miss nothing after a disconnection, keep the id of the last message and pass it to since when you reconnect.
Add scheduled=1 to include scheduled messages that have not been delivered yet.
curl -s "https://usenotif.com/my-reminders/json?poll=1&scheduled=1"
Filter messages
| Parameter | Alias | Effect |
|---|---|---|
id |
Exact ID | |
message |
m |
Exact text, not case-sensitive |
title |
t |
Exact title, not case-sensitive |
priority |
prio, p |
One of the priorities, separated by commas |
tags |
tag, ta |
All the tags, separated by commas |
curl -s "https://usenotif.com/my-backups/json?poll=1&priority=high,urgent"
curl -s "https://usenotif.com/my-backups/json?tags=warning,disk"
A message without a priority counts as priority 3. Filters only apply to message events.
All these parameters also work as headers: X-Poll, X-Since, X-Scheduled, X-Priority, etc. po, si and sched are aliases of poll, since and scheduled.
Protected topics
Pass your token as you would to publish. See Accounts.
curl -s -H "Authorization: Bearer tk_yourtoken" https://usenotif.com/my-private-topic/json
With EventSource or WebSocket in a browser, which do not accept headers, use the auth parameter.
To check read access without reading any messages:
curl -H "Authorization: Bearer tk_yourtoken" https://usenotif.com/my-private-topic/auth
Message format
{
"id": "OwR5sRK7eWPN",
"time": 1793541433,
"expires": 1793584633,
"event": "message",
"topic": "my-backups",
"title": "Backup complete",
"message": "12 GB copied",
"priority": 4,
"tags": ["floppy_disk"],
"click": "https://usenotif.com/docs",
"icon": "https://usenotif.com/icons/icon-192.png",
"actions": [{"action": "view", "label": "Details", "url": "https://usenotif.com/docs", "clear": false}],
"attachment": {
"name": "report.pdf",
"type": "application/pdf",
"size": 52041,
"expires": 1793552233,
"url": "https://usenotif.com/file/E26jUBV5Cm85.pdf"
},
"content_type": "text/markdown",
"sequence_id": "copy-42"
}
Only id, time, event and topic are always present. The other fields are added when they have a value.
| Field | Content |
|---|---|
id |
12-character ID |
time |
Unix timestamp of delivery |
expires |
Unix timestamp of removal from the server |
event |
Event type |
topic |
Topic. In open, the list of topics |
message |
Text |
title |
Title |
priority |
From 1 to 5. Missing: priority 3 |
tags |
List of tags |
click |
Click link |
icon |
Icon address |
actions |
List of buttons |
attachment |
Attachment. For an online file, only name and url are present |
content_type |
text/markdown if the message is in Markdown |
sequence_id |
Sequence ID |
encoding |
base64 for some UnifiedPush messages |
Event types
| Event | Meaning |
|---|---|
open |
Connection established |
keepalive |
Keeps the connection alive |
message |
New message |
message_clear |
The message of this sequence has been read: close its notification |
message_delete |
The message of this sequence has been deleted |
poll_request |
The client must read the topic again |
For updates, keep the last message of each sequence_id. Replaced and deleted messages stay stored until they expire and come back when you resume with since.