Skip to content

REST API

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

FieldTypeAlwaysDescription
channelstring
entriesarray
next_offsetstringPass 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

FieldTypeAlwaysDescription
statusstring
export_idstring
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_idpathstringExport id returned by realtime_archive_export

Response

FieldTypeAlwaysDescription
refobjectBlob reference of the NDJSON export once status is "done"
errorstring
statusstring
export_idstring
entry_countinteger
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

FieldTypeAlwaysDescription
grantsarray
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)
opsbodyarrayOperations granted on matching channels

Response

FieldTypeAlwaysDescription
idstring
opsarray
patternstring
subjectstring
createdAtstring
DELETE/realtime/grants/:id

Revoke a realtime channel grant by id

MCP tool: realtime_grant_revoke

Parameters

NameInTypeRequiredDescription
idpathstringGrant id to revoke

Response

FieldTypeAlwaysDescription
revokedboolean
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

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
publishedbooleanPublish 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

FieldTypeAlwaysDescription
epochstringCurrent stream epoch, or null when the channel has no history yet
channelstringChannel the history was read from
entriesarrayEntries 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

FieldTypeAlwaysDescription
namespacesarray
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)
visibilitybodystringpublic: any authenticated identity may subscribe without a grant
presencebodybooleanWhether presence is enabled on channels in this namespace
clientEventsbodybooleanWhether clients may publish events directly
historybodystringHistory 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
subscribeProxyUrlbodystringIf set, token mint consults this URL per requested channel (fail-closed); null disables
archivebodystringHistory archive policy: off, or durably retain archived entries for N days (requires history != "none")

Response

FieldTypeAlwaysDescription
idstring
namestring
archivestringHistory archive policy
historystring
presenceboolean
createdAtstring
updatedAtstring
visibilitystring
clientEventsboolean
identifiedOnlyboolean
subscribeProxyUrlstring
encryptionRequiredboolean
historyWindowSecondsinteger
subscribeProxySecretstringFull proxy signing secret — returned ONLY when subscribeProxyUrl is set/changed
subscribeProxySecretPrefixstringVisible 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

FieldTypeAlwaysDescription
deletedboolean
GET/realtime/namespaces/:name

Get a realtime namespace and its policy by name

MCP tool: realtime_namespace_get

Parameters

NameInTypeRequiredDescription
namepathstringNamespace name

Response

FieldTypeAlwaysDescription
idstring
namestring
archivestringHistory archive policy
historystring
presenceboolean
createdAtstring
updatedAtstring
visibilitystring
clientEventsboolean
identifiedOnlyboolean
subscribeProxyUrlstring
encryptionRequiredboolean
historyWindowSecondsinteger
subscribeProxySecretstringFull proxy signing secret — returned ONLY when subscribeProxyUrl is set/changed
subscribeProxySecretPrefixstringVisible 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
visibilitybodystringpublic: any authenticated identity may subscribe without a grant
presencebodybooleanWhether presence is enabled on channels in this namespace
clientEventsbodybooleanWhether clients may publish events directly
historybodystringHistory 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
subscribeProxyUrlbodystringIf set, token mint consults this URL per requested channel (fail-closed); null disables
archivebodystringHistory archive policy: off, or durably retain archived entries for N days (requires history != "none")

Response

FieldTypeAlwaysDescription
idstring
namestring
archivestringHistory archive policy
historystring
presenceboolean
createdAtstring
updatedAtstring
visibilitystring
clientEventsboolean
identifiedOnlyboolean
subscribeProxyUrlstring
encryptionRequiredboolean
historyWindowSecondsinteger
subscribeProxySecretstringFull proxy signing secret — returned ONLY when subscribeProxyUrl is set/changed
subscribeProxySecretPrefixstringVisible 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

FieldTypeAlwaysDescription
channelstringChannel name
membersarrayCurrent 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

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

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

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

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

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

FieldTypeAlwaysDescription
redisstringRedis fan-out connectivity
servicestringAPI 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
channelsbodyarrayConcrete channels to filter the resolved capabilities to; omit to receive all capabilities the identity has

Response

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

FieldTypeAlwaysDescription
webhooksarray
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
urlbodystringEndpoint that receives signed lifecycle POSTs (https in production)
eventsbodyarrayLifecycle event types this webhook receives
descriptionbodystringFree-form note

Response

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
webhookIdpathstringWebhook id

Response

FieldTypeAlwaysDescription
deletedboolean
GET/realtime/webhooks/:webhookId

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

MCP tool: realtime_webhook_get

Parameters

NameInTypeRequiredDescription
webhookIdpathstringWebhook id

Response

FieldTypeAlwaysDescription
idstring
urlstring
activeboolean
eventsarray
secretsarraySecret metadata only — never the secret itself
createdAtstring
updatedAtstring
descriptionstring
PATCH/realtime/webhooks/:webhookId

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

MCP tool: realtime_webhook_update

Parameters

NameInTypeRequiredDescription
urlbodystringEndpoint that receives signed lifecycle POSTs (https in production)
eventsbodyarrayLifecycle event types this webhook receives
descriptionbodystringFree-form note
activebodybooleanInactive webhooks receive no deliveries
webhookIdpathstringWebhook id to update

Response

FieldTypeAlwaysDescription
idstring
urlstring
activeboolean
eventsarray
secretsarraySecret metadata only — never the secret itself
createdAtstring
updatedAtstring
descriptionstring
GET/realtime/webhooks/:webhookId/deliveries

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

MCP tool: realtime_webhook_deliveries_list

Parameters

NameInTypeRequiredDescription
webhookIdpathstringWebhook id
limitqueryintegerMax deliveries to return (newest first)

Response

FieldTypeAlwaysDescription
deliveriesarray
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
webhookIdpathstringWebhook id

Response

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

Start typing to search the docs.

navigateselect