# File Management

Operations for uploading and managing project files

## Upload multiple files to a project with enhanced support

> Uploads one or more files to be associated with a project for research and content generation purposes.\
> \
> \*\*Enhanced Features:\*\*\
> \- Support for 20+ file types including PDF, Word, TXT, Markdown, Python, JSON, XML, CSV, HTML, TEX, JavaScript, C, YAML, TOML, and more\
> \- Multi-file upload support (single or multiple files per request)\
> \- Advanced validation with detailed error reporting\
> \- Automatic duplicate detection and prevention\
> \- Comprehensive response formatting with upload summary\
> \- Secure file storage with unique naming and proper cleanup on errors\
> \
> \*\*File Type Support:\*\*\
> PDF, Word Documents, Text Files, Markdown, Python Scripts, JSON Data, XML Documents,\
> CSV Files, HTML Files, TEX/LaTeX, JavaScript, C Source Code, YAML Configuration,\
> TOML Configuration, Jupyter Notebooks, RSS/Atom Feeds, SVG Images, and more.\
> \
> \*\*Upload Limits:\*\*\
> \- Maximum file size: 50MB per file\
> \- No limit on number of files per request\
> \- Automatic validation and error reporting for each file<br>

```json
{"openapi":"3.0.3","info":{"title":"DeepWriter API","version":"2.0.0"},"tags":[{"name":"File Management","description":"Operations for uploading and managing project files"}],"servers":[{"url":"/api","description":"API base path"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT token for user session authentication."}},"schemas":{"ProjectFile":{"type":"object","description":"Represents a file uploaded to a project","properties":{"id":{"type":"string","format":"uuid","description":"The unique identifier for the file"},"project_id":{"type":"string","format":"uuid","description":"The ID of the project this file belongs to"},"file_name":{"type":"string","description":"The original name of the uploaded file"},"file_size":{"type":"number","description":"The size of the file in bytes"},"file_type":{"type":"string","description":"The MIME type of the file"},"storage_path":{"type":"string","description":"The path where the file is stored"},"created_at":{"type":"string","format":"date-time","description":"When the file was uploaded"},"updated_at":{"type":"string","format":"date-time","description":"When the file was last updated"}},"required":["id","project_id","file_name","file_size","file_type","storage_path","created_at","updated_at"]},"Error":{"type":"object","properties":{"error":{"type":"string","description":"A message describing the error"}},"required":["error"]}}},"paths":{"/uploadProjectFiles":{"post":{"summary":"Upload multiple files to a project with enhanced support","description":"Uploads one or more files to be associated with a project for research and content generation purposes.\n\n**Enhanced Features:**\n- Support for 20+ file types including PDF, Word, TXT, Markdown, Python, JSON, XML, CSV, HTML, TEX, JavaScript, C, YAML, TOML, and more\n- Multi-file upload support (single or multiple files per request)\n- Advanced validation with detailed error reporting\n- Automatic duplicate detection and prevention\n- Comprehensive response formatting with upload summary\n- Secure file storage with unique naming and proper cleanup on errors\n\n**File Type Support:**\nPDF, Word Documents, Text Files, Markdown, Python Scripts, JSON Data, XML Documents,\nCSV Files, HTML Files, TEX/LaTeX, JavaScript, C Source Code, YAML Configuration,\nTOML Configuration, Jupyter Notebooks, RSS/Atom Feeds, SVG Images, and more.\n\n**Upload Limits:**\n- Maximum file size: 50MB per file\n- No limit on number of files per request\n- Automatic validation and error reporting for each file\n","tags":["File Management"],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["projectId"],"properties":{"projectId":{"type":"string","format":"uuid","description":"ID of the project to associate files with"},"files":{"type":"array","items":{"type":"string","format":"binary"},"description":"Multiple files to upload (alternative to single file)"},"file":{"type":"string","format":"binary","description":"Single file to upload (alternative to files array)"}}}}}},"responses":{"200":{"description":"All files uploaded successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"files":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Database ID of the uploaded file"},"file_name":{"type":"string","description":"Original filename"},"file_type":{"type":"string","description":"MIME type of the file"},"file_size":{"type":"number","description":"File size in bytes"},"file_url":{"type":"string","description":"Public URL for accessing the file"},"storage_path":{"type":"string","description":"Internal storage path in Supabase"},"uploaded_at":{"type":"string","format":"date-time","description":"Upload timestamp"}}}},"summary":{"type":"object","properties":{"total_files":{"type":"number","description":"Total number of files processed"},"successful_uploads":{"type":"number","description":"Number of successfully uploaded files"},"failed_uploads":{"type":"number","description":"Number of failed uploads"},"errors":{"type":"array","items":{"type":"object","properties":{"file_name":{"type":"string"},"error":{"type":"string"}}},"description":"List of any upload errors (empty if all successful)"}}}}}}}},"207":{"description":"Multi-Status - Some files uploaded successfully, some failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"files":{"type":"array","items":{"$ref":"#/components/schemas/ProjectFile"}},"summary":{"type":"object","properties":{"total_files":{"type":"number"},"successful_uploads":{"type":"number"},"failed_uploads":{"type":"number"},"errors":{"type":"array","items":{"type":"object","properties":{"file_name":{"type":"string"},"error":{"type":"string"}}}}}}}}}}},"400":{"description":"Bad Request - No files uploaded or all uploads failed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"details":{"type":"array","items":{"type":"string"}},"summary":{"type":"object","properties":{"total_files":{"type":"number"},"successful_uploads":{"type":"number"},"failed_uploads":{"type":"number"},"errors":{"type":"array","items":{"type":"object"}}}}}}}}},"401":{"description":"Unauthorized - Authentication required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"details":{"type":"array","items":{"type":"string"}}}}}}},"404":{"description":"Project not found or access denied","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"details":{"type":"array","items":{"type":"string"}}}}}}},"409":{"description":"Conflict - File already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"File too large - Exceeds 50MB limit","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"details":{"type":"array","items":{"type":"string"}}}}}}},"415":{"description":"Unsupported file type","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"details":{"type":"array","items":{"type":"string"}}}}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"details":{"type":"array","items":{"type":"string"}}}}}}}}}}}}
```

