# Folders and Trash

> List folders and what's in them, create, rename and move them, move workflows between them, delete a folder and restore it, and see what's in the Trash.

Web page: https://docs.lodol.com/docs/api/folders

Folders group a workspace's workflows the way the **Workflows** page in Lodol does, and they nest. They use the workflow scopes: `workflows:read` to read them, `workflows:write` to create, rename and move them, and `workflows:delete` to delete and restore them. The member who created the key needs the same role permissions and access to a folder as in Lodol.

## The folder object

```json
{
  "id": "66c4e6a8b0d2f4a6c8e0a2b4",
  "name": "Client reports",
  "path": "Client reports",
  "parent_folder_id": null,
  "url": "https://app.lodol.com/workflows?folderId=66c4e6a8b0d2f4a6c8e0a2b4",
  "workflow_count": 1,
  "folder_count": 1
}
```

<Fields title="Fields">
<Field id="id" type="string" description="The folder's ID." />
<Field id="name" type="string" description="Its name." />
<Field id="path" type="string" description="Its place from the top level, folder names separated by /, such as Client reports / Monthly." />
<Field id="parent_folder_id" type="string or null" description="The folder it's in, or null at the top level." />
<Field id="url" type="string" description="Where to open it in Lodol." />
<Field id="workflow_count" type="integer" description="How many workflows it holds directly." />
<Field id="folder_count" type="integer" description="How many folders it holds directly." />
<Field id="folders" type="array" description="The folders it holds, each with its id and name. Only an answer about one folder includes it." />
<Field id="workflows" type="array" description="The workflows it holds, each with its id, name and url. Only an answer about one folder includes it." />
</Fields>

---

## List folders

<Endpoint method="GET" path="/api/v1/folders" />

Returns the workspace's folders that the key's member can see, at every depth, a page at a time. Requires the `workflows:read` scope.

<Fields title="Query parameters">
<Field id="search" type="string" description="Only folders whose name contains this text, in any case." />
<Field id="limit" type="integer" description="How many to return, from 1 to 100." facts="Default: `50`." />
<Field id="cursor" type="string" description="For the next page: the next_cursor of the page you have." />
</Fields>

```bash tab="cURL" tab-group="lang"
curl "https://api-prod.lodol.com/api/v1/folders?search=reports" \
  -H "Authorization: Bearer $LODOL_API_KEY"
```

```js tab="JavaScript"
const response = await fetch('https://api-prod.lodol.com/api/v1/folders?search=reports', {
  headers: { Authorization: `Bearer ${process.env.LODOL_API_KEY}` },
});
const { folders, next_cursor } = await response.json();
```

```python tab="Python"
response = requests.get(
    "https://api-prod.lodol.com/api/v1/folders",
    headers={"Authorization": f"Bearer {os.environ['LODOL_API_KEY']}"},
    params={"search": "reports"},
)
folders = response.json()["folders"]
```

