Export Document
POST /api/writing/export/document
📤 Export a document to file.
Exports a document to the specified format with proper formatting, metadata, and structure preservation. Uses Pandoc for PDF/DOCX conversion. Supports multiple output formats for versatile document sharing and publishing.
Args: document_id: Unique ID of document to export format: Export format - “docx”, “pdf”, “txt”, “md”, “html” (default: “docx”) content: Document content (HTML) to export title: Document title for metadata include_toc: Include table of contents (PDF/DOCX only)
Returns: DocumentExportResponse: Export result with file path and format information
Raises: HTTPException: 400 if unsupported format, 500 if export fails
Example Response: { “status”: “success”, “document_id”: “doc_123”, “format”: “docx”, “export_path”: “exports/document_123.docx”, “timestamp”: “2024-12-19T10:00:00Z” }
Request Body required
Section titled “Request Body required ”object
Responses
Section titled “ Responses ”Successful Response
Document export API response model.
Provides confirmation and file information for document export operations including export status, document identification, output format, file path, and export timestamp. Used for multi-format document export with metadata preservation.
Fields:
status: Export operation status (“success” or “error”)document_id: Unique identifier of exported documentformat: Export format identifier (“docx”, “pdf”, “txt”, “md”)export_path: Filesystem path to exported filetimestamp: ISO 8601 timestamp of export operation
Supported Formats:
"docx": Microsoft Word document format (default)"pdf": Portable Document Format"txt": Plain text format"md": Markdown format
Export Features:
- Format conversion with metadata preservation
- Structure and formatting retention
- Custom export options (future)
- Batch export support (future)
- Template-based export (future)
Usage: POST /api/creative/export/document returns this response model.
JSON Example (Success):
{
"status": "success",
"documentId": "doc_abc123",
"format": "docx",
"exportPath": "/exports/doc_abc123.docx",
"timestamp": "2025-01-31T10:30:00Z"
}
JSON Example (PDF Export):
{
"status": "success",
"documentId": "doc_abc123",
"format": "pdf",
"exportPath": "/exports/doc_abc123.pdf",
"timestamp": "2025-01-31T10:30:00Z"
}
Integration:
- ImportExportService: Performs document export with format conversion
- File System: Writes exported file to specified path
- Frontend UI: Provides download link and export confirmation
- Publishing Workflows: Enables document publishing and sharing
object
Export status
Document ID that was exported
Export format
Filesystem path to exported file
Export timestamp (ISO format)
Validation Error