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

# Upload File

> Upload a file to a drive.

## Request Body

<ParamField body="drive_id" type="string" required>
  The ID of the drive to upload the file to.
</ParamField>

<ParamField body="filename" type="string" required>
  The name of the file.
</ParamField>

<ParamField body="path" type="string">
  The path where the file should be stored. Defaults to the filename if not specified.
</ParamField>

<ParamField body="content" type="string" required>
  The file content encoded as a base64 string.
</ParamField>

<ParamField body="content_type" type="string">
  The MIME type of the file. Auto-detected from the filename if not specified.
</ParamField>

<ParamField body="metadata" type="object">
  Arbitrary key-value metadata to attach to the file.
</ParamField>

<ParamField body="tags" type="string[]">
  An array of string tags to associate with the file.
</ParamField>

<ParamField body="expires_at" type="string">
  An ISO 8601 timestamp for when the file should expire.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.getagentdrive.com/v0/files \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "drive_id": "drv_abc123",
      "filename": "report.pdf",
      "path": "documents/report.pdf",
      "content": "JVBERi0xLjQK...",
      "content_type": "application/pdf",
      "metadata": { "author": "Jane Doe" },
      "tags": ["report", "2026"]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "file_xyz789",
    "drive_id": "drv_abc123",
    "path": "documents/report.pdf",
    "filename": "report.pdf",
    "mime_type": "application/pdf",
    "size": 24576,
    "content_hash": "sha256:abcdef1234567890",
    "content_preview": null,
    "tags": ["report", "2026"],
    "metadata": { "author": "Jane Doe" },
    "created_at": "2026-01-15T10:30:00Z",
    "updated_at": "2026-01-15T10:30:00Z"
  }
  ```
</ResponseExample>

## Response

<ResponseField name="id" type="string">
  Unique identifier for the file.
</ResponseField>

<ResponseField name="drive_id" type="string">
  The ID of the drive the file belongs to.
</ResponseField>

<ResponseField name="path" type="string">
  The full path of the file within the drive.
</ResponseField>

<ResponseField name="filename" type="string">
  The name of the file.
</ResponseField>

<ResponseField name="mime_type" type="string">
  The MIME type of the file.
</ResponseField>

<ResponseField name="size" type="integer">
  The size of the file in bytes.
</ResponseField>

<ResponseField name="content_hash" type="string">
  A SHA-256 hash of the file content.
</ResponseField>

<ResponseField name="content_preview" type="string">
  A text preview of the file content, if available.
</ResponseField>

<ResponseField name="tags" type="string[]">
  Tags associated with the file.
</ResponseField>

<ResponseField name="metadata" type="object">
  Custom metadata attached to the file.
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 timestamp of when the file was created.
</ResponseField>

<ResponseField name="updated_at" type="string">
  ISO 8601 timestamp of when the file was last updated.
</ResponseField>
