Skip to content

Realtime API

REST endpoints for the Realtime area of Lessly.

The Realtime area publishes 28 REST endpoints. Paths are relative to https://api.lessly.com; see Authentication for the required header.

GET/realtime/archive

Read a channel's durably archived history from Postgres (survives the Redis hot window). Offset-paginated: pass the returned next_offset as after_offset for the next page.

MCP tool: realtime_archive_get

Parameters

NameInTypeRequiredDescription
channelquerystringChannel whose archived history to read
after_offsetquerystringReturn entries strictly after this offset (from a previous page)
limitqueryinteger

Response

Returns object.

FieldTypeAlwaysDescription
channelstring
entriesobject[]
next_offsetstring | nullPass as after_offset to fetch the next page; null = no more entries
POST/realtime/archive/exports

Start an async NDJSON export of a channel's archived history to the product bucket. Returns an export id; poll realtime_archive_export_status until done.

MCP tool: realtime_archive_export

Parameters

NameInTypeRequiredDescription
channelbodystringChannel whose archive to export
from_tsbodyintegerOnly entries with ts >= from_ts (epoch ms)
to_tsbodyintegerOnly entries with ts <= to_ts (epoch ms)

Response

Returns object.

FieldTypeAlwaysDescription
statusstringone of: pending, done, failed
export_idstring (uuid)
GET/realtime/archive/exports/:export_id

Check an archive export: status, and the NDJSON blob reference once done

MCP tool: realtime_archive_export_status

Parameters

NameInTypeRequiredDescription
export_idpathstring (uuid)Export id returned by realtime_archive_export

Response

Returns object.

FieldTypeAlwaysDescription
refobject | nullBlob reference of the NDJSON export once status is "done"
errorstring | null
statusstringone of: pending, done, failed
export_idstring (uuid)
entry_countinteger | null
GET/realtime/grants

List realtime channel grants for this product, optionally filtered by subject

MCP tool: realtime_grant_list

Parameters

NameInTypeRequiredDescription
subjectquerystringFilter grants by subject

Response

Returns object.

FieldTypeAlwaysDescription
grantsobject[]
POST/realtime/grants

Grant a subject (identity id or "*" for all identities) operations on channels matching a pattern; "*" in a pattern matches exactly one segment

MCP tool: realtime_grant_create

Parameters

NameInTypeRequiredDescription
subjectbodystringIdentity id the grant applies to, or "*" for every identity in the product
patternbodystringChannel pattern, e.g. "chat:*" ("*" matches exactly one segment)
opsbodystring[]one of: subscribe, publish, presence, historyOperations granted on matching channels

Response

Returns object.

FieldTypeAlwaysDescription
idstring (uuid)
opsstring[]one of: subscribe, publish, presence, history
patternstring
subjectstring
createdAtstring
DELETE/realtime/grants/:id

Revoke a realtime channel grant by id

MCP tool: realtime_grant_revoke

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)Grant id to revoke

Response

Returns object.

FieldTypeAlwaysDescription
revokedbooleanone of: true
POST/realtime/messages

Publish a JSON message to a realtime channel of the current product

MCP tool: realtime_messages_publish

Parameters

NameInTypeRequiredDescription
channelbodystringChannel to publish the message to
databodystringJSON payload delivered to channel subscribers

Response

Returns object.

FieldTypeAlwaysDescription
epochstringStream epoch of the stored message (present when history is on)
offsetstringStream offset of the stored message (present when history is on)
channelstringChannel the message was published to
publishedbooleanone of: truePublish acknowledged by the fan-out backend
GET/realtime/messages/history

Read message history of a realtime channel: either a cursor (offset + epoch, replays strictly after the offset; recovered:false on epoch mismatch or aged-out entries) or a window (last_n / last_ms). Conceptually requires the `history` capability; in Phase 1 this surface is Identity-authenticated management access.

MCP tool: realtime_history_get

Parameters

NameInTypeRequiredDescription
channelquerystringChannel to read history from
offsetquerystringCursor: resume strictly after this offset (requires epoch)
epochquerystringCursor: stream epoch the offset belongs to
last_nqueryintegerWindow: return the last N entries
last_msqueryintegerWindow: return entries newer than now minus this many milliseconds

