---
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`

## Request

- Base URL: `https://api.loket.nl`
- URL: `https://api.loket.nl/v2/providers/employers/{employerId}/users/{userId}/departments`
- Auth: none required

__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

- object: a warning indacateds that the given payload is valide, however take notice of the warning this might ifluence behavour.
  - `version` Version
    - `obsoleteDate` string, date, nullable: The date (can be null) on which the `resourceVersion` is no longer supported/available
    - `resourceVersion` string, date: The resource version of the object in the response
  - `messages` object[]
    - `type` string: Indication of the type of message. See [the general documentation for more information](./#section/Response/Messages)
    - `description` string: Describes the message
    - `id` string, uuid, nullable: In some cases when the message may relate to a specific entity, or specific group of entities, this field provides the identifier of that entity
    - `code` integer: Identifying code for the message
    - `properties` string[]: An array that can contain additional information
  - `content` object

## Other responses

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

---

[API](https://skmtc.dev/loket/apis/loket-api.md) - [All operations](https://skmtc.dev/loket/apis/loket-api/llms.txt) - [OpenAPI document](https://skmtc.dev/loket/apis/loket-api/revisions/32170564148f?raw)
