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>"
}
'import requests
url = "https://api.agentoffice.dev/v1/documents/"
payload = {
"ttl_seconds": 123,
"return_markdown": True,
"tracked_changes": True,
"author_name": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ttl_seconds: 123,
return_markdown: true,
tracked_changes: true,
author_name: '<string>'
})
};
fetch('https://api.agentoffice.dev/v1/documents/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.agentoffice.dev/v1/documents/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ttl_seconds' => 123,
'return_markdown' => true,
'tracked_changes' => true,
'author_name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentoffice.dev/v1/documents/"
payload := strings.NewReader("{\n \"ttl_seconds\": 123,\n \"return_markdown\": true,\n \"tracked_changes\": true,\n \"author_name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.agentoffice.dev/v1/documents/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ttl_seconds\": 123,\n \"return_markdown\": true,\n \"tracked_changes\": true,\n \"author_name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentoffice.dev/v1/documents/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ttl_seconds\": 123,\n \"return_markdown\": true,\n \"tracked_changes\": true,\n \"author_name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"detail": "File type not supported. Please upload a .docx or .pdf file"
}
{
"detail": "File size exceeds maximum allowed size of 10MB"
}
API Reference
Upload Document
Upload a Word or PDF document to Agent Office
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>"
}
'import requests
url = "https://api.agentoffice.dev/v1/documents/"
payload = {
"ttl_seconds": 123,
"return_markdown": True,
"tracked_changes": True,
"author_name": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ttl_seconds: 123,
return_markdown: true,
tracked_changes: true,
author_name: '<string>'
})
};
fetch('https://api.agentoffice.dev/v1/documents/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.agentoffice.dev/v1/documents/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ttl_seconds' => 123,
'return_markdown' => true,
'tracked_changes' => true,
'author_name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentoffice.dev/v1/documents/"
payload := strings.NewReader("{\n \"ttl_seconds\": 123,\n \"return_markdown\": true,\n \"tracked_changes\": true,\n \"author_name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.agentoffice.dev/v1/documents/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ttl_seconds\": 123,\n \"return_markdown\": true,\n \"tracked_changes\": true,\n \"author_name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentoffice.dev/v1/documents/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ttl_seconds\": 123,\n \"return_markdown\": true,\n \"tracked_changes\": true,\n \"author_name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"detail": "File type not supported. Please upload a .docx or .pdf file"
}
{
"detail": "File size exceeds maximum allowed size of 10MB"
}
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
required
The document file to upload (Word .docx or PDF)
integer
Time to live in seconds (300-21600). Default is 3600 (1 hour). The TTL is
refreshed after each edit.
boolean
If true, returns a markdown representation of the document. Default is false.
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.
string
Author name for tracked changes attribution. Only used if tracked_changes is
enabled. Default is “Anonymous”.
Response
string
required
Unique identifier for the uploaded document (UUID format)
string
required
Original filename of the uploaded document
string
required
ISO 8601 timestamp when the document was created
string
required
MIME type of the uploaded file
array
Array of image annotations if the document contains images
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);
import requests
url = 'https://api.agentoffice.dev/v1/documents/'
headers = {
'Authorization': 'Bearer YOUR_API_KEY'
}
with open('document.docx', 'rb') as f:
files = {'file': f}
data = {
'ttl_seconds': 3600,
'tracked_changes': True,
'author_name': 'John Doe'
}
response = requests.post(url, headers=headers, files=files, data=data)
result = response.json()
print(f"Document ID: {result['docId']}")
from agent_office import AgentOffice
import os
client = AgentOffice(api_key=os.getenv('AGENT_OFFICE_API_KEY'))
# Upload with tracked changes enabled
doc = client.documents.create(
file='document.docx',
ttl_seconds=3600,
tracked_changes=True,
author_name='John Doe'
)
print(f"Document ID: {doc.doc_id}")
curl -X POST 'https://api.agentoffice.dev/v1/documents/' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-F 'file=@document.docx' \
-F 'ttl_seconds=3600' \
-F 'tracked_changes=true' \
-F 'author_name=John Doe'
Tracked Changes Feature
When you enabletracked_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:
- Upload document with
tracked_changes=true - Make edits using the edit endpoint
- 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"
}
{
"detail": "File size exceeds maximum allowed size of 10MB"
}

