HTTP API: realtime
Publish to channels, read presence and replay missed messages, server-side subscriptions, rule dry-runs and end-to-end encryption keys.
Realtime over HTTP: publish, catch up, presence, rule checks and the keys of end-to-end encrypted channels. Channel rules (SUBSCRIBE, PUBLISH) decide who may do what (Channels and connections).
| Base URL | https://<project-ref>.sovarias.in — your project URL from Connect. |
| Keys | Send the project's key as apikey. Calls made for a signed-in user also send Authorization: Bearer <access token>. |
| Errors | A status code and {"detail": …} — a sentence, or {code, message} for errors your code may branch on (HTTP API). |
#Publish and catch up
Clients receive messages over a WebSocket: get a ticket with POST /api/v1/auth/ws-ticket (HTTP API: authentication), then connect to wss://<project-ref>.sovarias.in/api/v1/rt/ws/<channel>?ticket=…. The SDKs do this (JavaScript: Realtime).
POST/api/v1/rt/stream/publish/{channel}
Publish a message to a channel.
Every subscriber of the channel — including the sender — receives it, with a stream_seq (its number in the channel) that clients use to catch up with replay. Your channel rules must allow PUBLISH for the caller; servers publish with the service role key.
Send the message as payload, or the whole body is taken as the payload. Give an event_id to make retries safe: the same id within 24 hours is published once.
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/stream/publish/{channel}
Path parameters
channelstringrequired- The channel name:
room-42,user:<id>, …
Body
payloadobjectoptional- The message (a JSON object), up to the plan's / project's message size. Without it, the body itself is the payload.
event_idstringoptional- 1–64 letters, digits,
-,_. A repeat within 24 hours isn't published again (duplicate: true).
Returns
channelstringstream_seqinteger- The message's number in the channel.
clock, clock_deltaobject- Vector clock of the channel (ordering across realtime servers).
publishedbooleanfalsewithduplicate: truewhen theevent_idwas already published.
Responses
- 200Success.
- 400
payloadisn't a JSON object, a badevent_id, or the message is over the size limit. - 403
CHANNEL_DENIED— no channel rule allows this caller to publish/subscribe here (Channels and connections). - 403
PLAN_QUOTA_EXHAUSTED— the plan's realtime messages for the month are used up (rt.messages_month). - 429Over the project's events per second — retry after
Retry-After. - 401No valid session or key.
curl -s -X POST "$URL/api/v1/rt/stream/publish/room-42" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"payload": {"text": "Hello!", "from": "ada"}, "event_id": "msg_01J9ZK3"}'Response
{
"channel": "room-42",
"clock": {
"pulse-1": 1834
},
"clock_delta": {
"pulse-1": 1
},
"stream_seq": 1834,
"published": true
}GET/api/v1/rt/stream/replay/{channel}
Messages published after a sequence number — how a client catches up after being offline.
The most recent messages per channel are kept (the plan's rt.replay_events). Needs SUBSCRIBE on the channel.
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/stream/replay/{channel}
Path parameters
channelstringrequired- The channel.
Query parameters
afterintegeroptionaldefault0- Return messages with
stream_seqgreater than this (the last one the client saw). limitintegeroptionaldefault200- 1–1,000 (default 200).
- 1–1000
Returns
eventsarray<object>- In order:
payload,stream_seq,clock,clock_delta, thechanneland its internalscoped_channelname. countinteger
Responses
- 200Success.
- 403
CHANNEL_DENIED— no channel rule allows this caller to publish/subscribe here (Channels and connections). - 401No valid session or key.
curl -s "$URL/api/v1/rt/stream/replay/room-42?after=1832&limit=50" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN"Response
{
"channel": "room-42",
"events": [
{
"channel": "room-42",
"scoped_channel": "b2f4a1c8…:room-42:…",
"payload": {
"text": "Are you there?",
"from": "grace"
},
"clock": {
"pulse-1": 1833
},
"clock_delta": {
"pulse-1": 1
},
"stream_seq": 1833
},
{
"channel": "room-42",
"scoped_channel": "b2f4a1c8…:room-42:…",
"payload": {
"text": "Hello!",
"from": "ada"
},
"clock": {
"pulse-1": 1834
},
"clock_delta": {
"pulse-1": 1
},
"stream_seq": 1834
}
],
"count": 2
}GET/api/v1/rt/stream/presence/{channel}
Who is connected to a channel right now.
Each open connection (tab or device) is one client; a connection that vanished without closing stays listed for about 90 seconds (Presence). Needs SUBSCRIBE on the channel.
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/stream/presence/{channel},/presence/v1/{channel}
Path parameters
channelstringrequired- The channel.
Returns
online_clientsarray<string>- Connection ids.
countinteger
Responses
- 200Success.
- 403
CHANNEL_DENIED— no channel rule allows this caller to publish/subscribe here (Channels and connections). - 401No valid session or key.
curl -s "$URL/api/v1/rt/stream/presence/doc-1234" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN"Response
{
"channel": "doc-1234",
"online_clients": [
"c_7f2a91",
"c_03bd4e"
],
"count": 2
}#Channels, rule checks and server subscriptions
GET/api/v1/rt/stream/channels
The project's active channels with subscriber and message counts.
For your team only — channel names such as user:<id> are the project's business.
- Who
- A project team member's session (the console, or a token from
sov login) asAuthorization: Bearer <token>. The member's role must allow the action. - Also at
/realtime/v1/stream/channels
Responses
- 200Success.
- 403App users can't list channels.
- 401No valid session or key.
curl -s "$URL/api/v1/rt/stream/channels" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN"Response
{
"channels": [
{
"channel": "room-42",
"scoped_channel": "b2f4a1c8…:room-42:…",
"subscribers": 2,
"event_count": 1834
}
],
"total": 1
}POST/api/v1/rt/stream/dry-run
Would a given caller be allowed to subscribe to or publish on a channel? Nothing is sent.
- Who
- A project team member's session (the console, or a token from
sov login) asAuthorization: Bearer <token>. The member's role must allow the action. - Also at
/realtime/v1/stream/dry-run
Body
channelstringrequiredactionstringoptionaldefaultSUBSCRIBE- One of
SUBSCRIBE,PUBLISH user_idstringoptional- An app user's id; leave out for an anonymous visitor.
rolesarray<string>optional- That user's app roles (up to 20).
payloadobjectoptional- A message to measure against the size limit.
Responses
- 200Success.
- 401No valid session or key.
curl -s -X POST "$URL/api/v1/rt/stream/dry-run" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"channel": "orders", "action": "PUBLISH", "user_id": "6e19c0a2-…", "roles": ["staff"], "payload": {"order": 1042}}'Response
{
"channel": "orders",
"action": "PUBLISH",
"caller": {
"user_id": "6e19c0a2-…",
"roles": [
"staff"
],
"anonymous": false
},
"allowed": true,
"reason": "ALLOWED",
"subscribers_now": 4,
"would_reach": 4,
"payload_bytes": 14,
"notes": [],
"sent": false
}POST/api/v1/rt/stream/subscribe
Subscribe a server-side client id to a channel (for server consumers; apps use WebSockets). It shows in presence for 90 seconds: subscribe again to stay present. If the project allows only signed-in users, a bare project key gets 401 here and on replay and publish.
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/stream/subscribe
Body
channelstringrequired- The channel.
client_idstringrequired- Your consumer's id.
Returns
channelstringrequired- The channel name.
subscribedbooleanoptionaldefaulttrue
Responses
- 200Success.
- 403
CHANNEL_DENIED— no channel rule allows this caller to publish/subscribe here (Channels and connections). - 401No valid session or key.
- 422The body is missing a required field or has a field of the wrong type.
curl -s -X POST "$URL/api/v1/rt/stream/subscribe" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"channel": "orders", "client_id": "worker-1"}'Response
{
"channel": "orders",
"subscribed": true
}POST/api/v1/rt/stream/unsubscribe
Remove a server-side subscription.
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/stream/unsubscribe
Body
channelstringrequired- The channel.
client_idstringrequired- The id you subscribed.
Responses
- 200Success.
- 401No valid session or key.
- 422The body is missing a required field or has a field of the wrong type.
curl -s -X POST "$URL/api/v1/rt/stream/unsubscribe" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"channel": "orders", "client_id": "worker-1"}'Response
{
"status": "ok"
}#End-to-end encryption keys
POST/api/v1/rt/e2ee/keys/bootstrap
Get (or create) the active key of an end-to-end encrypted channel.
Clients encrypt messages with this key before publishing and decrypt after receiving, so Sovaria relays them without being able to read them. Send your public key to receive the key wrapped for it. Paid plans (rt.e2ee).
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/e2ee/keys/bootstrap
Body
channelstringrequired- The channel.
- 1–128 characters
ttl_secondsintegeroptionaldefault86400- How long a new key lives (60 s – 7 days; default 1 day).
- 60.0–604800.0
force_newbooleanoptionaldefaultfalse- Create a new key even if one is active.
client_public_key_pemstring | nulloptional- The client's RSA public key (PEM). The channel key comes back encrypted for it (
wrapped_key_b64) instead of in clear.
Returns
channelstringtenant_scopestring- The organization and project the key belongs to.
key_idstring- Send it with encrypted messages so receivers know which key to use.
key_b64string | null- The AES key (base64) — only when no
client_public_key_pemwas sent. wrapped_key_b64string | null- The AES key encrypted for your public key (base64).
wrapping_algstring | nullRSA-OAEP-SHA256.statusstringactiveorrotated.created_at_ms, expires_at_msinteger- Unix milliseconds.
Responses
- 200Success.
- 403
CHANNEL_DENIED— no channel rule allows this caller to publish/subscribe here (Channels and connections). - 403
PLAN_FEATURE_REQUIRED— end-to-end encryption isn't in the plan. - 401No valid session or key.
- 422The body is missing a required field or has a field of the wrong type.
curl -s -X POST "$URL/api/v1/rt/e2ee/keys/bootstrap" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"channel": "room-42", "client_public_key_pem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBg…\n-----END PUBLIC KEY-----"}'Response
{
"channel": "room-42",
"tenant_scope": "b2f4a1c8…:f0c3e9a2…",
"key_id": "k_9f3a2c71",
"key_b64": null,
"wrapped_key_b64": "Qm9v…",
"wrapping_alg": "RSA-OAEP-SHA256",
"status": "active",
"created_at_ms": 1792262400000,
"expires_at_ms": 1792348800000
}POST/api/v1/rt/e2ee/keys/rotate
Replace a channel's key; the old one stays readable for messages already sent (rotated).
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/e2ee/keys/rotate
Body
channelstringrequired- The channel.
- 1–128 characters
ttl_secondsintegeroptionaldefault86400- Lifetime of the new key.
- 60.0–604800.0
client_public_key_pemstring | nulloptional- The client's RSA public key (PEM). The channel key comes back encrypted for it (
wrapped_key_b64) instead of in clear.
Returns
channelstringtenant_scopestring- The organization and project the key belongs to.
key_idstring- Send it with encrypted messages so receivers know which key to use.
key_b64string | null- The AES key (base64) — only when no
client_public_key_pemwas sent. wrapped_key_b64string | null- The AES key encrypted for your public key (base64).
wrapping_algstring | nullRSA-OAEP-SHA256.statusstringactiveorrotated.created_at_ms, expires_at_msinteger- Unix milliseconds.
Responses
- 200Success.
- 401No valid session or key.
- 422The body is missing a required field or has a field of the wrong type.
curl -s -X POST "$URL/api/v1/rt/e2ee/keys/rotate" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"channel": "room-42"}'Response
{
"channel": "room-42",
"tenant_scope": "b2f4a1c8…:f0c3e9a2…",
"key_id": "k_1c7e0b44",
"key_b64": "q1Z8…",
"wrapped_key_b64": null,
"wrapping_alg": null,
"status": "active",
"created_at_ms": 1792262400000,
"expires_at_ms": 1792348800000
}POST/api/v1/rt/e2ee/keys/revoke
Revoke a channel key (or the active one); it can't be fetched again.
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/e2ee/keys/revoke
Body
channelstringrequired- The channel.
- 1–128 characters
key_idstring | nulloptional- The key; leave out for the active one.
- 3–128 characters
reasonstring | nulloptional- Why (kept with the key).
- 0–256 characters
Returns
channelstringrequired- The channel name.
tenant_scopestringrequiredkey_idstringrequiredstatusstringrequired- One of
active,rotated,revoked,expired created_at_msintegerrequiredexpires_at_msintegerrequiredrevoked_at_msinteger | nulloptionalrevocation_reasonstring | nulloptional
Responses
- 200Success.
- 401No valid session or key.
- 422The body is missing a required field or has a field of the wrong type.
curl -s -X POST "$URL/api/v1/rt/e2ee/keys/revoke" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"channel": "room-42", "key_id": "k_9f3a2c71", "reason": "device lost"}'Response
{
"channel": "room-42",
"tenant_scope": "b2f4a1c8…:f0c3e9a2…",
"key_id": "k_9f3a2c71",
"status": "revoked",
"created_at_ms": 1792262400000,
"expires_at_ms": 1792348800000,
"revoked_at_ms": 1792266000000,
"revocation_reason": "device lost"
}GET/api/v1/rt/e2ee/keys/active/{channel}
The channel's active key.
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/e2ee/keys/active/{channel}
Path parameters
channelstringrequired- The channel.
Query parameters
client_public_key_pemstring | nulloptional- The client's RSA public key (PEM). The channel key comes back encrypted for it (
wrapped_key_b64) instead of in clear.
Returns
channelstringtenant_scopestring- The organization and project the key belongs to.
key_idstring- Send it with encrypted messages so receivers know which key to use.
key_b64string | null- The AES key (base64) — only when no
client_public_key_pemwas sent. wrapped_key_b64string | null- The AES key encrypted for your public key (base64).
wrapping_algstring | nullRSA-OAEP-SHA256.statusstringactiveorrotated.created_at_ms, expires_at_msinteger- Unix milliseconds.
Responses
- 200Success.
- 401No valid session or key.
curl -s "$URL/api/v1/rt/e2ee/keys/active/room-42" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN"Response
{
"channel": "room-42",
"tenant_scope": "b2f4a1c8…:f0c3e9a2…",
"key_id": "k_9f3a2c71",
"key_b64": null,
"wrapped_key_b64": "Qm9v…",
"wrapping_alg": "RSA-OAEP-SHA256",
"status": "active",
"created_at_ms": 1792262400000,
"expires_at_ms": 1792348800000
}GET/api/v1/rt/e2ee/keys/{channel}/{key_id}
One key of the channel, to decrypt older messages.
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/e2ee/keys/{channel}/{key_id}
Path parameters
channelstringrequired- The channel.
key_idstringrequired- From the message.
Query parameters
client_public_key_pemstring | nulloptional- The client's RSA public key (PEM). The channel key comes back encrypted for it (
wrapped_key_b64) instead of in clear.
Returns
channelstringtenant_scopestring- The organization and project the key belongs to.
key_idstring- Send it with encrypted messages so receivers know which key to use.
key_b64string | null- The AES key (base64) — only when no
client_public_key_pemwas sent. wrapped_key_b64string | null- The AES key encrypted for your public key (base64).
wrapping_algstring | nullRSA-OAEP-SHA256.statusstringactiveorrotated.created_at_ms, expires_at_msinteger- Unix milliseconds.
Responses
- 200Success.
- 404No such key, or it was revoked.
- 401No valid session or key.
curl -s "$URL/api/v1/rt/e2ee/keys/room-42/k_9f3a2c71" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN"Response
{
"channel": "room-42",
"tenant_scope": "b2f4a1c8…:f0c3e9a2…",
"key_id": "k_9f3a2c71",
"key_b64": null,
"wrapped_key_b64": "Qm9v…",
"wrapping_alg": "RSA-OAEP-SHA256",
"status": "active",
"created_at_ms": 1792262400000,
"expires_at_ms": 1792348800000
}GET/api/v1/rt/e2ee/keys/{channel}
The channel's keys (metadata only, never the key material).
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/e2ee/keys/{channel}
Path parameters
channelstringrequired- The channel.
Returns
channelstringrequired- The channel name.
keysarray<object>optional8 fields
channelstringrequired- The channel name.
tenant_scopestringrequiredkey_idstringrequiredstatusstringrequired- One of
active,rotated,revoked,expired created_at_msintegerrequiredexpires_at_msintegerrequiredrevoked_at_msinteger | nulloptionalrevocation_reasonstring | nulloptional
Responses
- 200Success.
- 401No valid session or key.
curl -s "$URL/api/v1/rt/e2ee/keys/room-42" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN"Response
{
"channel": "room-42",
"keys": [
{
"channel": "room-42",
"tenant_scope": "b2f4a1c8…:f0c3e9a2…",
"key_id": "k_1c7e0b44",
"status": "active",
"created_at_ms": 1792265000000,
"expires_at_ms": 1792351400000,
"revoked_at_ms": null,
"revocation_reason": null
},
{
"channel": "room-42",
"tenant_scope": "b2f4a1c8…:f0c3e9a2…",
"key_id": "k_9f3a2c71",
"status": "rotated",
"created_at_ms": 1792262400000,
"expires_at_ms": 1792348800000,
"revoked_at_ms": null,
"revocation_reason": null
}
]
}#More endpoints
POST/api/v1/rt/stream/publish-batch/{channel}
Publish batch.
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/stream/publish-batch/{channel}
Path parameters
channelstringrequired- The channel name.
Responses
- 200Success.
- 401No valid session or key.
curl -s -X POST "$URL/api/v1/rt/stream/publish-batch/orders" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN"POST/api/v1/rt/stream/publish-many
One message each to many channels of one project, in one request (A14-PERF-04).
- Who
- Your app: the project's anon key (
apikey: <anon key>), with the user's access token once they are signed in. - Also at
/realtime/v1/stream/publish-many
Responses
- 200Success.
- 401No valid session or key.
curl -s -X POST "$URL/api/v1/rt/stream/publish-many" \
-H "apikey: $ANON_KEY" \
-H "Authorization: Bearer $ACCESS_TOKEN"