## Replace the pipeline (hr:recruiting:manage)

`PUT /api/hr/v1/recruiting/stages`

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

The stages in order. Every phase (`new`, `active`, `hired`, `rejected`, `withdrawn`) needs a stage that is not
archived; existing stages keep their phase and are archived, never removed. Stages without `id` are added.

### Request body

`application/json` (required)

- `stages` (array of RecruitingStage): The whole pipeline in order (at most 30); existing stages are archived, never left out (400)
  - `name` (string, required): Name of the stage (max length 100)
  - `phase` (string, required): Phase of the stage; rules look only at the phase (one of `new`, `active`, `hired`, `rejected`, `withdrawn`)
  - `archived` (boolean): Archived: no longer offered, kept for existing applications
  - `id` (string (uuid)): Empty for a new stage
  - `position` (integer, read-only): Position in the pipeline

Example:

```json
{
  "stages": [
    {
      "id": "6c8e0a2c-4e6a-4c8e-8a2c-4e6a8c0e2a82",
      "name": "Eingegangen",
      "phase": "new"
    },
    {
      "id": "8e0a2c4e-6a8c-4e0a-9c4e-6a8c0e2a4c83",
      "name": "In Prüfung",
      "phase": "active"
    },
    {
      "name": "Telefoninterview",
      "phase": "active"
    },
    {
      "id": "0a2c4e6a-8c0e-4a2c-8e6a-8c0e2a4c6e84",
      "name": "Fachgespräch",
      "phase": "active"
    },
    {
      "id": "2c4e6a8c-0e2a-4c4e-9a8c-0e2a4c6e8a85",
      "name": "Angebot",
      "phase": "active"
    },
    {
      "id": "4e6a8c0e-2a4c-4e6a-8c0e-2a4c6e8a0c86",
      "name": "Eingestellt",
      "phase": "hired"
    },
    {
      "id": "6a8c0e2a-4c6e-4a8c-9e2a-4c6e8a0c2e87",
      "name": "Abgesagt",
      "phase": "rejected"
    },
    {
      "id": "8c0e2a4c-6e8a-4c0e-8a4c-6e8a0c2e4a88",
      "name": "Zurückgezogen",
      "phase": "withdrawn"
    }
  ]
}
```

### Responses

- **200** The pipeline (`application/json`)
- **400** Error (`application/json`)

Fields of the 200 answer:

- `items` (array of RecruitingStage, required): The saved pipeline
  - `name` (string, required): Name of the stage (max length 100)
  - `phase` (string, required): Phase of the stage; rules look only at the phase (one of `new`, `active`, `hired`, `rejected`, `withdrawn`)
  - `archived` (boolean): Archived: no longer offered, kept for existing applications
  - `id` (string (uuid)): Empty for a new stage
  - `position` (integer, read-only): Position in the pipeline

Example 200 answer:

```json
{
  "items": [
    {
      "archived": false,
      "id": "6c8e0a2c-4e6a-4c8e-8a2c-4e6a8c0e2a82",
      "name": "Eingegangen",
      "phase": "new",
      "position": 1
    },
    {
      "archived": false,
      "id": "8e0a2c4e-6a8c-4e0a-9c4e-6a8c0e2a4c83",
      "name": "In Prüfung",
      "phase": "active",
      "position": 2
    },
    {
      "archived": false,
      "id": "1e3a5c7e-9a1c-4e3a-9c5e-9a1c3e5a7c92",
      "name": "Telefoninterview",
      "phase": "active",
      "position": 3
    },
    {
      "archived": false,
      "id": "0a2c4e6a-8c0e-4a2c-8e6a-8c0e2a4c6e84",
      "name": "Fachgespräch",
      "phase": "active",
      "position": 4
    },
    {
      "archived": false,
      "id": "2c4e6a8c-0e2a-4c4e-9a8c-0e2a4c6e8a85",
      "name": "Angebot",
      "phase": "active",
      "position": 5
    },
    {
      "archived": false,
      "id": "4e6a8c0e-2a4c-4e6a-8c0e-2a4c6e8a0c86",
      "name": "Eingestellt",
      "phase": "hired",
      "position": 6
    },
    {
      "archived": false,
      "id": "6a8c0e2a-4c6e-4a8c-9e2a-4c6e8a0c2e87",
      "name": "Abgesagt",
      "phase": "rejected",
      "position": 7
    },
    {
      "archived": false,
      "id": "8c0e2a4c-6e8a-4c0e-8a4c-6e8a0c2e4a88",
      "name": "Zurückgezogen",
      "phase": "withdrawn",
      "position": 8
    }
  ]
}
```

### Example request

```bash
curl -X PUT 'https://api.mbcom.cloud/api/hr/v1/recruiting/stages' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"stages":[{"id":"6c8e0a2c-4e6a-4c8e-8a2c-4e6a8c0e2a82","name":"Eingegangen","phase":"new"},{"id":"8e0a2c4e-6a8c-4e0a-9c4e-6a8c0e2a4c83","name":"In Prüfung","phase":"active"},{"name":"Telefoninterview","phase":"active"},{"id":"0a2c4e6a-8c0e-4a2c-8e6a-8c0e2a4c6e84","name":"Fachgespräch","phase":"active"},{"id":"2c4e6a8c-0e2a-4c4e-9a8c-0e2a4c6e8a85","name":"Angebot","phase":"active"},{"id":"4e6a8c0e-2a4c-4e6a-8c0e-2a4c6e8a0c86","name":"Eingestellt","phase":"hired"},{"id":"6a8c0e2a-4c6e-4a8c-9e2a-4c6e8a0c2e87","name":"Abgesagt","phase":"rejected"},{"id":"8c0e2a4c-6e8a-4c0e-8a4c-6e8a0c2e4a88","name":"Zurückgezogen","phase":"withdrawn"}]}'
```
