> ## Documentation Index
> Fetch the complete documentation index at: https://docs.drime.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload File

> Upload a file directly to Drime Cloud

## Overview

Uploads a file directly to Drime Cloud using multipart form data. This is the simplest upload method but recommended only for smaller files.

<Note>
  For files larger than 5MB, consider using the [presigned URL](/api-reference/uploads/presign-url) or [multipart upload](/api-reference/multipart/create-multipart) flow for better reliability.
</Note>

## Request Body (multipart/form-data)

<ParamField body="file" type="file" required>
  The file to upload
</ParamField>

<ParamField body="parentId" type="integer">
  ID of the destination folder. Use `null` for root.
</ParamField>

<ParamField body="workspaceId" type="integer">
  Workspace ID. Use `0` for personal workspace.
</ParamField>

<ParamField body="relativePath" type="string">
  Optional folder path. Folders will be auto-created if they don't exist.
  Format: `/some/folders/here/file-name.jpg`
</ParamField>

## Response

<ResponseField name="fileEntry" type="object">
  The created file entry object
</ResponseField>

<ResponseField name="status" type="string">
  Request status (`success`)
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://app.drime.cloud/api/v1/uploads \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -F "file=@/path/to/document.pdf" \
    -F "parentId=" \
    -F "workspaceId=0"
  ```

  ```javascript JavaScript theme={null}
  const formData = new FormData();
  formData.append('file', fileInput.files[0]);
  formData.append('parentId', ''); // null for root
  formData.append('workspaceId', '0');

  const response = await fetch('https://app.drime.cloud/api/v1/uploads', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
    },
    body: formData
  });

  const { fileEntry } = await response.json();
  console.log(`Uploaded: ${fileEntry.name} (ID: ${fileEntry.id})`);
  ```

  ```python Python theme={null}
  import requests

  with open('document.pdf', 'rb') as f:
      response = requests.post(
          'https://app.drime.cloud/api/v1/uploads',
          headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'},
          files={'file': f},
          data={
              'parentId': '',
              'workspaceId': 0
          }
      )

  file_entry = response.json()['fileEntry']
  print(f"Uploaded: {file_entry['name']} (ID: {file_entry['id']})")
  ```
</RequestExample>

<ResponseExample>
  ```json 201 - Created theme={null}
  {
    "status": "success",
    "fileEntry": {
      "id": 123456,
      "name": "document.pdf",
      "type": "pdf",
      "mime": "application/pdf",
      "file_size": 1048576,
      "hash": "MTIzNDU2fA",
      "parent_id": null,
      "workspace_id": 0,
      "created_at": "2024-01-20T10:00:00.000000Z"
    }
  }
  ```

  ```json 422 - Validation Error theme={null}
  {
    "status": "error",
    "message": "The given data was invalid.",
    "errors": {
      "file": "The file field is required."
    }
  }
  ```
</ResponseExample>
