> ## Documentation Index
> Fetch the complete documentation index at: https://docs.myworklayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rooms

> Isolate conversations inside a factory—one Room per ticket, customer, or work item—and read each conversation's history.

A **Room** is an isolated conversation between your application and a factory. Typically you create one Room per work object—such as an issue, support ticket, customer, or incident—so separate threads of work never bleed into each other.

```bash theme={null}
curl -X POST "https://api.myworklayer.com/v1/rooms"   -H "Authorization: Bearer $WORKLAYER_API_KEY"   -H "Content-Type: application/json"   -d '{"name": "Ticket 4821", "externalKey": "zendesk-ticket-4821"}'
```

The response returns the Room's `id`. All conversation endpoints are scoped under `/v1/rooms/{roomId}/...`.

## Design your interface first, then map to Rooms

Don't start by designing Room topology in the abstract. Define the interface and work objects your users need first—for example, an issue dashboard where each row has an impact score, a **"Fix with Agent"** button, PR status, and rollback actions—then let your coding agent map each work object to a Room using `externalKey`:

* **One Room per work item** (issue, ticket, PR, incident) keeps history, Events, and Workers cleanly scoped to that item.
* **One Room per customer or workspace** works well when every interaction for that customer should share ongoing thread context.
* **Rooms never message each other directly.** Keep Rooms strictly isolated and route each Event to the Room that owns that work item.

## Isolation vs. shared factory state

