> 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/departments.md).

# Departments

Manage departments in Teamleader Focus.

```php
Teamleader::departments()
```

|                          |                                                             |
| ------------------------ | ----------------------------------------------------------- |
| Class                    | `McoreServices\TeamleaderSDK\Resources\General\Departments` |
| Create / update / delete | — / — / —                                                   |
| Pagination               | No                                                          |

## Endpoints

* `departments.info`
* `departments.list`

## Filters

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

| Filter   | Description                                    |
| -------- | ---------------------------------------------- |
| `ids`    | Array of department UUIDs to filter by         |
| `status` | Filter by department status (active, archived) |

## Sorting

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

| Field                | Description                                  |
| -------------------- | -------------------------------------------- |
| `created_at`         | Creation date                                |
| `default_department` | Ascending lists the default department first |
| `name`               | Department name                              |

## Accepted values

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

| Constant   | Values               |
| ---------- | -------------------- |
| `STATUSES` | `active`, `archived` |

## Methods

### `list()`

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

List departments

* `$filters` — ids, status (active and/or archived)
* `$options` — sort (default\_department|name|created\_at), sort\_order

**Throws** `InvalidArgumentException` On an unknown filter key, option, value or sort field

### `info()`

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

Get one department

* `$id` — Department UUID
* `$includes` — departments.info takes no includes; passing any throws

### `active()`

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

Get active departments only

### `archived()`

```php
archived(): array
```

Get archived departments only

### `byIds()`

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

Get departments by specific IDs

* `$ids` — Array of department UUIDs

### `getAvailableStatuses()`

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

Get available status values for filtering

## Examples

Get all departments:

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

Get only active departments:

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

Get specific departments by ID:

```php
$departments = Teamleader::departments()->list(['ids' => ['uuid1', 'uuid2']]);
```

Get departments sorted by name:

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

Get a single department:

```php
$department = Teamleader::departments()->info('department-uuid-here');
```
