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

# REST API endpoints for managing users and team members

> List your team, invite new users by email and role, update user profiles and permissions, and remove members. Most endpoints require admin or owner role.

The users and invites endpoints give you programmatic control over your LeadScout team. You can list current members, invite new reps or admins by email, update a user's role and permissions, and remove users who have left the team. Most of these endpoints require the `admin` or `owner` role — a `sales` user can read the team list but cannot manage it.

## List team members

```
GET /api/users
```

Returns all active (non-deleted) users in your company, ordered newest first.

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://app.leadscoutapp.com/api/users \
    --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://app.leadscoutapp.com/api/users', {
    headers: { Authorization: `Bearer ${accessToken}` },
  });
  const users = await response.json();
  ```
</CodeGroup>

### Response

Returns an array of user objects directly.

<ResponseField name="id" type="number">User ID.</ResponseField>
<ResponseField name="firstName" type="string">First name.</ResponseField>
<ResponseField name="lastName" type="string">Last name.</ResponseField>
<ResponseField name="email" type="string">Email address.</ResponseField>
<ResponseField name="phoneNumber" type="string | null">Phone number.</ResponseField>
<ResponseField name="role" type="string">`owner`, `admin`, or `sales`.</ResponseField>
<ResponseField name="canManageProspects" type="boolean">Whether this user can perform prospect management actions regardless of role.</ResponseField>
<ResponseField name="canManageTags" type="boolean">Whether this user can create and modify tags regardless of role.</ResponseField>
<ResponseField name="isPrimary" type="boolean">Whether this is the primary account holder.</ResponseField>
<ResponseField name="timeZone" type="string | null">IANA time zone string.</ResponseField>
<ResponseField name="autoDetectTimeZone" type="boolean">Whether the app auto-detects the user's time zone.</ResponseField>
<ResponseField name="workingHoursStart" type="string | null">Start of working hours (e.g. `"08:00"`).</ResponseField>
<ResponseField name="workingHoursEnd" type="string | null">End of working hours (e.g. `"17:00"`).</ResponseField>
<ResponseField name="bufferMinutes" type="number | null">Appointment buffer time in minutes.</ResponseField>
<ResponseField name="use24HourFormat" type="boolean">Whether the user prefers 24-hour time display.</ResponseField>
<ResponseField name="showAllEvents" type="boolean">Whether the user's calendar shows all company events.</ResponseField>
<ResponseField name="createdAt" type="string">ISO 8601 creation timestamp.</ResponseField>

***

## Invite a user

```
POST /api/invites
```

<Note>
  Inviting users requires the `admin` or `owner` role. Requests from `sales` users return `403`.
</Note>

Sends an invitation for a new team member. The invite is stored and the invitee receives an email with instructions to complete sign-up. You can only invite users with the `admin` or `sales` role — the `owner` role cannot be assigned through invitations.

### Request body

<ParamField body="firstName" type="string" required>
  Invitee's first name.
</ParamField>

<ParamField body="lastName" type="string" required>
  Invitee's last name.
</ParamField>

<ParamField body="email" type="string" required>
  Must be a valid email address. Used as the login identifier.
</ParamField>

<ParamField body="phoneNumber" type="string">
  Optional phone number for the invitee.
</ParamField>

<ParamField body="role" type="string" required>
  Role to grant on acceptance. Must be `admin` or `sales`.
</ParamField>

<ParamField body="expiresAt" type="string">
  ISO 8601 timestamp after which the invite link expires. If omitted, the invite does not expire.
</ParamField>

Returns `201` with the created invite object on success.

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://app.leadscoutapp.com/api/invites \
    --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
    --header 'Content-Type: application/json' \
    --data '{
      "firstName": "Alex",
      "lastName": "Rivera",
      "email": "alex.rivera@example.com",
      "role": "sales",
      "expiresAt": "2024-12-31T23:59:59Z"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://app.leadscoutapp.com/api/invites', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${accessToken}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      firstName: 'Alex',
      lastName: 'Rivera',
      email: 'alex.rivera@example.com',
      role: 'sales',
      expiresAt: '2024-12-31T23:59:59Z',
    }),
  });
  const invite = await response.json();
  ```
</CodeGroup>

***

## Update a user

```
PATCH /api/users/:id
```

<Note>
  Updating another user's role or permissions (`role`, `isPrimary`, `canManageTags`, `canManageProspects`) requires the `canManageTeam` permission, which is granted to `admin` and `owner` roles. Users can update their own profile fields (name, email, phone, time zone, calendar preferences) without elevated permissions.
</Note>

All body fields are optional. Only the fields you send are updated.

### Path parameters

<ParamField path="id" type="number" required>
  The user ID to update.
</ParamField>

### Request body

**Profile fields (any user can update on themselves):**

<ParamField body="firstName" type="string">First name. Must be at least 1 character.</ParamField>
<ParamField body="lastName" type="string">Last name. Must be at least 1 character.</ParamField>
<ParamField body="email" type="string">Valid email address.</ParamField>
<ParamField body="phoneNumber" type="string">Phone number. Pass `null` to clear.</ParamField>
<ParamField body="timeZone" type="string">IANA time zone string (e.g. `America/Detroit`).</ParamField>
<ParamField body="autoDetectTimeZone" type="boolean">Whether to auto-detect time zone from the device.</ParamField>
<ParamField body="workingHoursStart" type="string">Working hours start time string (e.g. `"08:00"`).</ParamField>
<ParamField body="workingHoursEnd" type="string">Working hours end time string (e.g. `"17:00"`).</ParamField>
<ParamField body="bufferMinutes" type="number">Integer appointment buffer in minutes.</ParamField>
<ParamField body="use24HourFormat" type="boolean">Whether to display times in 24-hour format.</ParamField>
<ParamField body="showAllEvents" type="boolean">Whether the calendar shows all company events.</ParamField>

**Admin/owner only fields:**

<ParamField body="role" type="string">New role: `owner`, `admin`, or `sales`.</ParamField>
<ParamField body="isPrimary" type="boolean">Whether to mark this user as the primary account holder.</ParamField>
<ParamField body="canManageTags" type="boolean">Grant or revoke tag management permission.</ParamField>
<ParamField body="canManageProspects" type="boolean">Grant or revoke prospect management permission.</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl --request PATCH \
    --url https://app.leadscoutapp.com/api/users/14 \
    --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
    --header 'Content-Type: application/json' \
    --data '{
      "role": "admin",
      "canManageProspects": true
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://app.leadscoutapp.com/api/users/14', {
    method: 'PATCH',
    headers: {
      Authorization: `Bearer ${accessToken}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      role: 'admin',
      canManageProspects: true,
    }),
  });
  const updated = await response.json();
  ```
</CodeGroup>

***

## Remove a user

```
DELETE /api/users/:id
```

<Warning>
  Removing a user requires the `admin` or `owner` role. The user's prospects and activity history are preserved, but they can no longer sign in.
</Warning>

### Path parameters

<ParamField path="id" type="number" required>
  The user ID to remove.
</ParamField>

Returns `{ "id": <number> }` on success.

<CodeGroup>
  ```bash cURL theme={null}
  curl --request DELETE \
    --url https://app.leadscoutapp.com/api/users/14 \
    --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'
  ```

  ```javascript JavaScript theme={null}
  await fetch('https://app.leadscoutapp.com/api/users/14', {
    method: 'DELETE',
    headers: { Authorization: `Bearer ${accessToken}` },
  });
  ```
</CodeGroup>
