> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vambe.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Get all team members

## Overview

Retrieve a complete list of all team members (agents) in your organization. This endpoint returns essential information about each team member including their ID, name, email, and phone number.

Use this endpoint to display team members in dropdowns, build agent assignment interfaces, or sync team data with external systems.

## Use Cases

* **Agent Assignment UI**: Populate dropdowns for assigning conversations to specific agents
* **Team Directory**: Display a list of all team members in your application
* **Reporting & Analytics**: Get agent IDs for filtering analytics by team member
* **External Integrations**: Sync team member data with external CRM or HR systems
* **Automated Workflows**: Programmatically assign tasks or tickets to specific team members
* **Team Management**: Build custom team management interfaces

## Authentication

This endpoint requires authentication using an API key. Include your API key in the request header:

```
x-api-key: your_api_key_here
```

## Response Structure

The endpoint returns an array of team member objects:

### Team Member Object

| Field        | Type          | Description                           |
| ------------ | ------------- | ------------------------------------- |
| `id`         | string (UUID) | Unique identifier for the team member |
| `name`       | string        | Full name (first name + last name)    |
| `first_name` | string        | Team member's first name              |
| `last_name`  | string        | Team member's last name               |
| `email`      | string        | Team member's email address           |
| `phone`      | string        | Team member's phone number            |

## Example Response

```json theme={null}
[
  {
    "id": "228d7a0d-9072-4ca8-939b-959b75cc606a",
    "name": "Maria Rodriguez",
    "first_name": "Maria",
    "last_name": "Rodriguez",
    "email": "maria.rodriguez@company.com",
    "phone": "+56912345678"
  },
  {
    "id": "338e8b1e-8183-5db9-a4ab-a6ab86dd717b",
    "name": "Carlos Silva",
    "first_name": "Carlos",
    "last_name": "Silva",
    "email": "carlos.silva@company.com",
    "phone": "+56987654321"
  },
  {
    "id": "448f9c2f-9294-6eca-b5bc-b7bc97ee828c",
    "name": "Ana Martinez",
    "first_name": "Ana",
    "last_name": "Martinez",
    "email": "ana.martinez@company.com",
    "phone": "+56911223344"
  }
]
```

## Common Use Cases

### 1. Populate Agent Selection Dropdown

```javascript theme={null}
const loadTeamMembers = async () => {
  const response = await fetch(
    'https://api.vambe.me/api/public/team-members/all',
    {
      headers: {
        'x-api-key': 'your_api_key_here',
      },
    },
  );

  const teamMembers = await response.json();

  // Convert to dropdown options
  const agentOptions = teamMembers.map((member) => ({
    value: member.id,
    label: member.name,
    email: member.email,
  }));

  return agentOptions;
};

// Use in a select component
// <Select options={agentOptions} onChange={handleAgentSelect} />
```

### 2. Find Team Member by Email

```javascript theme={null}
const findTeamMemberByEmail = async (emailToFind) => {
  const response = await fetch(
    'https://api.vambe.me/api/public/team-members/all',
    {
      headers: {
        'x-api-key': 'your_api_key_here',
      },
    },
  );

  const teamMembers = await response.json();

  const member = teamMembers.find(
    (m) => m.email.toLowerCase() === emailToFind.toLowerCase(),
  );

  if (member) {
    console.log(`Found: ${member.name} (ID: ${member.id})`);
    return member;
  } else {
    console.log('Team member not found');
    return null;
  }
};
```

### 3. Display Team Directory

```javascript theme={null}
const displayTeamDirectory = async () => {
  const response = await fetch(
    'https://api.vambe.me/api/public/team-members/all',
    {
      headers: {
        'x-api-key': 'your_api_key_here',
      },
    },
  );

  const teamMembers = await response.json();

  // Group by first letter of last name
  const groupedByLastName = teamMembers.reduce((acc, member) => {
    const firstLetter = member.last_name[0].toUpperCase();
    if (!acc[firstLetter]) {
      acc[firstLetter] = [];
    }
    acc[firstLetter].push(member);
    return acc;
  }, {});

  console.log('Team Directory:', groupedByLastName);
  return groupedByLastName;
};
```

### 4. Get Team Member Count and Stats

