Skip to main content
The Realtime API allows you to subscribe to real-time updates for record changes using Server-Sent Events (SSE).

Connect to realtime

Establish a realtime SSE connection.
Authentication: Optional (unauthenticated connections are guests) This endpoint establishes a persistent SSE connection that remains open to receive real-time messages.

Response

The connection returns Server-Sent Events in the following format:
string
Unique client connection identifier returned in the initial PB_CONNECT event

Set subscriptions

Subscribe to specific topics to receive real-time updates.
Authentication: Optional (but required to upgrade guest connection to authenticated)

Request body

string
required
The client ID from the initial connection (returned in PB_CONNECT)
array
required
Array of subscription topics (max 1000 subscriptions, each max 2500 chars)

Subscription topics

You can subscribe to: Individual record:
All records in collection:
Collection name or ID:
With filters and options: Append query parameters to subscription topics:

Response

Returns 204 No Content on success.

Realtime events

When subscribed, you’ll receive events when records change:

Event structure

string
The type of change: create, update, or delete
object
The affected record data (respects API rules and field permissions)

Example event

Client-side subscriptions

JavaScript example

Access control

Realtime subscriptions respect collection API rules:
  • listRule - For wildcard subscriptions (posts/*)
  • viewRule - For specific record subscriptions (posts/RECORD_ID)
Users only receive updates for records they have permission to view based on the collection’s API rules.

Authentication state

You can upgrade a guest connection to authenticated:
  1. Establish SSE connection (guest)
  2. Make POST request to /api/realtime with auth token
  3. Subscription permissions are updated based on the auth record
You cannot change authentication from one user to another. Downgrading from authenticated to guest is also not allowed.

Subscription options

Add query parameters to subscription topics:

Filter

Only receive events for records matching the filter:

Expand

Automatically expand relation fields:

Fields

Limit fields included in the event:

Combined options

Connection management

Idle timeout

Connections automatically close after 5 minutes of inactivity (no events sent). The client should reconnect and resubscribe.

Reconnection

When the connection drops:
  1. Establish a new realtime connection
  2. Get new clientId from PB_CONNECT event
  3. Resubmit all subscriptions

Unsubscribing

To change subscriptions, send a new subscription list. Previous subscriptions are automatically cleared:

Performance considerations

  • Maximum 1000 subscriptions per client
  • Each subscription topic max 2500 characters
  • Realtime events are processed in chunks of 150 clients

Best practices

  1. Subscribe to specific collections rather than all records
  2. Use filters to reduce event volume
  3. Limit fields to only what you need
  4. Close connections when not needed
  5. Implement reconnection logic

Common use cases

Chat application

User notifications

Live dashboard

Collaborative editing