Response

Returns object.

FieldTypeAlwaysDescription
epochstring | nullCurrent stream epoch, or null when the channel has no history yet
channelstringChannel the history was read from
entriesobject[]Entries in stream order
recoveredbooleanfalse when the cursor epoch mismatches or entries aged out — client must resync
GET/realtime/namespaces

List all realtime namespaces registered for this product

MCP tool: realtime_namespace_list

Parameters

No parameters.

Response

Returns object.

FieldTypeAlwaysDescription
namespacesobject[]
POST/realtime/namespaces

Register a realtime namespace (the part of a channel name before the first colon) with its policy: visibility, presence, client events, history, encryption, identified-only

MCP tool: realtime_namespace_create

Parameters

NameInTypeRequiredDescription
namebodystringNamespace name (the part of a channel name before the first colon)
visibilitybodystringone of: public, authorizedpublic: any authenticated identity may subscribe without a grant
presencebodybooleanWhether presence is enabled on channels in this namespace
clientEventsbodybooleanWhether clients may publish events directly
historybodystringone of: none, last-message, windowHistory retention policy for channels in this namespace
historyWindowSecondsbodyintegerRetention window in seconds; required when history is "window"
encryptionRequiredbodybooleanWhether payloads must be end-to-end encrypted
identifiedOnlybodybooleanWhether only identified (non-anonymous) identities get capabilities
subscribeProxyUrlbodystring (uri) | nullIf set, token mint consults this URL per requested channel (fail-closed); null disables
archivebodystring | objectone of: offHistory archive policy: off, or durably retain archived entries for N days (requires history != "none")

Response

Returns object.

FieldTypeAlwaysDescription
idstring (uuid)
namestring
archivestring | objectone of: offHistory archive policy
historystringone of: none, last-message, window
presenceboolean
createdAtstring
updatedAtstring
visibilitystringone of: public, authorized
clientEventsboolean
identifiedOnlyboolean
subscribeProxyUrlstring | null
encryptionRequiredboolean
historyWindowSecondsinteger | null
subscribeProxySecretstringFull proxy signing secret — returned ONLY when subscribeProxyUrl is set/changed
subscribeProxySecretPrefixstring | nullVisible prefix of the proxy signing secret; null when no proxy url is set
DELETE/realtime/namespaces/:name

Delete a realtime namespace by name (grants on it stop resolving)

MCP tool: realtime_namespace_delete

Parameters

NameInTypeRequiredDescription
namepathstringNamespace name

Response

Returns object.

FieldTypeAlwaysDescription
deletedbooleanone of: true
GET/realtime/namespaces/:name

Get a realtime namespace and its policy by name

MCP tool: realtime_namespace_get

Parameters

NameInTypeRequiredDescription
namepathstringNamespace name

Response

Returns object.

FieldTypeAlwaysDescription
idstring (uuid)
namestring
archivestring | objectone of: offHistory archive policy
historystringone of: none, last-message, window
presenceboolean
createdAtstring
updatedAtstring
visibilitystringone of: public, authorized
clientEventsboolean
identifiedOnlyboolean
subscribeProxyUrlstring | null
encryptionRequiredboolean
historyWindowSecondsinteger | null
subscribeProxySecretstringFull proxy signing secret — returned ONLY when subscribeProxyUrl is set/changed
subscribeProxySecretPrefixstring | nullVisible prefix of the proxy signing secret; null when no proxy url is set
PATCH/realtime/namespaces/:name

Update the policy of a realtime namespace

MCP tool: realtime_namespace_update

Parameters

NameInTypeRequiredDescription
namepathstringNamespace name to update
visibilitybodystringone of: public, authorizedpublic: any authenticated identity may subscribe without a grant
presencebodybooleanWhether presence is enabled on channels in this namespace
clientEventsbodybooleanWhether clients may publish events directly
historybodystringone of: none, last-message, windowHistory retention policy for channels in this namespace
historyWindowSecondsbodyintegerRetention window in seconds; required when history is "window"
encryptionRequiredbodybooleanWhether payloads must be end-to-end encrypted
identifiedOnlybodybooleanWhether only identified (non-anonymous) identities get capabilities
subscribeProxyUrlbodystring (uri) | nullIf set, token mint consults this URL per requested channel (fail-closed); null disables
archivebodystring | objectone of: offHistory archive policy: off, or durably retain archived entries for N days (requires history != "none")

