Skip to content

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” }

Body_export_document_api_writing_export_document_post
object
document_id
required
Document Id
string
format
Format
string
default: docx
content
Content
string
""
title
Title
string
default: Untitled Document
include_toc
Include Toc
boolean

Successful Response

DocumentExportResponse

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 document
  • format: Export format identifier (“docx”, “pdf”, “txt”, “md”)
  • export_path: Filesystem path to exported file
  • timestamp: 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
status
required
Status

Export status

string
documentId
required
Documentid

Document ID that was exported

string
format
required
Format

Export format

string
exportPath
required
Exportpath

Filesystem path to exported file

string
timestamp
required
Timestamp

Export timestamp (ISO format)

string

Validation Error

HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object