# Move a workflow to a folder

**PUT** `/api/workflows/{id}/folder`

Files a workflow in a folder, or takes it out of one.

Needs [an API token](https://docs.gorunner.io/api/authentication#scopes) with the **Write** permission for workflows (`workflow:write`).

## Parameters

### Path

- `id` · Required · UUID: The workflow’s ID.

### Body

- `folderId` · Optional · UUID or null: A folder in this workspace, or `null` for no folder. Left out means no folder too.

## One folder at a time

A workflow is in one folder at most. Moving it makes no version and doesn’t change `definitionRev`.

Make and list folders with [Create a folder](https://docs.gorunner.io/api/folders/create-folder) and [List folders](https://docs.gorunner.io/api/folders/list-folders).

## Responses

- 200 OK

  Moved. The answer names the folder it is in now.

- 400 `VALIDATION_ERROR`

  `id` isn’t a UUID, the body isn’t JSON, or the folder isn’t in this workspace.

- 403 `FORBIDDEN`

  The token lacks the **Write** permission for workflows.

- 404 `NOT_FOUND`

  No workflow with this ID in the token’s workspace.

- 500 `INTERNAL_ERROR`

  Nothing moved. Try again.

Any call can also answer: [`401 UNAUTHORIZED`](https://docs.gorunner.io/errors#UNAUTHORIZED) · [`401 TOKEN_ENDED`](https://docs.gorunner.io/errors#TOKEN_ENDED) · [`403 TOKEN_SURFACE_OFF`](https://docs.gorunner.io/errors#TOKEN_SURFACE_OFF) · [`403 FEATURE_OFF`](https://docs.gorunner.io/errors#FEATURE_OFF) · [`403 EMBED_NOT_ALLOWED`](https://docs.gorunner.io/errors#EMBED_NOT_ALLOWED) · [`403 EMBED_NOT_AVAILABLE`](https://docs.gorunner.io/errors#EMBED_NOT_AVAILABLE) · [`403 ACCOUNT_SUSPENDED`](https://docs.gorunner.io/errors#ACCOUNT_SUSPENDED) · [`413 PAYLOAD_TOO_LARGE`](https://docs.gorunner.io/errors#PAYLOAD_TOO_LARGE) · [`415 INVALID_CONTENT_TYPE`](https://docs.gorunner.io/errors#INVALID_CONTENT_TYPE) · [`429 RATE_LIMITED`](https://docs.gorunner.io/errors#RATE_LIMITED) · [`503 BUSY`](https://docs.gorunner.io/errors#BUSY) · [`503 PAUSED`](https://docs.gorunner.io/errors#PAUSED) · [`503 SERVICE_UNAVAILABLE`](https://docs.gorunner.io/errors#SERVICE_UNAVAILABLE). See [Errors](https://docs.gorunner.io/api/errors#by-status).

Request

**curl**

```bash
GORUNNER="https://api.gorunner.io"
GORUNNER_TOKEN="grt_…"  # needs Write for workflows
WORKFLOW_ID="your-workflow-id"

URL="$GORUNNER/api/workflows/$WORKFLOW_ID/folder"
curl -X PUT "$URL" \
  -H "Authorization: Bearer $GORUNNER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "folderId": "7a2c9e41-5b3d-4f08-a6e1-2d9c4b7f0e13"
  }'
```

**JavaScript**

```js
const GORUNNER = "https://api.gorunner.io";
const TOKEN = process.env.GORUNNER_TOKEN;
const WORKFLOW_ID = process.env.WORKFLOW_ID;

const res = await fetch(
  `${GORUNNER}/api/workflows/${WORKFLOW_ID}/` +
    `folder`,
  {
    method: "PUT",
    headers: {
        Authorization: `Bearer ${TOKEN}`,
        "Content-Type": "application/json",
      },
    body: JSON.stringify({
        folderId: "7a2c9e41-5b3d-4f08-a6e1-2d9c4b7f0e13",
      }),
  },
);
const { data } = await res.json();
```

**Python**

```python
import os, requests

GORUNNER = "https://api.gorunner.io"
TOKEN = os.environ["GORUNNER_TOKEN"]
WORKFLOW_ID = os.environ["WORKFLOW_ID"]

res = requests.put(
    f"{GORUNNER}/api/workflows/{WORKFLOW_ID}/"
    f"folder",
    headers={"Authorization": f"Bearer {TOKEN}"},
    json={
      "folderId": "7a2c9e41-5b3d-4f08-a6e1-2d9c4b7f0e13",
    },
)
data = res.json()["data"]
```

Response · 200 OK

```json
{
  "data": {
    "id": "3b1e5c2a-7d4f-4e8b-a1c6-5f2d9b0e7a31",
    "folderId": "7a2c9e41-5b3d-4f08-a6e1-2d9c4b7f0e13"
  }
}
```

**Every field**

### Body

- `folderId` · Optional · UUID or null: Destination folder, or `null` to remove the workflow from every folder.

### Response · 200 OK

- `data` · object
  - `id` · UUID
  - `folderId` · UUID or null

Related: [List folders](https://docs.gorunner.io/api/folders/list-folders) · [Change many workflows at once](https://docs.gorunner.io/api/workflows/bulk-update-workflows)

Source: https://docs.gorunner.io/api/workflows/move-workflow-to-folder
