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

# External Parties

Manage external parties on projects in Teamleader Focus.

```php
Teamleader::externalParties()
```

|                          |                                                                  |
| ------------------------ | ---------------------------------------------------------------- |
| Class                    | `McoreServices\TeamleaderSDK\Resources\Projects\ExternalParties` |
| Also available as        | `external_parties()`                                             |
| Create / update / delete | — / — / —                                                        |
| Pagination               | No                                                               |

## Endpoints

* `projects-v2/externalParties.addToProject`
* `projects-v2/externalParties.delete`
* `projects-v2/externalParties.update`

## Filters

`list()` takes no filters.

## Accepted values

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

| Constant         | Values                                               |
| ---------------- | ---------------------------------------------------- |
| `ADD_FIELDS`     | `project_id`, `customer`, `function`, `sub_function` |
| `CUSTOMER_TYPES` | `contact`, `company`                                 |
| `UPDATE_FIELDS`  | `customer`, `function`, `sub_function`               |

## Methods

### `addToProject()`

```php
addToProject($projectIdOrData, ?string $customerType = null, ?string $customerId = null, ?string $function = null, ?string $subFunction = null): array
```

Add an external party to a project

Can be called with individual parameters or with a data array:

* addToProject($projectId, $customerType, $customerId, $function, $subFunction)
* addToProject($dataArray)
* `$projectIdOrData` — Project UUID or full data array
* `$customerType` — Customer type (contact, company) - required if using individual params
* `$customerId` — Customer UUID - required if using individual params
* `$function` — Function/role description
* `$subFunction` — Sub-function/role description

**Throws** `InvalidArgumentException`

### `update()`

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

Update an external party

* `$id` — External party UUID
* `$data` — Update data containing customer, function, and/or sub\_function

**Throws** `InvalidArgumentException`

### `delete()`

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

Delete an external party

* `$id` — External party UUID
* `$additionalParams` — Not used for external parties

**Throws** `InvalidArgumentException`

### `removeFromProject()`

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

Remove an external party from a project (alias for delete)

* `$id` — External party UUID

### `updateRole()`

```php
updateRole(string $id, ?string $function = null, ?string $subFunction = null): array
```

Update the function/role of an external party

* `$id` — External party UUID
* `$function` — Function/role
* `$subFunction` — Sub-function/role

## Examples

Add a contact as external party to a project:

```php
$result = Teamleader::externalParties()->addToProject(
    "project-uuid",
    "contact",
    "contact-uuid",
    "Project Manager"
);
```

Add a company as external party to a project:

```php
$result = Teamleader::externalParties()->addToProject(
    "project-uuid",
    "company",
    "company-uuid",
    "Contractor",
    "Lead Contractor"
);
```

Add external party with full array structure:

```php
$result = Teamleader::externalParties()->addToProject([
    "project_id" => "project-uuid",
    "customer" => [
        "type" => "contact",
        "id" => "contact-uuid"
    ],
    "function" => "Project Manager",
    "sub_function" => "Senior PM"
]);
```

Update an external party:

```php
$result = Teamleader::externalParties()->update(
    "external-party-uuid",
    [
        "customer" => [
            "type" => "contact",
            "id" => "contact-uuid"
        ],
        "function" => "Lead Designer",
        "sub_function" => null
    ]
);
```

Delete an external party:

```php
$result = Teamleader::externalParties()->delete("external-party-uuid");
```
