# Named actor rooms

Connect multiple clients to one named room. The room receives messages, sends to selected connections and broadcasts events to all connected clients.

```javascript
await this.send(recipientId, message);
await this.broadcast("build:finished");
```

These calls enqueue messages. The application controls client authentication and decides what to save on disk.

## Register a room endpoint

Bundle and deploy the workspace's `examples/landing-room/worker.js` on Cloudflare Workers. Set its `WABE_ACTOR_ENDPOINT_SECRET` to a random base64url value. The Worker accepts broker connections at `/wabe`. Register the public HTTPS URL directly with your project key.

Create a project API key in [Dashboard](https://dashboard.wabe.sh). Replace `YOUR_PROJECT_API_KEY`, `https://your-worker.example/wabe` and `YOUR_ENDPOINT_SECRET` before running these requests.

```sh
curl --fail-with-body -X PUT "https://api.wabe.sh/v1/disks/chat-state" \
  -H "Authorization: Bearer YOUR_PROJECT_API_KEY"

curl --fail-with-body "https://api.wabe.sh/v1/actor" \
  -H "Authorization: Bearer YOUR_PROJECT_API_KEY" \
  --json "$(jq -n --arg endpoint "https://your-worker.example/wabe" \
    --arg secret "YOUR_ENDPOINT_SECRET" \
    '{name:"rooms",disk:"chat-state",endpoint:$endpoint,endpointSecret:$secret}')"
```

Replace `{instance}` in the returned `fetchUrlTemplate` with `project-room` and connect using `wss:`. All clients using that actor ID and instance name share one live room. Each room saves its latest text message to the disk's `rooms` KV namespace under its instance name. A new connection receives the saved message, including after the room restarts.

The gateway resolves the hostname at activation, accepts only public addresses, verifies TLS and rejects redirects. It returns 503 if it cannot activate the endpoint.

This example admits public clients. Keep the project key and endpoint secret on the server.