**Response `200`:** a page of [folders](#the-folder-object). `next_cursor` gets the next page; see [Paging through lists](https://docs.lodol.com/docs/api.md#paging-through-lists).

```json
{
  "folders": [
    {
      "id": "66c4e6a8b0d2f4a6c8e0a2b4",
      "name": "Client reports",
      "path": "Client reports",
      "parent_folder_id": null,
      "url": "https://app.lodol.com/workflows?folderId=66c4e6a8b0d2f4a6c8e0a2b4",
      "workflow_count": 1,
      "folder_count": 1
    },
    {
      "id": "66c4e6a8b0d2f4a6c8e0a2b6",
      "name": "Monthly",
      "path": "Client reports / Monthly",
      "parent_folder_id": "66c4e6a8b0d2f4a6c8e0a2b4",
      "url": "https://app.lodol.com/workflows?folderId=66c4e6a8b0d2f4a6c8e0a2b6",
      "workflow_count": 0,
      "folder_count": 0
    }
  ],
  "next_cursor": null
}
```

---

## Get a folder

<Endpoint method="GET" path="/api/v1/folders/:id" />

Returns a [folder](#the-folder-object) and what it holds: its `folders` and `workflows`. Requires the `workflows:read` scope. A folder that doesn't exist, or that the key's member can't open, returns `404`.

```bash
curl https://api-prod.lodol.com/api/v1/folders/66c4e6a8b0d2f4a6c8e0a2b4 \
  -H "Authorization: Bearer $LODOL_API_KEY"
```

**Response `200`:**

```json
{
  "id": "66c4e6a8b0d2f4a6c8e0a2b4",
  "name": "Client reports",
  "path": "Client reports",
  "parent_folder_id": null,
  "url": "https://app.lodol.com/workflows?folderId=66c4e6a8b0d2f4a6c8e0a2b4",
  "workflow_count": 1,
  "folder_count": 1,
  "folders": [{ "id": "66c4e6a8b0d2f4a6c8e0a2b6", "name": "Monthly" }],
  "workflows": [
    {
      "id": "665f1a2b3c4d5e6f7a8b9c0d",
      "name": "Monthly Client Report",
      "url": "https://app.lodol.com/create?programId=665f1a2b3c4d5e6f7a8b9c0d"
    }
  ]
}
```

---

## Create a folder

<Endpoint method="POST" path="/api/v1/folders" />

Creates a folder, at the top level or inside another. Requires the `workflows:write` scope.

<Fields title="Headers">
<Field id="Idempotency-Key" type="string" description="Makes the request safe to retry: a repeat with the same key returns the first response instead of creating another folder. See Idempotency." />
</Fields>

<Fields title="Body">
<Field id="name" type="string" description="The folder's name, up to 255 characters." facts="Required." />
<Field id="parent_folder_id" type="string" description="The folder to create it in. Left out, it's created at the top level." />
</Fields>

```bash
curl -X POST https://api-prod.lodol.com/api/v1/folders \
  -H "Authorization: Bearer $LODOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Monthly", "parent_folder_id": "66c4e6a8b0d2f4a6c8e0a2b4"}'
```

**Response `201`:** the new folder, as [Get a folder](#get-a-folder) returns it.

```json
{
  "id": "66c4e6a8b0d2f4a6c8e0a2b6",
  "name": "Monthly",
  "path": "Client reports / Monthly",
  "parent_folder_id": "66c4e6a8b0d2f4a6c8e0a2b4",
  "url": "https://app.lodol.com/workflows?folderId=66c4e6a8b0d2f4a6c8e0a2b6",
  "workflow_count": 0,
  "folder_count": 0,
  "folders": [],
  "workflows": []
}
```

A folder with the same name in the same place returns `400`.

---

## Rename a folder

<Endpoint method="PATCH" path="/api/v1/folders/:id" />

Gives a folder a new name. Requires the `workflows:write` scope.

<Fields title="Body">
<Field id="name" type="string" description="The new name." facts="Required." />
</Fields>

```bash
curl -X PATCH https://api-prod.lodol.com/api/v1/folders/66c4e6a8b0d2f4a6c8e0a2b4 \
  -H "Authorization: Bearer $LODOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Client reports (2026)"}'
```

**Response `200`:** the folder with its new name, as [Get a folder](#get-a-folder) returns it.

---

## Move into a folder

<Endpoint method="POST" path="/api/v1/folders/move" />

Moves workflows or folders into a folder, or out of their folders to the top level. Something is in one folder at most, so moving it takes it out of the one it was in. A folder moves with everything in it, and can't go inside itself. If any of them can't move, none do. Requires the `workflows:write` scope.

Something moved into a restricted folder can be opened only by the people that folder is shared with.

<Fields title="Body">
<Field id="items" type="array" description="What to move, 1 to 50 things, each an object with a type (workflow or folder) and its id." facts="Required." />
<Field id="folder_id" type="string or null" description="The folder to move them into. Left out or null, they move to the top level." />
</Fields>

```bash tab="cURL" tab-group="lang"
curl -X POST https://api-prod.lodol.com/api/v1/folders/move \
  -H "Authorization: Bearer $LODOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [{"type": "workflow", "id": "665f1a2b3c4d5e6f7a8b9c0d"}],
    "folder_id": "66c4e6a8b0d2f4a6c8e0a2b4"
  }'
```

```js tab="JavaScript"
await fetch('https://api-prod.lodol.com/api/v1/folders/move', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.LODOL_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    items: [{ type: 'workflow', id: '665f1a2b3c4d5e6f7a8b9c0d' }],
    folder_id: '66c4e6a8b0d2f4a6c8e0a2b4',
  }),
});
```

```python tab="Python"
requests.post(
    "https://api-prod.lodol.com/api/v1/folders/move",
    headers={"Authorization": f"Bearer {os.environ['LODOL_API_KEY']}"},
    json={
        "items": [{"type": "workflow", "id": "665f1a2b3c4d5e6f7a8b9c0d"}],
        "folder_id": "66c4e6a8b0d2f4a6c8e0a2b4",
    },
)
```

**Response `200`:** what moved, and the folder it's now in (`null` for the top level).

```json
{
  "moved": [{ "type": "workflow", "id": "665f1a2b3c4d5e6f7a8b9c0d", "name": "Monthly Client Report" }],
  "folder_id": "66c4e6a8b0d2f4a6c8e0a2b4"
}
```

---

## Delete a folder

<Endpoint method="DELETE" path="/api/v1/folders/:id" />

Moves a folder and everything in it, at every depth, to the Trash. Workflows in it stop running and their triggers stop listening. It can all be restored for 30 days; after that it's deleted for good. To keep something that's in it, [move](#move-into-a-folder) it out first. Requires the `workflows:delete` scope.

```bash
curl -X DELETE https://api-prod.lodol.com/api/v1/folders/66c4e6a8b0d2f4a6c8e0a2b6 \
  -H "Authorization: Bearer $LODOL_API_KEY"
```

**Response `200`:** `restorable_until` is when it leaves the Trash for good.

```json
{
  "id": "66c4e6a8b0d2f4a6c8e0a2b6",
  "deleted": true,
  "restorable_until": "2026-12-31T20:22:18.341592+00:00"
}
```

---

## Restore a folder

<Endpoint method="POST" path="/api/v1/folders/:id/restore" />

Brings a deleted folder back from the Trash, within 30 days, with everything deleted with it, where it was. Requires the `workflows:delete` scope.

```bash
curl -X POST https://api-prod.lodol.com/api/v1/folders/66c4e6a8b0d2f4a6c8e0a2b6/restore \
  -H "Authorization: Bearer $LODOL_API_KEY"
```

**Response `200`:** the folder, back where it was, as [Get a folder](#get-a-folder) returns it.

---

## List the Trash

<Endpoint method="GET" path="/api/v1/trash" />

Returns what was deleted and can still be restored, most recently deleted first, a page at a time, as the **Trash** on the **Workflows** page lists it: what the key's member could edit. Something deleted with its folder isn't listed on its own: it comes back with the folder. Requires the `workflows:delete` scope, and the member who created the key must be allowed to delete workflows.

<Fields title="Query parameters">
<Field id="type" type="string" description="Only this kind of thing: workflow or folder." />
<Field id="search" type="string" description="Only things whose name contains this text, in any case." />
<Field id="limit" type="integer" description="How many to return, from 1 to 100." facts="Default: `50`." />
<Field id="cursor" type="string" description="For the next page: the next_cursor of the page you have." />
</Fields>

```bash
curl "https://api-prod.lodol.com/api/v1/trash?type=workflow" \
  -H "Authorization: Bearer $LODOL_API_KEY"
```

**Response `200`:**

```json
{
  "items": [
    {
      "type": "workflow",
      "id": "665f1a2b3c4d5e6f7a8b9c0d",
      "name": "Monthly Client Report",
      "deleted_at": "2026-12-01T19:14:12.620000+00:00",
      "deleted_by": { "id": "665f1a2b3c4d5e6f7a8b9c0e", "name": "Ada Lovelace" },
      "restorable_until": "2026-12-31T19:14:12.620000+00:00",
      "restores_to": "Client reports"
    }
  ],
  "next_cursor": null
}
```

<Fields title="Item fields">
<Field id="type" type="string" description="workflow or folder." />
<Field id="id" type="string" description="Its ID, which Restore a workflow or Restore a folder takes." />
<Field id="name" type="string" description="Its name." />
<Field id="deleted_at" type="string" description="When it was deleted, in ISO 8601." />
<Field id="deleted_by" type="object or null" description="Who deleted it: their id and name." />
<Field id="restorable_until" type="string" description="When it leaves the Trash for good, in ISO 8601." />
<Field id="restores_to" type="string" description="The path of the folder it's restored into, or the top level." />
</Fields>
