# ws.room.open

Opens the room --room (an exact name, e.g

# ws.room.open

```
ws.room.open --room TEXT [--private] [--max-sessions N] [--meta JSON] [--idle DURATION] [--hold DURATION] [--max-state SIZE] → room
```

Opens the room `--room` (an exact name, e.g. `match-{{ Date.now() }}`) under an active [`trigger.room`](/nodes/trigger/trigger.room.md) pattern (`match-:id`) — no visitor can make a room by naming one. Refused for a name no active pattern matches, for a fixed room's name and for a room already open. `--private` admits only holders of a [`ws.ticket.create`](/nodes/ws/ws.ticket.create.md) ticket; `--max-sessions` (default 1000, at most 10000) caps the room, a join past it closing with 4429; `--meta` is a small JSON object [`ws.room.list`](/nodes/ws/ws.room.list.md) shows (what matchmaking filters on); `--idle` (default 10m) closes the room after it has sat empty that long; `--hold` keeps the seat of a session whose connection drops (`$away`; `joined` gave it a `resume` token, and reconnecting with `?resume=` within the hold gives back the same session and raises `$back`, else `$disconnect { reason: "timeout" }`); `--max-state` (default 1MB, at most 16MB) caps the room's state, a write past it refused. Adds `room` — the room as [`ws.room.list`](/nodes/ws/ws.room.list.md) shows it — and keeps the rest of the payload.

## Flags

- `--room` (required): The room's name: 1–128 of letters, digits, '-', '_', '.', matched by an active trigger.room pattern.
- `--private`: Admit only holders of a ws.ticket.create ticket.
- `--max-sessions`: The most sessions at once (default 1000, at most 10000); a join past it closes with 4429.
- `--meta`: A small JSON object ws.room.list shows: mode, map, level band.
- `--idle`: Close the room after it has sat empty this long (default 10m, 1s–24h).
- `--hold`: Keep the seat of a session whose connection drops this long (1s–1h), for its socket to resume with ?resume=.
- `--max-state`: The most bytes of room state (default 1MB, at most 16MB); a write past it is refused.

## Examples

### Open a private match for ten

```
| ws.room.open --room "match-{{ Date.now() }}" --private --max-sessions 10 --meta "{{ { mode: 'ranked', map: 'valley' } }}"
```

Needs an active `trigger.room --room "match-:id"`. Then `| ws.ticket.create --room "{{ input.room.room }}" --user "{{ $trigger.auth.sub }}"` lets a player in.

It answers:

```json
{
  "room": {
    "room": "match-1760601600000",
    "kind": "opened",
    "private": true,
    "mode": "event",
    "meta": {
      "mode": "ranked",
      "map": "valley"
    },
    "sessions": 0,
    "max_sessions": 10,
    "opened_at": "2026-10-16T08:00:00Z",
    "opened_by": "pipelines/matches/open",
    "last_activity_at": "2026-10-16T08:00:00Z",
    "state_bytes": 2,
    "counters": {
      "messages_in": 0,
      "messages_out": 0,
      "ticks": 0,
      "tick_overruns": 0,
      "inputs_dropped": 0,
      "pipeline_runs": 0,
      "pipeline_errors": 0,
      "resyncs": 0,
      "flood_closes": 0
    }
  }
}
```

## Used in

- [Forum with Real-Time Chat](/examples/forum-with-chat.md)
- [Real-Time Game (WebSocket State Sync)](/examples/realtime-game.md)
