> For the complete documentation index, see [llms.txt](https://docs.biodock.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.biodock.ai/public-api/resources/files.md). Agents can also search and read this documentation through its [MCP server](https://docs.biodock.ai/~gitbook/mcp).

# Files

*What you'll get: how to upload a file and list files and folders through the API.*

{% hint style="info" %}
The public API accepts one file per request, up to 5 GB. To upload larger files, or file formats the API doesn't accept, use the app. See [Limitations](https://docs.biodock.ai/public-api/limitations.md#uploads) for the accepted formats.
{% endhint %}

## Upload a file

Send the file as a multipart form to this endpoint.

## Upload file

<mark style="color:green;">`POST`</mark> `https://app.biodock.ai/api/external/filesystem-items/upload-file`

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-KEY<mark style="color:red;">\*</mark> | String | API key.    |

#### Request Body

| Name                                       | Type   | Description                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| fileName<mark style="color:red;">\*</mark> | String | Name of the file in Biodock, including its extension (for example `cells_01.tif`). Letters, numbers, spaces, `_`, `-` and `.` only, and the extension must be one the API accepts, in lower case.                                                                                                                                                                                        |
| destinationFolder                          | String | Folder path to upload into, starting from your top-level folder, for example `experiment_1/day_2`. In a workspace, see [In a workspace](#in-a-workspace) below for where the path starts. Folders that do not exist are created. Leave it out to upload to your top-level folder: an empty value is rejected. Letters, numbers, spaces, `_`, `-` and `.` only, with `/` between folders. |
| upload<mark style="color:red;">\*</mark>   | file   | File to upload.                                                                                                                                                                                                                                                                                                                                                                          |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    id: "0123456789",
    name: "my_file.png",
    __t: "File"
}
```

{% endtab %}
{% endtabs %}

An upload through the API follows the same [upload limits](https://docs.biodock.ai/account/credits-storage-and-limits.md#upload-limits) as one in the app.

| Response                                                                                            | Why                                                                  |
| --------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| `400` *"You must upload a file."*                                                                   | The request has no `upload` file.                                    |
| `400` *"The file you uploaded was invalid"*                                                         | The endpoint rejected the file, for example because it is over 5 GB. |
| `400` *"File is not valid."*                                                                        | Biodock can't read the file.                                         |
| *"This upload will exceed your total storage limit. Please upgrade your storage limit to proceed."* | The upload would take you over your storage limit.                   |

## List files and folders

To list items in a folder, use this endpoint:

## List filesystem items

<mark style="color:blue;">`GET`</mark> `https://app.biodock.ai/api/external/filesystem-items`

#### Query Parameters

| Name          | Type   | Description                                                                                              |
| ------------- | ------ | -------------------------------------------------------------------------------------------------------- |
| limit         | Number | Maximum number of results to return, from 1 to 100. Defaults to 10.                                      |
| startingAfter | String | Pagination cursor: the `id` of the last item on the previous page. Items are returned newest first.      |
| folderId      | String | ID of the folder to list. Defaults to your top-level folder (in a workspace, the workspace's top level). |

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-KEY<mark style="color:red;">\*</mark> | String | API key.    |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    results: [{
        id: "0123456789",
        name: "my_file.png",
        __t: "File"
    }, 
    {
        id: "1234567890",
        name: "my_folder",
        __t: "Folder"
    }],
    count: 2
}
```

{% endtab %}
{% endtabs %}

## In a workspace

To upload or list in a [workspace](https://docs.biodock.ai/workspaces/workspaces.md), name it with the `X-Biodock-Workspace` header, or use a key that moved there with your team. See [Act in a workspace](https://docs.biodock.ai/public-api/authentication.md#act-in-a-workspace).

* **The workspace pays**, and its storage limit is the one checked.
* **Where `destinationFolder` starts:** if your team was moved into the workspace, in your own folder from the move (*"\<your name>'s files"*), so scripts written before the move fill the same folders. Otherwise, at the workspace's top level. Folders on the path that don't exist are created.
* **Listing** without a `folderId` starts at the workspace's top level.
* **A folder you can't add to** is refused with `403` *"You cannot add files to the folder "\<name>" in this workspace."*

## Sample usage

Upload a file

```python
import requests

API_KEY = "" # Replace with your api key
FILE_TO_UPLOAD = "" # Replace with your file path
DESIRED_FILENAME = "" # Replace with your desired filename
DESIRED_FOLDER = "" # Replace with your desired folder path, or leave empty for your top-level folder

URL = "https://app.biodock.ai/api/external/filesystem-items/upload-file"

with open(FILE_TO_UPLOAD, "rb") as file_to_upload:
    data = {"fileName": DESIRED_FILENAME}
    if DESIRED_FOLDER:
        data["destinationFolder"] = DESIRED_FOLDER
    headers = {"X-API-KEY": API_KEY}
    files = {"upload": file_to_upload}
    response = requests.post(URL, data=data, headers=headers, files=files)
    print(response.text)
```

List filesystem items in your top-level folder

```python
import requests

API_KEY = "" # Replace with your api key

URL = "https://app.biodock.ai/api/external/filesystem-items"
headers = {"X-API-KEY": API_KEY, "Content-Type": "application/json"}

response = requests.get(URL, headers=headers)
print(response.text)
```

List filesystem items in a different folder

```python
import requests

API_KEY = "" # Replace with your api key
FOLDER_ID = "" # Replace with your folder id

URL = f"https://app.biodock.ai/api/external/filesystem-items?folderId={FOLDER_ID}"
headers = {"X-API-KEY": API_KEY, "Content-Type": "application/json"}

response = requests.get(URL, headers=headers)
print(response.text)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.biodock.ai/public-api/resources/files.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
