> For the complete documentation index, see [llms.txt](https://teamleader-sdk.mcore-services.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://teamleader-sdk.mcore-services.dev/api-reference/general/users.md).

# Users

Manage users in Teamleader Focus.

```php
Teamleader::users()
```

|                          |                                                                       |
| ------------------------ | --------------------------------------------------------------------- |
| Class                    | `McoreServices\TeamleaderSDK\Resources\General\Users`                 |
| Create / update / delete | — / — / —                                                             |
| Pagination               | `page_size` / `page_number`; no totals — a short page is the last one |

## Endpoints

* `users.getWeekSchedule` — deprecated by Teamleader
* `users.info`
* `users.list`
* `users.listDaysOff`
* `users.me`

## Filters

Passed as the first argument to `list()`. Any other key throws.

| Filter   | Description                                                |
| -------- | ---------------------------------------------------------- |
| `ids`    | Array of user UUIDs to filter by                           |
| `status` | Filter by user status (active, deactivated)                |
| `term`   | Search filter on first name, last name, email and function |

## Sorting

Pass `sort` (and optionally `sort_order`) in the options. Any other field throws.

| Field        | Description   |
| ------------ | ------------- |
| `email`      | Email address |
| `first_name` | First name    |
| `function`   | Function      |
| `last_name`  | Last name     |

## Includes

| Endpoint | Includes        |
| -------- | --------------- |
| `list()` | none            |
| `info()` | `external_rate` |

## Accepted values

Public constants on the class. Body fields and enum values outside these lists throw before the request is sent.

| Constant           | Values                        |
| ------------------ | ----------------------------- |
| `DAYS_OFF_FILTERS` | `starts_after`, `ends_before` |
| `INFO_INCLUDES`    | `external_rate`               |
| `STATUSES`         | `active`, `deactivated`       |

## Methods

### `list()`

```php
list(array $filters = [], array $options = []): array
```

List users with enhanced filtering and sorting

* `$filters` — Filters to apply
* `$options` — Additional options (sorting, pagination)

### `info()`

```php
info($id, $includes = null): array
```

Get one user

* `$id` — User UUID
* `$includes` — external\_rate

**Throws** `InvalidArgumentException` On an include users.info does not accept

### `me()`

```php
me(): array
```

Get current authenticated user

### `getWeekSchedule()`

> **Deprecated** Teamleader marks users.getWeekSchedule deprecated. Use userSchedules()->forUser($id, $from, $until) instead; this raises E\_USER\_DEPRECATED once per process and goes in v3.0.

```php
getWeekSchedule(string $id): array
```

Get user week schedule Only available with the Weekly working schedule feature

* `$id` — User UUID

### `listDaysOff()`

```php
listDaysOff(string $id, array $filters = [], array $options = []): array
```

List user days off

* `$id` — User UUID
* `$filters` — Filter options (starts\_after, ends\_before)
* `$options` — Pagination options

### `active()`

```php
active(): array
```

Get active users only

### `deactivated()`

```php
deactivated(): array
```

Get deactivated users only

### `search()`

```php
search(string $term): array
```

Search users by term

* `$term` — Search term

### `byIds()`

```php
byIds(array $ids): array
```

Get users by specific IDs

* `$ids` — Array of user UUIDs

### `withExternalRate()`

```php
withExternalRate()
```

Include external rate in response

### `getAvailableStatuses()`

```php
getAvailableStatuses(): array
```

Get available status values for filtering

## Examples

Get all users:

```php
$users = Teamleader::users()->list();
```

Get only active users:

```php
$users = Teamleader::users()->list(['status' => ['active']]);
```

Search users by term:

```php
$users = Teamleader::users()->list(['term' => 'John']);
```

Get users sorted by first name:

```php
$users = Teamleader::users()->list([], ['sort' => [['field' => 'first_name', 'order' => 'asc']]]);
```

Get a single user with external rate:

```php
$user = Teamleader::users()->info('user-uuid-here', 'external_rate');
```

Get current authenticated user:

```php
$currentUser = Teamleader::users()->me();
```

Get user week schedule:

```php
$schedule = Teamleader::users()->getWeekSchedule('user-uuid-here');
```

Get user days off:

```php
$daysOff = Teamleader::users()->listDaysOff('user-uuid-here', ['starts_after' => '2023-10-01']);
```
