## Enable or disable a flow, change its service account (tenant:flows:write|admin; scoped flows the owning module's manage)

`PATCH /api/flows/v1/flows/{id}`

Module: Flows · operationId: `updateFlow` · Tag: Flows · Auth: access token (`Authorization: Bearer <accessToken>`)

Enabling needs a published version. A new service account disables the flow until the next publish confirms it.
A scoped flow is changed by whoever its module lets manage the scope, not by `tenant:flows:admin`
(`503 scope_unavailable` when the module cannot answer).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string (uuid) | yes |  |

### Request body

`application/json` (required)

- `version` (integer, required): The flow's version you read
- `enabled` (boolean): Enable or disable the flow
- `serviceAccountId` (string (uuid)): Tenant flows: the new service account

Example:

```json
{
  "enabled": false,
  "version": 5
}
```

### Responses

- **200** The flow (`application/json`)
- **400** Invalid input (`invalid`); `field` names the first invalid field, `details.fields` every one. (`application/json`)
- **401** Missing, invalid or expired token (no body).
- **403** The token lacks the permission or has no active tenant (`forbidden`). Also: `person_required` (a service-account key on personal flows or the task inbox), `live_test_forbidden`, `forbidden_grant`, `starter_excluded`. (`application/json`)
- **404** The record does not exist in the token's tenant – or it belongs to a scope the caller may not view (a scoped flow stays hidden). (`application/json`)
- **409** The state does not allow it: version_conflict (reload), no_changes, archived, key_taken, flow_disabled, flow_tripped, task_closed, run_finished. (`application/json`)
- **422** invalid_definition (details.diagnostics), permission_missing (details.groups), owner_inactive, owner_not_found, not_published, key_changed, not_webhook, filter_failed, unknown_trigger, no_manual_trigger. (`application/json`)
- **503** A dependency is not available: `scope_unavailable` (the module that owns a flow's scope did not answer who may see and manage it – nothing of a scoped flow is shown or changed), `identity_unavailable` (HR), `ai_unavailable`, `ai_failed`. (`application/json`)

Fields of the 200 answer:

- `archived` (boolean): Whether the flow is archived
- `canEdit` (boolean): Whether the caller may change the draft and publish (a scoped flow: the owning module lets the caller manage the scope and the token holds tenant:flows:write or admin)
- `createdAt` (string (date-time)): When the flow was created
- `createdBy` (string): E-mail of the creator
- `description` (string): Description from the definition
- `enabled` (boolean): Whether the published version's triggers start runs
- `id` (string (uuid)): Flow id
- `key` (string): Unique per tenant; sub-flows call a flow by it
- `name` (string): Display name
- `owner` (string): `personal` (acts as its creator) or `tenant` (acts as its service account) (one of `personal`, `tenant`)
- `ownerEmail` (string): Personal flows: the owner; tenant flows: who created it
- `pausedReason` (string): Why runs stopped by themselves (owner_inactive, permission_lost, tripped)
- `publishedNumber` (integer): The live version
- `scope` (string): What the flow belongs to – `desk:space:<id>` or `forge:project:<id>`; absent for a tenant or personal flow. The owning module decides who sees and manages a scoped flow ("Scoped flows").
- `serviceAccountId` (string (uuid)): Tenant flows: the account it acts as
- `updatedAt` (string (date-time)): When the flow was changed last
- `updatedBy` (string): E-mail of who changed the flow last
- `version` (integer): Send it with changes

Example 200 answer:

```json
{
  "archived": false,
  "canEdit": true,
  "createdAt": "2026-10-21T09:20:00Z",
  "createdBy": "sophie.huber@muster-it.example",
  "description": "Bei jedem neuen Ticket mit hoher oder kritischer Priorität fasst die KI die Meldung zusammen und die Systemadministration bekommt eine Nachricht.",
  "enabled": true,
  "id": "6f2a9c4e-1b3d-4e5f-8a7b-9c0d1e2f3a4b",
  "key": "kritische-tickets-zusammenfassen",
  "name": "Kritische Tickets zusammenfassen",
  "owner": "personal",
  "ownerEmail": "sophie.huber@muster-it.example",
  "publishedNumber": 2,
  "updatedAt": "2026-11-12T14:03:27Z",
  "updatedBy": "sophie.huber@muster-it.example",
  "version": 5
}
```

### Example request

```bash
curl -X PATCH 'https://api.mbcom.cloud/api/flows/v1/flows/3f2b8c1e-7d4a-4e9b-9c2a-5b1d6e8f0a12' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"enabled":false,"version":5}'
```
