Add directory people/teams

Populate your workplace directory with people and teams, then link people to their respective teams for allocations and analytics.

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) Add people

Create add-people.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.directory.createPeople({
    people: [
      { email: "[email protected]", first_name: "Alice", last_name: "Smith" },
      { email: "[email protected]", first_name: "Bob", last_name: "Nguyen" }
    ],
  });

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

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

Run:


2) Add teams

Create add-teams.ts:

Run:


3) Map people to teams (add team members)

You’ll need the team_id values from step 2 and the people_id values from step 1.

Create add-team-members.ts:

Run:

Last updated

Was this helpful?