Skip to content

Get Document Versions

GET
/api/writing/documents/{document_id}/versions

πŸ“œ Get version history for a document

Retrieves complete version history with timestamps, authors, and change descriptions. Enables version comparison and rollback for document recovery and change tracking.

Path Parameters:

  • document_id: Unique identifier of the document

Dependencies:

  • writing_service: Injected IshvanaWritingModule instance

Returns:

  • VersionHistory object with all versions and current version number

Raises:

  • HTTPException 500: If version history retrieval fails

Example Response:

{
    "document_id": "doc_123",
    "versions": [
        {"version": 1, "timestamp": "...", "changes": "Initial version"},
        {"version": 2, "timestamp": "...", "changes": "Added chapter 2"}
    ],
    "current_version": 2
}
document_id
required
Document Id
string

Successful Response

VersionHistory

Complete document version history model.

Provides the complete version history for a document including all versions with their metadata for history browsing and version management.

Fields: document_id: Document identifier versions: Ordered list of all document versions (newest first) total_versions: Total count of versions

Used By: - GET /api/writing/documents/{document_id}/versions endpoint - Version history browser UI - Version comparison selection - Rollback operation source

object
documentId
required
Documentid
string
versions
required
Versions
Array<object>
DocumentVersion

Individual document version model.

Represents a single version in a document’s version history with metadata for version tracking, comparison, and rollback operations.

Fields: version_number: Version identifier (incremental integer) created_at: Timestamp when this version was created word_count: Word count at this version content_hash: SHA256 hash for content integrity verification version_id: Optional unique version identifier created_by: Optional author/creator of this version content_preview: Optional preview snippet of version content change_description: Optional description of changes in this version

Used By: - VersionHistory for version listing - Version comparison operations - Version rollback functionality - Document history timeline

object
versionNumber
required
Versionnumber
integer
createdAt
Createdat

Version creation timestamp

string format: date-time
wordCount
Wordcount

Word count at this version

integer
0
contentHash
Any of:
string
versionId
Any of:
string
createdBy
Any of:
string
contentPreview
Any of:
string
changeDescription
Any of:
string
totalVersions
Any of:
integer

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