retry: 3000
id: evt_0193c1a2c0027a2b8c3d4e5f60718293
event: document.checking
data: {"id":"evt_0193c1a2c0027a2b8c3d4e5f60718293","type":"document.checking","created_at":"2026-11-26T09:41:49.002Z","workspace":"ws_0193c1a2b3c44d5e8f60718293a4b5c6","mode":"live","data":{"object":{"id":"doc_0193c1a2b7d84e1f9a2b3c4d5e6f7081","object":"document","state":"checking","check":{"stage":"reading","percent":25}}},"channel":"workspace"}
:
id: evt_0193c1a2c0047a2b8c3d4e5f60718293
event: document.checked
data: {"id":"evt_0193c1a2c0047a2b8c3d4e5f60718293","type":"document.checked","created_at":"2026-11-26T09:41:58.906Z","workspace":"ws_0193c1a2b3c44d5e8f60718293a4b5c6","mode":"live","data":{"object":{"id":"doc_0193c1a2b7d84e1f9a2b3c4d5e6f7081","object":"document","state":"checked","verdict":"trusted"}},"channel":"workspace"}
event: resync
data: {}// on your server: mint a token with the secret key
// POST /v1/realtime/tokens {"channels": ["workspace"]}
// in the page: read the stream with fetch, the token in the Authorization
// header (EventSource cannot set headers, and a URL would put it in logs)
let lastEventId: string | null = null;
async function follow(token: string) {
const res = await fetch("https://api.kontiga.com/v1/realtime?channels=workspace", {
headers: {
Authorization: `Bearer ${token}`,
Accept: "text/event-stream",
...(lastEventId ? { "Last-Event-ID": lastEventId } : {}),
},
});
const reader = res.body!.pipeThrough(new TextDecoderStream()).getReader();
let buffer = "";
for (;;) {
const { value, done } = await reader.read();
if (done) break;
buffer += value;
const messages = buffer.split("\n\n");
buffer = messages.pop() ?? "";
for (const message of messages) {
const id = /^id: (.+)$/m.exec(message)?.[1];
const type = /^event: (.+)$/m.exec(message)?.[1];
const data = /^data: (.+)$/m.exec(message)?.[1];
if (id) lastEventId = id;
if (type === "resync") reloadWhatIsShown();
else if (type && data) handle(type, JSON.parse(data));
}
}
}POST/v1/realtime/tokens
A short-lived token that opens the realtime channel for the channels named, so a page or a script listens without holding a secret key.
- Who may
- Owner, Admin and Developer
- CLI
kontiga realtime token [--channels <channel,...>]- MCP tool
create_realtime_token- Returns
- The token, shown once, with when it expires; it carries the key’s workspace, mode and scopes.
Parameters
channelsThe channels the token opens:
workspace(any channel of the workspace your access reads), or exactly thedocument:{document_id}channels named. Left out,workspace. The token carries the key’s workspace and mode and lasts 15 minutes. At most 20 items.
curl -X POST https://api.kontiga.com/v1/realtime/tokens \
-H "Authorization: Bearer $KONTIGA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"channels": [
"document:doc_0193c1a2b7d84e1f9a2b3c4d5e6f7081"
]
}'POST /v1/realtime/tokens
{
"object": "realtime_token",
"token": "kt_rt_AQICAAIBAA8yXj3sY4bK1q0nT7wVd2LmRh9cPz6EaF5uG8iJxO4kB3MvNsQ7lUe",
"expires_at": "2026-11-26T10:12:00Z",
"channels": ["document:doc_0193c1a2b7d84e1f9a2b3c4d5e6f7081"],
"mode": "live"
}GET/v1/realtime
The workspace’s events as they happen, one server-sent event each, resumed after a drop with the last event id so none is missed.
- Who may
- Owner, Admin, Analyst and Viewer; Developer in test mode
- CLI
kontiga events tail [--channels <channel,...>] [--types <event,...>] [--last-event-id <evt_id>]- MCP tool
read_live_events- Returns
- The events after last_event_id, oldest first, each in the webhook envelope; the stream itself keeps sending as they happen.
Parameters
channelsThe channels to follow. Changing them means opening the stream again with
Last-Event-ID. At most 20 items.typesOnly these event types, such as
document.checked, or every type of a product, such asdocument. Left out, every type. At most 50 items.last_event_idThe page: the events after this one, oldest first, at most 50. The stream resumes from the
Last-Event-IDheader instead.
curl -X GET "https://api.kontiga.com/v1/realtime?channels=workspace&types=document&last_event_id=evt_0193c1a2c0027a2b8c3d4e5f60718293" \
-H "Authorization: Bearer $KONTIGA_API_KEY"GET /v1/realtime
{
"object": "event_page",
"events": [
{
"id": "evt_0193c1a2c0037a2b8c3d4e5f60718293",
"type": "document.checked_fast",
"created_at": "2026-11-26T09:41:51.204Z",
"workspace": "ws_0193c1a2b3c44d5e8f60718293a4b5c6",
"mode": "live",
"data": { "object": { "id": "doc_0193c1a2b7d84e1f9a2b3c4d5e6f7081", "object": "document" } }
},
{
"id": "evt_0193c1a2c0047a2b8c3d4e5f60718293",
"type": "document.checked",
"created_at": "2026-11-26T09:41:58.906Z",
"workspace": "ws_0193c1a2b3c44d5e8f60718293a4b5c6",
"mode": "live",
"data": { "object": { "id": "doc_0193c1a2b7d84e1f9a2b3c4d5e6f7081", "object": "document" } }
}
],
"last_event_id": "evt_0193c1a2c0047a2b8c3d4e5f60718293"
}With Accept: text/event-stream the call is the stream: text/event-stream, open until it ends. Without it, a reader that cannot hold a stream, such as an MCP tool, gets the page of events after last_event_id shown here, each naming its object, and calls again with the newest id.