Skip to main content
POST
/
v1
/
documents
/
Upload Document
curl --request POST \
  --url https://api.agentoffice.dev/v1/documents/ \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "ttl_seconds": 123,
  "return_markdown": true,
  "tracked_changes": true,
  "author_name": "<string>"
}'
{
  "detail": "File type not supported. Please upload a .docx or .pdf file"
}

Upload a Document

Upload a Microsoft Word (.docx) or PDF file to create a new document in Agent Office. The document will be stored and ready for AI-powered editing.

Request Parameters

file
file
required
The document file to upload (Word .docx or PDF)
ttl_seconds
integer
Time to live in seconds (300-21600). Default is 3600 (1 hour). The TTL is refreshed after each edit.
return_markdown
boolean
If true, returns a markdown representation of the document. Default is false.
tracked_changes
boolean
Enable tracked changes mode - stores a backup copy of the original document. When enabled, all edits will be shown as tracked changes when you download the document. Default is false.
author_name
string
Author name for tracked changes attribution. Only used if tracked_changes is enabled. Default is “Anonymous”.

Response

docId
string
required
Unique identifier for the uploaded document (UUID format)
name
string
required
Original filename of the uploaded document
createdAt
string
required
ISO 8601 timestamp when the document was created
fileType
string
required
MIME type of the uploaded file
imageAnnotations
array
Array of image annotations if the document contains images
markdown
string
Markdown representation of the document (only if return_markdown=true)

Example Response

{
  "docId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "name": "document.docx",
  "createdAt": "2024-01-15T10:30:00Z",
  "fileType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  "imageAnnotations": null,
  "markdown": null
}
The docId from the response is required for all subsequent operations (editing, downloading, etc.)

Code Examples

const formData = new FormData();
formData.append("file", fileInput.files[0]);
formData.append("ttl_seconds", "3600");
formData.append("tracked_changes", "true");
formData.append("author_name", "John Doe");

const response = await fetch("https://api.agentoffice.dev/v1/documents/", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
  },
  body: formData,
});

const result = await response.json();
console.log("Document ID:", result.docId);

Tracked Changes Feature

When you enable tracked_changes=true at upload time, Agent Office stores a backup copy of your original document. When you make edits and download the document, all changes will be shown as Microsoft Word track changes, making it easy to review what was modified. Example workflow:
  1. Upload document with tracked_changes=true
  2. Make edits using the edit endpoint
  3. Download the document - changes will appear as Word track changes
Use tracked changes when you need a clear audit trail of all modifications made to your document.

Error Responses

{
  "detail": "File type not supported. Please upload a .docx or .pdf file"
}