![Room isolation vs. shared factory state: Ticket 4821 and Ticket 4822 keep history, Events, notes, and Workers isolated while sharing apps, skills, memory, files, and databases.](https://mintcdn.com/worklayer-17401167/cpUXFKQRIMsNdzrq/images/diagrams/rooms-isolation-light.svg?fit=max\&auto=format\&n=cpUXFKQRIMsNdzrq\&q=85\&s=b5ec352ed0475ebad82e371fa865c878)

Every Room you create keeps its own:

* **History:** the user-visible conversation log. See [Room History](#room-history).
* **Events:** everything your app sent to this Room. See [Events](https://docs.myworklayer.com/events.md).
* **Notes:** a short working summary the factory maintains for this conversation—such as ticket status and customer details.
* **Workers:** the background tasks spawned from this Room. See [Workers](https://docs.myworklayer.com/workers.md).

API-created Rooms cannot see or message one another. A Room has no access to another Room's history, Events, notes, or Workers, so work on Issue #4821 never leaks context from Issue #4822.

At the same time, every Room shares the factory's **[connected apps](https://docs.myworklayer.com/apps.md), skills, long-term memory, files, and databases**. Room notes stay scoped to a single Room; factory memory and files are shared across the factory.

> [!WARNING]
>
> Anything the factory writes to factory-level memory or files can be read from any Room. The factory stores conversation-specific details in Room notes, but don't rely on Room isolation to protect data saved to shared factory memory or files.

## The main Room

Every factory also includes a **main Room**—the default workspace used in the Worklayer web app, targeted with `roomId` set to `web`:

```bash theme={null}
curl "https://api.myworklayer.com/v1/rooms/web/workers"   -H "Authorization: Bearer $WORKLAYER_API_KEY"
```

Unlike isolated API Rooms, the main Room (`web`) provides read-only visibility across the factory: `GET /v1/rooms/web/workers` lists Workers across all Rooms, and the web workspace can inspect Events and notes from other Rooms (read-only—it cannot modify another Room's notes or message another Room directly).

Use `web` for factory-wide visibility—such as an activity overview or checking every active Worker—and create dedicated API Rooms with `POST /v1/rooms` for per-item workflows so unrelated tasks stay cleanly isolated.

Slack conversations run in their own isolated Rooms as well, though they are not exposed through `/v1/rooms` today. See [Channels](https://docs.myworklayer.com/channels.md).

## Idempotent Room creation with externalKey

`POST /v1/rooms` accepts two optional fields:

* `name` — display name (1 to 191 characters).
* `externalKey` — your own unique identifier, such as a help desk ticket ID (1 to 191 visible ASCII characters). If omitted, Worklayer generates one automatically.

If a Room with the same `externalKey` already exists, the API returns `409 Conflict` along with its `roomId`:

```json theme={null}
{
  "statusCode": 409,
  "error": "Conflict",
  "message": "A Room with this externalKey exists.",
  "roomId": "cmhx3q7v20004l808sd5k2r1m"
}
```

This makes "find or create" straightforward: call `POST /v1/rooms` with your ticket's `externalKey` and use the `roomId` from either `201 Created` or `409 Conflict`. Archived Rooms retain their `externalKey`, so a `409` may reference an archived Room.

## Manage Rooms

* **List Rooms:** `GET /v1/rooms` returns the main Room and all active (non-archived) API Rooms, ordered by most recent activity (`limit`: 1–50, default `20`).
* **Rename a Room:** `PATCH /v1/rooms/{roomId}` updates `name`. Pass `{"name": null}` to clear it.
* **Archive a Room:** `DELETE /v1/rooms/{roomId}` archives the Room and returns `204 No Content`. Archived Rooms no longer appear in `GET /v1/rooms`, and all routes for that Room return `404`.

Renaming and archiving apply only to Rooms you created. Calling either on the main Room (`web`) returns `403 Forbidden`.

## Room History

Fetch a Room's conversation log with `GET /v1/rooms/{roomId}/history`:

```bash theme={null}
curl "https://api.myworklayer.com/v1/rooms/$ROOM_ID/history"   -H "Authorization: Bearer $WORKLAYER_API_KEY"
```

```json theme={null}
{
  "messages": [
    {
      "id": "cmhx3r0a10007l808m2c4t9xw",
      "kind": "event",
      "text": "Ticket 4821 from Dana Lee: I was charged twice for order 1188. Please refund one charge.",
      "createdAt": "2026-11-19T17:41:02.118Z",
      "eventId": "b7e4c1d2-8a3f-4f6e-9d20-5c1a7e9b3f08"
    },
    {
      "id": "toolu_01HbW7q2Lk9sVd3XnR8cPz4m",
      "kind": "response",
      "text": "I refunded the duplicate charge for order 1188 and notified Dana Lee.",
      "createdAt": "2026-11-19T17:52:08.311Z"
    }
  ],
  "nextCursor": "cmhx3q9f80005l8086b1n0d4k"
}
```

| `kind` | Description |
| - | - |
| `user` | A message sent by a person—for example, in the [main Room](#the-main-room). |
| `event` | An [Event](https://docs.myworklayer.com/events.md) received by the factory, including its `eventId`. Appears for every delivery mode, including `context`. |
| `response` | A reply from the factory. Its `id` matches the `messageId` delivered in the `room.response` [Subscription event](https://docs.myworklayer.com/subscriptions.md). |

Room History focuses on user-visible conversation. It intentionally omits:

* Internal factory reasoning and tool calls.
* Worker-to-factory completion reports (inspect individual Worker transcripts with [Get Worker Messages](https://docs.myworklayer.com/workers.md#follow-progress)).
* Message reactions.

A brand-new Room with no activity returns an empty `messages` array. Room History is **read-only**—to send new input to the factory, send an [Event](https://docs.myworklayer.com/events.md).

## Pagination

In Room History, the first page contains the most recent entries (ordered oldest-first within the page), and `nextCursor` walks backward to older pages.

All paginated endpoints in the Factory API follow the same cursor pattern:

**1. Request a page**

Pass an optional `limit` to control page size. Omit it to use the endpoint default.

**2. Check nextCursor**

When `nextCursor` is `null`, you have reached the end of the list.

**3. Fetch the next page**

Repeat the exact same request with `cursor` set to the previous response's `nextCursor`.

| Endpoint | `limit` range | Default | Ordering |
| - | - | - | - |
| List Rooms | 1–50 | 20 | Most recent activity first |
| Get Room History | 1–100 | 30 | Newest page first; oldest-first within each page |
| List Workers | 1–100 | 30 | Most recent activity first |
| Get Worker Messages | 1–100 | 30 | Controlled by `order` (`asc` or `desc`) |

Treat cursors as opaque tokens—never construct or modify them. A cursor is bound to the exact request that produced it (the same Room, and for Workers, the same `status` or `order`). Passing a mismatched or invalid cursor returns `400` with `Invalid cursor for this request.`

On Worker list endpoints, a page may return fewer items than `limit` while still returning a non-null `nextCursor`. Keep paging until `nextCursor` is `null`.

> [card] [Events](https://docs.myworklayer.com/events.md)
>
> Send activity into a Room and control delivery timing.

> [card] [Subscriptions](https://docs.myworklayer.com/subscriptions.md)
>
> Receive signed webhooks the moment the factory replies.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.