Create zones
Define logical zones or neighbourhoods within your workplace to group spaces and support zone-level allocations and reporting.
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
fileAn 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
:
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:
npx tsx create-zones.ts
3) (Optional) Verify zones and their spaces
List zones for your layer and see which spaces are assigned:
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:
npx tsx list-zones.ts
Last updated
Was this helpful?