Developers
Realtime API
A Socket.IO connection to the /v1 namespace, authenticated with the same key. Generate without polling, and hear about changes as they happen.
realtime.js
import { io } from "socket.io-client";
const socket = io("https://api.tokoman.com/v1", { auth: { apiKey: process.env.TOKOMAN_KEY } });
socket.on("ready", (d) => console.log("connected as", d.application, "with", d.scopes));
socket.on("generateDocumentSuccess", ({ populatedItem }) => console.log(populatedItem.status, populatedItem.downloadUrl));
socket.on("generateDocumentError", ({ message, code }) => console.error(code, message));
socket.emit("generateDocument", { templateId: "invoice", correlationId: "INV-2026-0419", data: { … } });
// Pushed for every change your key's read scopes allow
socket.on("change", (change) => console.log(change.event, change.data));Every REST operation has a realtime event of the same name: listTemplates, getDocument, generateDocument, and so on. You emit the request and listen for the Success and Error events. There are no callbacks.
The change feed
The same events a webhook receives, pushed to the connection. A key with documents.read hears about documents; one without does not. Reconnecting does not replay what was missed; use a webhook for anything that must not be lost.
Envelope
json
{ "populatedItem": { … } | [ … ] | null, "message": "…", "success": true }