Response

Returns object.

FieldTypeAlwaysDescription
idstring (uuid)
namestring
archivestring | objectone of: offHistory archive policy
historystringone of: none, last-message, window
presenceboolean
createdAtstring
updatedAtstring
visibilitystringone of: public, authorized
clientEventsboolean
identifiedOnlyboolean
subscribeProxyUrlstring | null
encryptionRequiredboolean
historyWindowSecondsinteger | null
subscribeProxySecretstringFull proxy signing secret — returned ONLY when subscribeProxyUrl is set/changed
subscribeProxySecretPrefixstring | nullVisible prefix of the proxy signing secret; null when no proxy url is set
GET/realtime/presence

Get the current presence roster for a channel. Roster is deduplicated by identity (connections counts live sockets); a per-connection view is deferred — the store is identity-keyed.

MCP tool: realtime_presence_get

Parameters

NameInTypeRequiredDescription
channelquerystringChannel name, "namespace:rest"

Response

Returns object.

FieldTypeAlwaysDescription
channelstringChannel name
membersobject[]Current roster, deduplicated by identity
POST/realtime/presence/enter

Enter presence on a realtime channel; upserts the caller (or member_id) into the roster

MCP tool: realtime_presence_enter

Parameters

NameInTypeRequiredDescription
channelbodystringChannel name, "namespace:rest"
infobodystringArbitrary JSON metadata for the member (<=10KB serialized)
ttl_secondsbodyintegerPresence entry TTL in seconds (1-3600)
member_idbodystringAct for a synthetic member id instead of the caller identity (backend integrations)

Response

Returns object.

FieldTypeAlwaysDescription
memberobjectThe entered/updated member
channelstringChannel name
POST/realtime/presence/leave

Leave presence on a realtime channel, removing the caller (or member_id) from the roster

MCP tool: realtime_presence_leave

Parameters

NameInTypeRequiredDescription
channelbodystringChannel name, "namespace:rest"
member_idbodystringAct for a synthetic member id instead of the caller identity (backend integrations)

Response

Returns object.

FieldTypeAlwaysDescription
channelstringChannel name
removedbooleanWhether the member was removed
GET/realtime/presence/stats

Get the presence member count for a channel

MCP tool: realtime_presence_stats

Parameters

NameInTypeRequiredDescription
channelquerystringChannel name, "namespace:rest"

Response

Returns object.

FieldTypeAlwaysDescription
channelstringChannel name
membersintegerNumber of distinct identities present
POST/realtime/presence/update

Update a presence member's info and/or refresh its TTL

MCP tool: realtime_presence_update

Parameters

NameInTypeRequiredDescription
channelbodystringChannel name, "namespace:rest"
infobodystringArbitrary JSON metadata for the member (<=10KB serialized)
ttl_secondsbodyintegerPresence entry TTL in seconds (1-3600)
member_idbodystringAct for a synthetic member id instead of the caller identity (backend integrations)

Response

Returns object.

FieldTypeAlwaysDescription
memberobjectThe entered/updated member
channelstringChannel name
GET/realtime/public-access/status

Check whether this product has a public key configured — an onboarding hint for the portal, never an authorization decision

MCP tool: realtime_public_access_status

Parameters

No parameters.

Response

Returns object.

FieldTypeAlwaysDescription
existsbooleanWhether this product has created a public key yet (an onboarding hint, not a gate)
GET/realtime/status

Get realtime service status: Redis fan-out connectivity, token signing key presence, gateway URL

MCP tool: realtime_status_get

Parameters

No parameters.

Response

Returns object.

FieldTypeAlwaysDescription
redisstringone of: connected, disconnected, unconfiguredRedis fan-out connectivity
servicestringone of: okAPI liveness marker
gatewayUrlstringWebSocket URL of the realtime gateway
signingKeyConfiguredbooleanWhether the token signing key is present
POST/realtime/tokens

