> For the complete documentation index, see [llms.txt](https://developer.gospace.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.gospace.com/start-building/create-a-location/create-a-layer/create-rooms.md).

# Create rooms

Add rooms (e.g., meeting rooms, focus rooms) to your workplace layers, linked to specific spaces for usage and booking.

{% tabs %}
{% tab title="Node.js" %}

### Prerequisites

* Completed **Setup Your Development Environment** and **Send Your First API Request**
* Node.js v18+ and npm v9+
* A valid gospace API key in your `.env` file
* An existing **location\_id** and **layer\_id** (rooms belong to a layer)
* One or more **space\_id** values (spaces must already exist before you can assign them to a room)

***

### 1) Create the script

Create `create-room.ts`:

```ts
import "dotenv/config";
import GospaceAI from "@gospace-ai/api";

async function main() {
  const gospace = new GospaceAI(process.env.GOSPACE_API_KEY!);

  const res = await gospace.spatial.createRooms({
    rooms: [
      {
        layer_id: "layer_123",          // required: the layer this room belongs to
        name: "Conference Room A",      // required: room name
        spaces: ["space_001", "space_002"], // assign existing space IDs
        // external_id: "conf-a",        // optional
      },
      {
        layer_id: "layer_123",
        name: "Focus Room 1",
        spaces: ["space_003"],          // single space assigned to the room
      }
    ],
  });

  console.log(JSON.stringify(res.data, null, 2));
}

main().catch((err) => {
  console.error("Request failed:", err);
  process.exit(1);
});
```

***

### 2) Run the script

With TypeScript:

```bash
npx tsx create-room.ts
```

***

### 3) (Optional) Verify rooms and their spaces

List rooms for your layer and see which spaces are assigned:

```ts
import "dotenv/config";
import GospaceAI from "@gospace-ai/api";

async function main() {
  const gospace = new GospaceAI(process.env.GOSPACE_API_KEY!);
  const res = await gospace.spatial.getRooms({
    layer_id: "layer_123",
    skip: 0,
    limit: 50,
  });
  console.log(JSON.stringify(res.data.rooms, null, 2));
}

main().catch(console.error);
```

Run:

```bash
npx tsx list-rooms.ts
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.gospace.com/start-building/create-a-location/create-a-layer/create-rooms.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
