# Set the workflow type

> Switch a workflow between code and agent. Rewrite the files for the new type afterwards.

Source: https://docs.generalinput.com/api/workflows/set-type



<Endpoint method="PATCH" path="/v1/workflows/:id/type" />

<Access scope="workflows:manage" />

The runtime executes by the configured type, not by which files exist. After switching, replace the files with the new type's and delete the old type's before validating again.

The body accepts only `code` and `agent`, but nothing stops you pointing this at an app, which rewrites its type and leaves its bundle mismatched. Create apps with [`POST /v1/workflows`](/api/workflows/create) and leave their type alone.

## Body [#body]

| Field          | Type   | Required | Notes              |
| -------------- | ------ | -------- | ------------------ |
| `workflowType` | string | yes      | `code` or `agent`. |

## Response [#response]

```json
{
  "detail": { "id": "wf_01HX…", "workflowType": "agent", "…": "…" },
  "forbiddenFiles": ["main.ts", "package.json", "tsconfig.json"]
}
```

`forbiddenFiles` lists the old type's files that now fail validation if left in the bundle.
