## Create a workflow (tenant:forge:write and maintainer, or tenant:forge:admin)

`POST /api/forge/v1/projects/{key}/workflows`

Module: Forge · operationId: `createForgeWorkflow` · Tag: Configuration · Auth: access token (`Authorization: Bearer <accessToken>`)

Requires `tenant:forge:admin`, or `tenant:forge:write` and project role maintainer or admin. Writes `forge.config.updated`.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `key` | path | string | yes | Project key (e.g. APP) |

### Request body

`application/json` (required)

- `key` (string): Create: workflow key; fixed afterwards
- `name` (string): Display name (max length 60)
- `statusIds` (array of string (uuid)): Statuses of the workflow (at least one); replaces the list on PATCH
- `transitions` (array of Transition): Allowed moves; empty = free movement; replaces the list on PATCH
  - `fromStatusId` (string (uuid), required): Status the move starts from
  - `toStatusId` (string (uuid), required): Status the move leads to
- `version` (integer): PATCH: the version the change is based on

Example:

```json
{
  "key": "fehler",
  "name": "Fehlerablauf",
  "statusIds": [
    "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f01",
    "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f02",
    "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f03",
    "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f05",
    "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f06"
  ],
  "transitions": [
    {
      "fromStatusId": "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f01",
      "toStatusId": "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f02"
    },
    {
      "fromStatusId": "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f01",
      "toStatusId": "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f06"
    },
    {
      "fromStatusId": "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f02",
      "toStatusId": "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f03"
    },
    {
      "fromStatusId": "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f03",
      "toStatusId": "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f05"
    }
  ]
}
```

### Responses

- **201** Created (`application/json`)
- **400** Error (`application/json`)
- **403** Error (`application/json`)
- **404** Error (`application/json`)
- **409** Error (`application/json`)

Fields of the 201 answer:

- `id` (string (uuid), required): Workflow id
- `key` (string, required): Workflow key; never changes
- `name` (string, required): Display name
- `position` (integer, required): Order in the configuration
- `statusIds` (array of string (uuid), required): Statuses of the workflow
- `transitions` (array of Transition, required): Empty = free movement among the statuses
  - `fromStatusId` (string (uuid), required): Status the move starts from
  - `toStatusId` (string (uuid), required): Status the move leads to
- `version` (integer, required): Optimistic-locking version; send it with PATCH

Example 201 answer:

```json
{
  "id": "6e2f3a4b-5c6d-4e7f-9a8b-2c3d4e5f6a01",
  "key": "standard",
  "name": "Standard",
  "position": 0,
  "statusIds": [
    "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f01",
    "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f02",
    "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f03",
    "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f04",
    "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f05",
    "5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f06"
  ],
  "transitions": [],
  "version": 1
}
```

### Example request

```bash
curl -X POST 'https://api.mbcom.cloud/api/forge/v1/projects/string/workflows' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"key":"fehler","name":"Fehlerablauf","statusIds":["5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f01","5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f02","5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f03","5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f05","5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f06"],"transitions":[{"fromStatusId":"5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f01","toStatusId":"5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f02"},{"fromStatusId":"5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f01","toStatusId":"5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f06"},{"fromStatusId":"5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f02","toStatusId":"5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f03"},{"fromStatusId":"5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f03","toStatusId":"5d1e2f3a-4b5c-4d6e-8f7a-1b2c3d4e5f05"}]}'
```