```javascript theme={null}
const getTeamStats = async () => {
  const response = await fetch(
    'https://api.vambe.me/api/public/team-members/all',
    {
      headers: {
        'x-api-key': 'your_api_key_here',
      },
    },
  );

  const teamMembers = await response.json();

  const stats = {
    totalMembers: teamMembers.length,
    membersWithPhone: teamMembers.filter((m) => m.phone).length,
    emailDomains: [...new Set(teamMembers.map((m) => m.email.split('@')[1]))],
  };

  console.log('Team Statistics:', stats);
  return stats;
};
```

### 5. Sync with External System

```javascript theme={null}
const syncTeamMembersToExternalCRM = async () => {
  const response = await fetch(
    'https://api.vambe.me/api/public/team-members/all',
    {
      headers: {
        'x-api-key': 'your_api_key_here',
      },
    },
  );

  const teamMembers = await response.json();

  // Sync to external CRM
  for (const member of teamMembers) {
    await fetch('https://external-crm.com/api/users/sync', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        Authorization: 'Bearer external_crm_token',
      },
      body: JSON.stringify({
        external_id: member.id,
        name: member.name,
        email: member.email,
        phone: member.phone,
        source: 'vambe',
      }),
    });
  }

  console.log(`Synced ${teamMembers.length} team members to external CRM`);
};
```

### 6. Build Assignment Interface

```javascript theme={null}
const buildAssignmentInterface = async (contactId) => {
  const response = await fetch(
    'https://api.vambe.me/api/public/team-members/all',
    {
      headers: {
        'x-api-key': 'your_api_key_here',
      },
    },
  );

  const teamMembers = await response.json();

  // Display team members with assign button
  return teamMembers.map((member) => ({
    id: member.id,
    name: member.name,
    email: member.email,
    assignAction: async () => {
      // Use the assign endpoint
      await fetch(
        `https://api.vambe.me/api/public/contact/${contactId}/assign-team-member/${member.id}`,
        {
          method: 'POST',
          headers: {
            'x-api-key': 'your_api_key_here',
          },
        },
      );
      console.log(`Assigned ${member.name} to contact ${contactId}`);
    },
  }));
};
```

## Response Characteristics

* **Array Format**: Always returns an array, even if empty
* **Alphabetical Order**: Team members are returned in the order they exist in the database (not sorted)
* **Active Members Only**: Only returns active team members (not deactivated accounts)
* **Organization Scoped**: Returns only team members from your organization

## Error Responses

| Status Code | Description                                  |
| ----------- | -------------------------------------------- |
| 401         | Unauthorized - Invalid or missing API key    |
| 404         | Not Found - No team members found            |
| 500         | Internal Server Error - Something went wrong |

## Performance Tips

* **Cache the Results**: Team member lists typically don't change frequently - consider caching for 5-10 minutes
* **Client-side Filtering**: After fetching all members, filter on the client side rather than making multiple API calls
* **Lazy Loading**: For large teams, consider implementing pagination on the frontend
* **Update on Changes**: Refresh the list when team members are added or removed

## Related Endpoints

* [POST /api/public/contact/{aiContactId}/assign-team-member/{teamMemberId}](/reference/team-members/assign-team-member-to-contact) - Assign a team member to a contact
* [GET /api/public/contact/{aiContactId}/info](/reference/contact/get-info-of-an-ai-contact) - Get contact info including assigned agents

## Notes

* **Team Member vs Agent**: These terms are used interchangeably - a team member is any user who can be assigned to conversations
* **Role Information**: This endpoint doesn't return role/permission information - it only returns basic contact details
* **ID Format**: Team member IDs are UUIDs that can be used with the assignment endpoint
* **Name Concatenation**: The `name` field is automatically generated from `first_name + ' ' + last_name`


## OpenAPI

````yaml get /api/public/team-members/all
openapi: 3.0.0
info:
  title: Vambe AI API
  description: Vambe AI documentation
  version: '1.0'
  contact: {}
servers:
  - url: https://api.vambe.me
    description: Production Server
security: []
tags:
  - name: Vambe AI
    description: ''
paths:
  /api/public/team-members/all:
    get:
      tags:
        - Team Members
      summary: Get all team members
      operationId: PublicAgentController_getAllTeamMembers
      parameters:
        - name: x-api-key
          in: header
          description: API key needed to authorize the request
          required: true
          schema:
            type: string
      responses:
        '200':
          description: All team members found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserEntity'
        '404':
          description: Team member not found or profile not public.
components:
  schemas:
    UserEntity:
      type: object
      properties: {}

````