Mint a short-lived capability token (JWT) carrying the capabilities the identity has via namespace policy and grants (optionally filtered to the given channels), plus the gateway WebSocket URL to connect to

MCP tool: realtime_tokens_create

Parameters

NameInTypeRequiredDescription
channelsbodystring[]Concrete channels to filter the resolved capabilities to; omit to receive all capabilities the identity has

Response

Returns object.

FieldTypeAlwaysDescription
tokenstringSigned EdDSA capability JWT (60s TTL)
gatewayUrlstringWebSocket URL of the realtime gateway to connect to
GET/realtime/webhooks

List all client webhooks registered for this product (secret metadata only)

MCP tool: realtime_webhook_list

Parameters

No parameters.

Response

Returns object.

FieldTypeAlwaysDescription
webhooksobject[]
POST/realtime/webhooks

Register a client webhook: lifecycle notifications (channel occupied/vacated, presence member added/removed) are POSTed to the URL signed with HMAC-SHA256. Returns the full signing secret ONCE.

MCP tool: realtime_webhook_create

Parameters

NameInTypeRequiredDescription
urlbodystring (uri)Endpoint that receives signed lifecycle POSTs (https in production)
eventsbodystring[]one of: channel.occupied, channel.vacated, presence.member-added, presence.member-removedLifecycle event types this webhook receives
descriptionbodystringFree-form note

Response

Returns object.

FieldTypeAlwaysDescription
secretstringFull signing secret — returned only once, at creation. Store it now.
webhookobject
DELETE/realtime/webhooks/:webhookId

Delete a client webhook (its secrets and delivery log go with it)

MCP tool: realtime_webhook_delete

Parameters

NameInTypeRequiredDescription
webhookIdpathstring (uuid)Webhook id

Response

Returns object.

FieldTypeAlwaysDescription
deletedbooleanone of: true
GET/realtime/webhooks/:webhookId

Get a client webhook by id (secret metadata only, never the secret)

MCP tool: realtime_webhook_get

Parameters

NameInTypeRequiredDescription
webhookIdpathstring (uuid)Webhook id

Response

Returns object.

FieldTypeAlwaysDescription
idstring (uuid)
urlstring
activeboolean
eventsstring[]
secretsobject[]Secret metadata only — never the secret itself
createdAtstring
updatedAtstring
descriptionstring | null
PATCH/realtime/webhooks/:webhookId

Update a client webhook: url, event filter, description, active flag

MCP tool: realtime_webhook_update

Parameters

NameInTypeRequiredDescription
urlbodystring (uri)Endpoint that receives signed lifecycle POSTs (https in production)
eventsbodystring[]one of: channel.occupied, channel.vacated, presence.member-added, presence.member-removedLifecycle event types this webhook receives
descriptionbodystring | nullFree-form note
activebodybooleanInactive webhooks receive no deliveries
webhookIdpathstring (uuid)Webhook id to update

Response

Returns object.

FieldTypeAlwaysDescription
idstring (uuid)
urlstring
activeboolean
eventsstring[]
secretsobject[]Secret metadata only — never the secret itself
createdAtstring
updatedAtstring
descriptionstring | null
GET/realtime/webhooks/:webhookId/deliveries

List recent delivery attempts of a webhook (status, attempts, response code)

MCP tool: realtime_webhook_deliveries_list

Parameters

NameInTypeRequiredDescription
webhookIdpathstring (uuid)Webhook id
limitqueryintegerMax deliveries to return (newest first)

Response

Returns object.

FieldTypeAlwaysDescription
deliveriesobject[]
POST/realtime/webhooks/:webhookId/secret/rotate

Rotate the webhook signing secret with an overlap window: the new secret signs immediately (returned ONCE), the previous one keeps verifying until its grace expiry

MCP tool: realtime_webhook_secret_rotate

Parameters

NameInTypeRequiredDescription
webhookIdpathstring (uuid)Webhook id

Response

Returns object.

FieldTypeAlwaysDescription
prefixstringVisible prefix of the new secret (X-Realtime-Key)
secretstringNew full signing secret — returned only once. Store it now.
previousExpiresAtstring | nullWhen the rotated-out secret stops verifying (grace window)
Was this page helpful?
Esc

Start typing to search the docs.

navigateselect