Create a location
Add a new location in gospace to represent a physical site or office, providing the foundation for layers, spaces, and allocations.
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
1. Create the script
Create create-location.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.createLocations({
locations: [
{
name: "New Office",
country: {
country_id: "GB_ID",
name: "United Kingdom",
iso2: "GB",
selected_timezone: "Europe/London",
timezones: ["Europe/London"],
},
address: {
postal_code: "EC2V 6DN",
country_name: "UK",
line1: "1 Example St",
line2: "Suite 100",
},
coords: { latitude: 51.514, longitude: -0.093 },
external_id: "new-office-1",
},
],
});
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-location.ts
Last updated
Was this helpful?