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

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

Realtime Shared Protocol

Shared schemas and types for real-time communication protocols.

This module consolidates overlapping definitions between the transport-level

realtime protocol (SSE/Polling/WebSocket) and the WebSocket collaboration protocol.

**Architecture:**

- `realtime-shared.zod.ts` — Shared base schemas (Presence, Event types)

- `realtime.zod.ts` — Transport-layer protocol (Channel, Subscription, Transport selection)

- `websocket.zod.ts` — Collaboration protocol (Cursor, OT editing, Advanced presence)

@see realtime.zod.ts for transport-layer configuration

@see websocket.zod.ts for collaborative editing protocol

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

## TypeScript Usage

```typescript
import { BasePresence, PresenceStatus, RealtimeRecordAction } from '@objectstack/spec/api';
import type { BasePresence, PresenceStatus, RealtimeRecordAction } from '@objectstack/spec/api';

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

---

## BasePresence

### 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) |


---

## PresenceStatus

### Allowed Values

* `online`
* `away`
* `busy`
* `offline`


---

## RealtimeRecordAction

### Allowed Values

* `created`
* `updated`
* `deleted`


---

