API

Realtime Socket.IO API for live tenant events

Get live events and shared-document locking over Socket.IO. Catch up on missed events with replay.

Problems we solve

Does any of this sound like your week?

My page asks the server for changes all day.

Open one Socket.IO connection and listen. Events arrive as they happen, with no stream of empty requests.

The laptop went to sleep and I missed events.

Reconnect with a since checkpoint. The server replays the events you missed to your socket only.

Two people edited the same document. One lost.

Ask for the edit lock. Only the holder can broadcast changes, and others wait in line.

Will user A ever see user B events?

Rooms come from the verified token on the server, never from anything the browser sends.

What it does

  • The Realtime API pushes changes to your app the moment they happen. It uses Socket.IO. Connect once with the user token. You join a room for your account. Events for your account arrive as they are published. Nobody else gets your events, and you get no one else's.
  • It solves the polling problem. Instead of asking every few seconds "has anything changed?", your page listens. Dashboards update, lists refresh and toasts appear without a reload. Your server is not hit by a stream of empty requests.
  • Connecting is simple. Open a Socket.IO connection to /socket.io. Pass the JWT in the auth payload as token. Tokens in the URL query string are refused on purpose. Query strings end up in logs and browser history. A session may be revoked, an account suspended or a user turned off. A regular check then cuts any open sockets.
  • Missed something while offline? Add a since checkpoint to the connection as a query parameter. It can be a stream id or an ISO-8601 time. The server then replays the events you missed to that socket only. Events are kept on a Redis stream per tenant. Pass * to skip replay and go live only.
  • There is also a collaboration layer for shared documents. Each document has a room per tenant. Clients can join and leave. They can ask for the edit lock, release it and broadcast a change. They can also share presence, such as a cursor. Only the lock holder can broadcast changes. Waiting requests line up in order. The lock ends on its own after five minutes. Change history is kept.
  • How events get in: Takelan platform services publish them. They use an internal route that checks service sign-in. Your own app consumes them and uses the document collaboration events. That route is not a publishing API for customers. Agents cannot use it either.
  • We do not publish connection limits, delay or delivery-time numbers.
  • Pricing that stays affordable. Start free*. *Free test level; past the limits, non-critical calls slow or pause and nothing is charged unless you turn overage on. Connected ShadowCradle organizations can switch on Takelan SSO and these base-included services with one switch. Airgap licences work without any Takelan connection.

See how it works

Live tenant events, no polling

Browsers connect with a token and join the room for their account. Platform services publish inside the system. Events reach only your account. Customers cannot publish directly.

Shared documents with an edit lock

Only the lock holder can broadcast changes. Others wait in line, first come, first served. The lock ends on its own after five minutes.
Example use cases6 examples

A live dashboard

An operations screen listens for events. It updates a status tile when something changes. No refresh button needed.

Never miss an event after a reconnect

A laptop wakes from sleep and the socket reconnects with a since checkpoint. The server replays what was missed, so the list catches up.

Two people, one document

An editor asks for the lock. The second person sees who holds it and joins the queue. When the first releases it, the next in line gets the lock.

Show who is here

A shared document view broadcasts presence and cursor positions so teammates see each other.

Stay in step with a long job

A web app starts an import and listens for tenant events that report progress, instead of polling a status endpoint.

Safe by tenant

A SaaS app with many customers must be sure user A never gets user B events. Rooms are chosen from the verified token, never from anything the browser sends.

Try it

Connect from a browser (JavaScript)

import { io } from 'socket.io-client'

const socket = io('https://www.takelan.com', {
  path: '/socket.io',
  auth: { token: accessToken },  // the user's SSO JWT, never in the URL
  query: { since: lastSeenIso }  // optional: replay tenant events after this point; '*' = live only
})

socket.on('tenant_event', (event) => {
  console.log(event.event_type, event.resource_type, event.resource_id)
})

socket.on('tenant_event_replay_error', (e) => console.warn(e.message))
socket.on('connect_error', (err) => console.error(err.message))

Access tokens are short-lived. The SSO access token lasts 1800 seconds. After a refresh, reconnect with a fresh token. Use your own origin if your deployment serves the realtime service elsewhere.

Ask for the edit lock on a shared document

socket.emit('JOIN_DOCUMENT', { documentId: 'doc-42' })
socket.emit('DOCUMENT_LOCK_REQUESTED', { documentId: 'doc-42' })

// when you hold the lock:
socket.emit('DOCUMENT_CHANGED', { documentId: 'doc-42', change: { op: 'insert', at: 12, text: 'Hello' } })
socket.emit('DOCUMENT_LOCK_RELEASED', { documentId: 'doc-42' })

Payload field names are a sketch. Check the server events in your environment before you ship.

Endpoints2 endpoints
  • GET /socket.io/ Socket.IO endpoint. Connect with auth.token. Optional since checkpoint for replay.
  • POST /internal/publish Platform services only: store and broadcast a tenant event (service token). Not for customer apps.

MCP

Not available as tools. Socket and internal publish routes are excluded from /mcp/utils on purpose. An agent that needs the current state can read it from the REST APIs through /mcp/utils. It is read-only by default, and writes are off by default. About MCP

Common questions

how to get realtime updates in a web app without polling

Open a Socket.IO connection to /socket.io with the user JWT in the auth payload. Then listen for tenant_event. You get events for your tenant as they happen.

how do I authenticate a socket.io connection

Send the token in the auth object as token. Tokens in the query string are refused. Invalid or revoked sessions get a connect_error.

can I replay events I missed while offline

Yes. Pass a since query parameter on the connection. Use a Redis stream id or an ISO-8601 time. Missed tenant events are replayed to that socket only. Use * to skip replay.

how does document locking work

A client requests the lock for a document. If someone holds it, the request waits in a first-in first-out queue. The holder can broadcast changes and release the lock. The lock expires after five minutes if it is not released.

can one tenant see another tenant's events

No. Rooms are chosen from the verified token on the server. Document rooms are also tied to your account. The same document id in two accounts is two rooms.

can my own app publish events to the room

Not through this API today. Publishing is an internal route for Takelan platform services. Your app consumes tenant events and uses the document collaboration events. For app-to-person alerts, use the Notifications API.

what happens to my socket if my session is revoked

A periodic check compares open sockets with the session service. If the session was revoked, the user was turned off or the account was suspended, the socket is cut.

is the realtime api free

It is negotiable on price: start free*. *Free test level; past the limits, non-critical calls slow or pause and nothing is charged unless you turn overage on.

Analytics & Cookies

We use self-hosted Matomo analytics. By default we measure anonymously with no cookies. Enable cookies to help us improve your experience. You can change this anytime.