> **Photon Beta documentation**
> Browse all pages: https://photon.codes/docs/beta/llms.txt
> Search Beta docs via MCP: https://photon.codes/docs/beta/mcp (OAuth REST API MCP: https://mcp.photon.codes/mcp)

# Start a session

> Subscribe once on each connection and read the accepted limits.

On every `connect`, emit `subscribe` with your saved `startSeq` and an acknowledgement callback. A successful acknowledgement arrives before deliveries and includes the selected project, API version, connection ID, accepted cursor, and limits.

Include `apiVersion` to pin a selectable customer contract date, or omit it to use
the service default. Use the date returned by the acknowledgement when interpreting
projected events. Resend your chosen date on every reconnect. An unavailable date
returns `frame_invalid`; correct it and subscribe again before the connection's
subscription deadline. Already-public events retain their original envelope.

```ts
socket.on("connect", () => {
  socket.timeout(10_000).emit("subscribe", { startSeq: savedCursor, apiVersion: "2026-07-01" }, (error, result) => {
    if (error) { socket.io.engine.close(); return; }
    if (!result.ok) { console.error(result.error.code); return; }
    console.info("Subscribed", result.connectionId, result.apiVersion);
  });
});
```

Send one subscription per connection. A repeated subscription is rejected while the existing stream continues. Subscribe promptly; an idle connection that never subscribes is closed.

Read `limits.maxFrameBytes` and `limits.maxReplyBodyBytes` from the acknowledgement. Size reply payloads against these limits. Socket.IO manages heartbeat timing internally.

The connection ID is assigned by Socket.IO and changes after reconnection. Use it to correlate delivery diagnostics. See [Cursors and replay](/docs/beta/api-reference/websocket/cursors.md) before saving a cursor.
