> 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-zones.md).

# Create zones

Define logical zones or neighbourhoods within your workplace to group spaces and support zone-level allocations and reporting.

{% 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** (zones belong to a layer)
* One or more **space\_id** values (spaces must already exist before you can assign them to a zone)

***

### 1) Create the script

Create `create-zones.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.createZones({
    zones: [
      {
        layer_id: "layer_123",             // required: the layer this zone belongs to
        name: "Quiet Zone",                // required: zone name
        spaces: ["space_101", "space_102"],// assign existing space IDs
        // external_id: "quiet-zone",       // optional
      },
      {
        layer_id: "layer_123",
        name: "Collaboration Zone",
        spaces: ["space_103", "space_104", "space_105"],
      }
    ],
  });

  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-zones.ts
```

***

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

List zones 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.getZones({
    layer_id: "layer_123",
    skip: 0,
    limit: 50,
  });
  console.log(JSON.stringify(res.data.zones, null, 2));
}

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

Run:

```bash
npx tsx list-zones.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-zones.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.
