---
title: "Link or unlink departments from an user."
method: PATCH
path: "/v2/providers/employers/{employerId}/users/{userId}/departments"
tags: ["Linked departments"]
---

# Link or unlink departments from an user.

`PATCH /v2/providers/employers/{employerId}/users/{userId}/departments`

__Activity name:__ PatchEmployerUserLinkedDepartmentsByEmployerIdAndUserId

This endpoint enables the user to link or unlink multiple 'linkages' with one call.

## Path parameters

- `employerId` string, uuid, required
- `userId` string, uuid, required

## Headers

- `Authorization` string, required
- `Accept` string, required

## Request body

- LinkedDepartmentsPatch[]
  - `departmentId` string, uuid — The unique identifier (GUID/UUID) of the department
  - `action` 'link' | 'unlink' — The action to perform.
  - `hasAccessToSubDepartments` boolean — Indicates whether the user will have access to departments that are configured as sub-departments of the selected department.

## Response `200`

OK

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `409` — Conflict
- `500` — Internal Server Error

---

[API](https://skmtc.net/loket/apis/loket-api.md) · [All operations](https://skmtc.net/loket/apis/loket-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/loket/loket-api/revisions/32d1693f8db8/schema)
