# Add directory people/teams

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

{% 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

***

### 1) Add people

Create `add-people.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.directory.createPeople({
    people: [
      { email: "alice@example.com", first_name: "Alice", last_name: "Smith" },
      { email: "bob@example.com", 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:

```bash
npx tsx add-people.ts
```

***

### 2) Add teams

Create `add-teams.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.directory.createTeams({
    teams: [
      { team_name: "Engineering" },
      { team_name: "People Operations" }
    ],
  });

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

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

Run:

```bash
npx tsx add-teams.ts
```

***

### 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`:

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

const TEAM_ID = "team_123"; // replace with your real team_id

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

  await gospace.directory.addTeamMembers(TEAM_ID, {
    members: [
      { people_id: "person_abc" },
      { people_id: "person_def" },
    ],
  });

  console.log("Members added.");
}

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

Run:

```bash
npx tsx add-team-members.ts
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://developer.gospace.com/start-building/add-directory-people-teams.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