## Get files associated with a project

> Retrieves a list of all files uploaded to a specific project

```json
{"openapi":"3.0.3","info":{"title":"DeepWriter API","version":"2.0.0"},"tags":[{"name":"File Management","description":"Operations for uploading and managing project files"}],"servers":[{"url":"/api","description":"API base path"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT token for user session authentication."}},"schemas":{"ProjectFile":{"type":"object","description":"Represents a file uploaded to a project","properties":{"id":{"type":"string","format":"uuid","description":"The unique identifier for the file"},"project_id":{"type":"string","format":"uuid","description":"The ID of the project this file belongs to"},"file_name":{"type":"string","description":"The original name of the uploaded file"},"file_size":{"type":"number","description":"The size of the file in bytes"},"file_type":{"type":"string","description":"The MIME type of the file"},"storage_path":{"type":"string","description":"The path where the file is stored"},"created_at":{"type":"string","format":"date-time","description":"When the file was uploaded"},"updated_at":{"type":"string","format":"date-time","description":"When the file was last updated"}},"required":["id","project_id","file_name","file_size","file_type","storage_path","created_at","updated_at"]},"Error":{"type":"object","properties":{"error":{"type":"string","description":"A message describing the error"}},"required":["error"]}}},"paths":{"/getProjectFiles":{"get":{"summary":"Get files associated with a project","description":"Retrieves a list of all files uploaded to a specific project","tags":["File Management"],"parameters":[{"in":"query","name":"projectId","required":true,"schema":{"type":"string","format":"uuid"},"description":"ID of the project to get files for"}],"responses":{"200":{"description":"Project files retrieved successfully","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ProjectFile"}}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Project not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Delete a project file

> Removes a file from a project and deletes it from storage

```json
{"openapi":"3.0.3","info":{"title":"DeepWriter API","version":"2.0.0"},"tags":[{"name":"File Management","description":"Operations for uploading and managing project files"}],"servers":[{"url":"/api","description":"API base path"}],"security":[{"apiKey":[]},{"bearerAuth":[]}],"components":{"securitySchemes":{"apiKey":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key for external service authentication."},"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT token for user session authentication."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string","description":"A message describing the error"}},"required":["error"]}}},"paths":{"/deleteProjectFile":{"delete":{"summary":"Delete a project file","description":"Removes a file from a project and deletes it from storage","tags":["File Management"],"parameters":[{"in":"query","name":"fileId","required":true,"schema":{"type":"string","format":"uuid"},"description":"ID of the file to delete"}],"responses":{"200":{"description":"File deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"File not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```


---

# 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.deepwriter.com/api-access/file-management.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.
