# Files

{% hint style="info" %}
The public API supports uploading files up to 2 GB. If you would like to upload files larger than this, they must be uploaded using the website.
{% endhint %}

To upload a file, use the following 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 | Desired name of file in the Biodock filesystem.                                                                                 |
| destinationFolder                          | String | Desired parent folder of file in the Biodock filesystem. Will create folders if they do not exist. Defaults to the root folder. |
| upload<mark style="color:red;">\*</mark>   | file   | File to upload.                                                                                                                 |

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

```javascript
{
    id: "0123456789",
    __t: "File"
}
```

{% endtab %}
{% endtabs %}

To view items in the Biodock filesystem, use the following 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 show.             |
| startingAfter | String | Pagination cursor id.                          |
| folderId      | String | Parent folder id. Will default to root folder. |

#### 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",
        createdAt: "2000-01-01T00:00:00.001Z",
        __t: "File"
    }, 
    {
        id: "1234567890",
        name: "my_folder",
        createdAt: "2000-01-01T00:00:00.001Z",
        __t: "Folder"
    }],
    count: 2
}
```

{% endtab %}
{% endtabs %}

### 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

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, "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 the root 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
