platform-api
Realtime Subscriptions
Overview
OrbioCloud Realtime lets you subscribe to live data changes in your collections. The SDK generates a tenant-scoped authentication token for real-time connections. Security policies ensure tenants only see their own data.
Get a Realtime Token
// User must be signed in
const { token, expires_at, expires_in } = await orbio.getRealtimeToken();
// token: authenticated JWT (1 hour expiry)
// expires_in: 3600 (seconds)Subscribe to Changes
Use the realtime token to connect and listen for data changes:
const { token } = await orbio.getRealtimeToken();
// Connect to OrbioCloud Realtime using the token
// Listen for inserts, updates, and deletes on your collections
// The token includes your tenant_id for automatic data isolationToken Refresh
// Tokens expire after 1 hour — refresh before expiry
setInterval(async () => {
const { token } = await orbio.getRealtimeToken();
// Reconnect with new token
}, 50 * 60 * 1000); // Refresh at 50 minutesToken Claims
The realtime token includes these claims for data isolation:
sub — Your user ID
tenant_id — Your tenant ID (automatic data filtering)
user_type — platform (identifies platform API users)
role — authenticated (required for data access)
Security
All realtime connections are authenticated and tenant-scoped
Row-level security ensures you only receive events for your own data
Tokens are short-lived (1 hour) — refresh regularly