---
title: Realtime
description: Realtime protocol schemas
---

{/* ⚠️  AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs go in content/docs/guides/. */}

Transport Protocol Enum

Defines the communication protocol for realtime data synchronization

<Callout type="info">
**Source:** `packages/spec/src/api/realtime.zod.ts`
</Callout>

## TypeScript Usage

```typescript
import { RealtimeConfig, RealtimeEvent, RealtimeEventType, RealtimePresence, Subscription, SubscriptionEvent, TransportProtocol } from '@objectstack/spec/api';
import type { RealtimeConfig, RealtimeEvent, RealtimeEventType, RealtimePresence, Subscription, SubscriptionEvent, TransportProtocol } from '@objectstack/spec/api';

// Validate data
const result = RealtimeConfig.parse(data);
```

---

## RealtimeConfig

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **enabled** | `boolean` | ✅ | Enable realtime synchronization |
| **transport** | `Enum<'websocket' \| 'sse' \| 'polling'>` | ✅ | Transport protocol |
| **subscriptions** | `Object[]` | optional | Default subscriptions |


---

## RealtimeEvent

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **id** | `string` | ✅ | Unique event identifier |
| **type** | `string` | ✅ | Event type (e.g., record.created, record.updated) |
| **object** | `string` | optional | Object name the event relates to |
| **action** | `Enum<'created' \| 'updated' \| 'deleted'>` | optional | Action performed |
| **payload** | `Record<string, any>` | ✅ | Event payload data |
| **timestamp** | `string` | ✅ | ISO 8601 datetime when event occurred |
| **userId** | `string` | optional | User who triggered the event |
| **sessionId** | `string` | optional | Session identifier |


---

## RealtimeEventType

### Allowed Values

* `record.created`
* `record.updated`
* `record.deleted`
* `field.changed`


---

## RealtimePresence

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **userId** | `string` | ✅ | User identifier |
| **status** | `Enum<'online' \| 'away' \| 'busy' \| 'offline'>` | ✅ | Current presence status |
| **lastSeen** | `string` | ✅ | ISO 8601 datetime of last activity |
| **metadata** | `Record<string, any>` | optional | Custom presence data (e.g., current page, custom status) |


---

## Subscription

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **id** | `string` | ✅ | Unique subscription identifier |
| **events** | `Object[]` | ✅ | Array of events to subscribe to |
| **transport** | `Enum<'websocket' \| 'sse' \| 'polling'>` | ✅ | Transport protocol to use |
| **channel** | `string` | optional | Optional channel name for grouping subscriptions |


---

## SubscriptionEvent

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **type** | `Enum<'record.created' \| 'record.updated' \| 'record.deleted' \| 'field.changed'>` | ✅ | Type of event to subscribe to |
| **object** | `string` | optional | Object name to subscribe to |
| **filters** | `any` | optional | Filter conditions |


---

## TransportProtocol

### Allowed Values

* `websocket`
* `sse`
* `polling`


---

