## Chain of command of an employee (hr:read, the person themself, or their managers and deputies)

`GET /api/hr/v1/employees/{id}/chain`

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

Managers and deputies read the chain of the people in their chain of command; people outside their scope answer `404`. `me` is the caller.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Employee id or `me` |

### Responses

- **200** Chain (`application/json`)
- **404** Error (`application/json`)

Fields of the 200 answer:

- `chain` (array of PersonRef): Direct manager first
  - `displayName` (string): Display name of the employee
  - `email` (string): E-mail address of the employee
  - `id` (string): Id of the employee
- `employeeId` (string): Id of the employee
- `manager` (PersonRef)
  - `displayName` (string): Display name of the employee
  - `email` (string): E-mail address of the employee
  - `id` (string): Id of the employee
- `responsible` (array of PersonRef): Chain plus deputies
  - `displayName` (string): Display name of the employee
  - `email` (string): E-mail address of the employee
  - `id` (string): Id of the employee
- `unit` (OrgUnit)
  - `name` (string, required): Name of the unit (max length 120)
  - `archived` (boolean): Archived: no longer offered for new data, kept for existing data
  - `deputyId` (string): Stands in for the head (decides while the head is away)
  - `headId` (string): Employee who leads the unit (direct manager of its members)
  - `id` (string, read-only): Id of the org unit
  - `memberCount` (integer, read-only): Active employees placed directly in the unit
  - `parentId` (string): Empty = top level
  - `sortOrder` (integer): Position in lists (ascending)
  - `version` (integer): Version for optimistic locking: send the version you read with a change (stale: 409 version_conflict)

Example 200 answer:

```json
{
  "chain": [
    {
      "displayName": "Martin Brandl",
      "email": "martin.brandl@muster-it.example",
      "id": "b2d4f6a8-0c1e-4a3b-9d5f-7e9a1c3b5d04"
    },
    {
      "displayName": "Tobias Hartl",
      "email": "tobias.hartl@muster-it.example",
      "id": "9b1d3f5a-7c9e-4b1d-8f3a-5c7e9b1d3f2e"
    },
    {
      "displayName": "Thomas Pfeiffer",
      "email": "thomas.pfeiffer@muster-it.example",
      "id": "5c7e9a1c-3e5a-4c7e-9a1c-5e7a9c1e3a5b"
    }
  ],
  "employeeId": "e5a1c3d7-2b4f-4c6e-8a0b-1d3f5b7c9e02",
  "manager": {
    "displayName": "Martin Brandl",
    "email": "martin.brandl@muster-it.example",
    "id": "b2d4f6a8-0c1e-4a3b-9d5f-7e9a1c3b5d04"
  },
  "responsible": [
    {
      "displayName": "Martin Brandl",
      "email": "martin.brandl@muster-it.example",
      "id": "b2d4f6a8-0c1e-4a3b-9d5f-7e9a1c3b5d04"
    },
    {
      "displayName": "Tobias Hartl",
      "email": "tobias.hartl@muster-it.example",
      "id": "9b1d3f5a-7c9e-4b1d-8f3a-5c7e9b1d3f2e"
    },
    {
      "displayName": "Jonas Bauer",
      "email": "jonas.bauer@muster-it.example",
      "id": "f2a4c6e8-0b2d-4f4a-8c6e-8a0c2e4b6d1c"
    },
    {
      "displayName": "Thomas Pfeiffer",
      "email": "thomas.pfeiffer@muster-it.example",
      "id": "5c7e9a1c-3e5a-4c7e-9a1c-5e7a9c1e3a5b"
    }
  ],
  "unit": {
    "archived": false,
    "deputyId": "e5a1c3d7-2b4f-4c6e-8a0b-1d3f5b7c9e02",
    "headId": "b2d4f6a8-0c1e-4a3b-9d5f-7e9a1c3b5d04",
    "id": "0c2e4a6c-8e0a-4c2e-9a4c-6e8a0c2e4a71",
    "memberCount": 4,
    "name": "Service Desk",
    "parentId": "2e4a6c8e-0a2c-4e4a-8c6e-0a2c4e6a8c72",
    "sortOrder": 10,
    "version": 2
  }
}
```

### Example request

```bash
curl -X GET 'https://api.mbcom.cloud/api/hr/v1/employees/string/chain' \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```
