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

# Groups

Manage project groups in Teamleader Focus (New Projects API).

Project groups in the current ("nextgen") project system — `projects-v2/projectGroups.*`.

```php
Teamleader::groups()
```

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

## Endpoints

* `projects-v2/projectGroups.assign`
* `projects-v2/projectGroups.create`
* `projects-v2/projectGroups.delete`
* `projects-v2/projectGroups.duplicate`
* `projects-v2/projectGroups.info`
* `projects-v2/projectGroups.list`
* `projects-v2/projectGroups.unassign`
* `projects-v2/projectGroups.update`

## Filters

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

| Filter       | Description                       |
| ------------ | --------------------------------- |
| `ids`        | Array of group UUIDs to filter by |
| `project_id` | Filter groups by project UUID     |

## Accepted values

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

| Constant            | Values                                                                                                                                                          |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ASSIGNEE_TYPES`    | `team`, `user`                                                                                                                                                  |
| `BILLING_METHODS`   | `time_and_materials`, `fixed_price`, `parent_fixed_price`, `non_billable`                                                                                       |
| `BILLING_STATUSES`  | `not_billable`, `not_billed`, `partially_billed`, `fully_billed`                                                                                                |
| `COLORS`            | `#00B2B2`, `#008A8C`, `#992600`, `#ED9E00`, `#D157D3`, `#A400B2`, `#0071F2`, `#004DA6`, `#64788F`, `#C0C0C4`, `#82828C`, `#1A1C20`                              |
| `CREATE_FIELDS`     | `project_id`, `title`, `description`, `color`, `billing_method`, `fixed_price`, `external_budget`, `internal_budget`, `start_date`, `end_date`, `assignees`     |
| `CURRENCIES`        | `BAM`, `CAD`, `CHF`, `CLP`, `CNY`, `COP`, `CZK`, `DKK`, `EUR`, `GBP`, `INR`, `ISK`, `JPY`, `MAD`, `MXN`, `NOK`, `PEN`, `PLN`, `RON`, `SEK`, `TRY`, `USD`, `ZAR` |
| `DELETE_STRATEGIES` | `ungroup_tasks_and_materials`, `delete_tasks_and_materials`, `delete_tasks_materials_and_unbilled_timetrackings`                                                |
| `TIME_UNITS`        | `hours`, `minutes`, `seconds`                                                                                                                                   |
| `UPDATE_FIELDS`     | `title`, `description`, `color`, `billing_method`, `fixed_price`, `external_budget`, `internal_budget`, `start_date`, `end_date`                                |
| `UPDATE_STRATEGIES` | `none`, `cascade`                                                                                                                                               |

## Methods

### `list()`

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

List project groups

Before v2.2.9 unknown filter keys and a string `ids` were dropped without a word, as were the paging options.

* `$filters` — ids (a UUID or a list of UUIDs), project\_id
* `$options` — page\_size, page\_number

**Throws** `InvalidArgumentException` On an unknown filter key or option

### `forProject()`

```php
forProject(string $projectId, array $options = []): array
```

Get all groups of a project

* `$projectId` — Project UUID
* `$options` — page\_size, page\_number

### `byIds()`

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

Get project groups by ID

* `$ids` — Group UUIDs

### `info()`

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

Get one group

* `$id` — Group UUID
* `$includes` — projectGroups.info takes no includes; passing any throws

### `create()`

```php
create(array $data): array
```

Create a project group

Requires project\_id and title. fixed\_price is only allowed with billing method fixed\_price, external\_budget only with time\_and\_materials.

**Throws** `InvalidArgumentException` When a required field is missing, or a field or value is not accepted

### `update()`

```php
update($id, array $data): array
```

Update a project group

billing\_method is sent as {value, update\_strategy}. A plain method name is accepted and sent with update\_strategy `none` (this group only); `cascade` applies it to the group's tasks and materials as well.

* `$id` — Group UUID

**Throws** `InvalidArgumentException` When a field or value is not accepted

### `delete()`

```php
delete($id, ...$additionalParams): array
```

Delete a project group

* `$id` — Group UUID
* `$additionalParams` — Delete strategy: ungroup\_tasks\_and\_materials (default), delete\_tasks\_and\_materials or delete\_tasks\_materials\_and\_unbilled\_timetrackings

**Throws** `InvalidArgumentException`

### `duplicate()`

```php
duplicate(string $originId): array
```

Duplicate a project group and its entities (without time trackings)

* `$originId` — UUID of the group to duplicate

### `getAvailableBillingMethods()`

```php
getAvailableBillingMethods(): array
```

### `getAvailableDeleteStrategies()`

```php
getAvailableDeleteStrategies(): array
```

### `assign()`

```php
assign(string $id, string $assigneeType, string $assigneeId): array
```

Assign a user or team

* `$id` — UUID of the project, group, task or material
* `$assigneeType` — user or team
* `$assigneeId` — UUID of the user or team

**Throws** `InvalidArgumentException` When the assignee type is not user or team

### `unassign()`

```php
unassign(string $id, string $assigneeType, string $assigneeId): array
```

Unassign a user or team

* `$id` — UUID of the project, group, task or material
* `$assigneeType` — user or team
* `$assigneeId` — UUID of the user or team

**Throws** `InvalidArgumentException` When the assignee type is not user or team

### `assignUser()`

```php
assignUser(string $id, string $userId): array
```

### `assignTeam()`

```php
assignTeam(string $id, string $teamId): array
```

### `unassignUser()`

```php
unassignUser(string $id, string $userId): array
```

### `unassignTeam()`

```php
unassignTeam(string $id, string $teamId): array
```

### `getAvailableAssigneeTypes()`

```php
getAvailableAssigneeTypes(): array
```

## Examples

Get all groups for a specific project:

```php
$groups = Teamleader::groups()->forProject("project-uuid");
```

Create a new project group:

```php
$group = Teamleader::groups()->create([
                "project_id" => "project-uuid",
                "title" => "Phase 1: Design",
                "description" => "Initial design phase",
                "color" => "#00B2B2",
                "billing_method" => "fixed_price",
                "fixed_price" => ["amount" => 5000, "currency" => "EUR"]
            ]);
```

Update a project group:

```php
$group = Teamleader::groups()->update("group-uuid", [
                "title" => "Phase 1: Design & Planning",
                "start_date" => "2023-01-18",
                "end_date" => "2023-03-22"
            ]);
```

Assign a user to a group:

```php
$result = Teamleader::groups()->assign("group-uuid", "user", "user-uuid");
```

Duplicate a group:

```php
$newGroup = Teamleader::groups()->duplicate("origin-group-uuid");
```

Delete a group:

```php
$result = Teamleader::groups()->delete("group-uuid", "ungroup_tasks_and_materials");
```
