Reading messages

List topics, page through history and receive new messages with the long-poll sync endpoint.

All read endpoints accept the X-API-Key header or the session cookie. Cursor values are the message seq, not timestamps, so paging is stable while new messages arrive.

List topics

terminal
curl https://your-instance.example.com/api/v1/topics \
  -H "X-API-Key: YOUR_API_KEY"
response
{ "topics": [
  { "topic": "alerts", "last_seq": 1290, "last_message_at": "2026-01-01T12:00:00.000Z" },
  { "topic": "backups", "last_seq": 980, "last_message_at": "2026-01-01T03:00:00.000Z" }
] }

Message history

GET /api/v1/messages returns newest first. Filter by topic, page with before (a seq), and cap results with limit (1–200, default 100).

terminal
curl "https://your-instance.example.com/api/v1/messages?topic=alerts&limit=50" \
  -H "X-API-Key: YOUR_API_KEY"

# older page
curl "https://your-instance.example.com/api/v1/messages?topic=alerts&limit=50&before=1200" \
  -H "X-API-Key: YOUR_API_KEY"
response
{
  "messages": [
    {
      "id": "5f4c…",
      "seq": 1290,
      "topic": "alerts",
      "title": "Backup finished",
      "body": "All files were copied.",
      "priority": 4,
      "tags": ["backup"],
      "click": null,
      "actions": null,
      "created_at": "2026-01-01T12:00:00.000Z"
    }
  ],
  "hasMore": false
}

Long-poll sync

This is how the web and desktop clients receive messages. Pass the last seen since cursor; the request is held open for up to 25 seconds and returns as soon as a message exists. Call it again with the returned cursor.

terminal
curl "https://your-instance.example.com/api/v1/sync?since=0&wait=25" \
  -H "X-API-Key: YOUR_API_KEY"
response
{
  "messages": [ … ],
  "cursor": 1290,
  "reset": false
}
  • since — last processed seq. Start at 0.
  • wait — seconds to hold the request, clamped to 0–25. Default 25.
  • topic — optional filter for a single topic.
  • reset — true when the cursor is older than retention; discard the local cache and reload history.
client.js
let cursor = 0

for (;;) {
  const res = await fetch(
    `${API_URL}/api/v1/sync?since=${cursor}&wait=25`,
    { headers: { "X-API-Key": API_KEY } }
  )
  const data = await res.json()
  if (data.reset) cursor = 0
  for (const message of data.messages) handle(message)
  cursor = data.cursor
}

Delete a message

terminal
curl -X DELETE https://your-instance.example.com/api/v1/messages/5f4c… \
  -H "X-API-Key: YOUR_API_KEY"

Deleting removes the message for every client on its next sync. Pruning by age is handled by /api/cron/prune; see self-hosting.

Health

GET /api/v1/health is public and reports whether the instance is configured and which store it uses. It never returns the key.

terminal
curl https://your-instance.example.com/api/v1/health
response
{
  "ok": true,
  "version": "0.2.0",
  "configured": true,
  "store": "supabase",
  "devMode": false,
  "retentionDays": 30
}