## Link an NFON or TeamViewer account to the employee (hr:write)

`PUT /api/hr/v1/employees/{id}/linked-accounts`

Module: HR · operationId: `linkEmployeeAccount` · Tag: Employees · Auth: access token (`Authorization: Bearer <accessToken>`)

Sets the account as the employee's (by the employee's e-mail). An account linked to another person moves to this employee; a link set here is never replaced by a learned one.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string (uuid) | yes |  |

### Request body

`application/json` (required)

- `key` (string, required): The provider's id of the account (NFON extension, TeamViewer user id); surrounding spaces are removed (max length 256)
- `provider` (string, required): The provider of the account (one of `nfon`, `teamviewer`)

Example:

```json
{
  "key": "217",
  "provider": "nfon"
}
```

### Responses

- **204** Linked
- **400** Error (`application/json`)
- **403** Error (`application/json`)
- **404** Error (`application/json`)
- **409** The tenant has not connected the provider (`provider_not_connected`) (`application/json`)
- **422** The account cannot be linked (`linked_account_rejected`) or the employee has no e-mail (`employee_without_email`) (`application/json`)
- **503** comms is not configured or not reachable (`linked_accounts_unavailable`) (`application/json`)

### Example request

```bash
curl -X PUT 'https://api.mbcom.cloud/api/hr/v1/employees/3f2b8c1e-7d4a-4e9b-9c2a-5b1d6e8f0a12/linked-accounts' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"key":"217","provider":"nfon"}'
```
