Create Document From Template
POST /api/writing/templates/{template_id}/create-document
📝 Create document from template
Creates a new document by instantiating a template with specific variable values. Variables in the template (e.g., {{character_name}}) are replaced with the provided values to generate a customized document.
Path Parameters:
template_id: ID of the template to use
Request Body:
title: Title for the new documentvariables: Dictionary of variable substitutions (e.g., {“name”: “Aragorn”})
Dependencies:
writing_service: Injected IshvanaWritingModule instance
Returns:
- DocumentResponse with the newly created document
Raises:
HTTPException 404: If template not foundHTTPException 500: If document creation fails
Example Request:
{
"title": "Aragorn Character Profile",
"variables": {
"character_name": "Aragorn",
"age": "87",
"race": "Human"
}
}Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Request Body required
Section titled “Request Body required ”Document creation from template request model.
Request model for creating a new document by instantiating a template with specific variable values.
Fields: title: Title for the new document variables: Variable substitution values (e.g., {“character_name”: “Valko”})
Used By: - POST /api/writing/templates/{template_id}/create endpoint - Template instantiation UI - Batch document generation from templates
Responses
Section titled “ Responses ”Successful Response
Single document response model.
Response containing a single document with its complete metadata.
Fields: status: Response status (“success”, “error”) document: Complete document metadata
Used By: - GET /api/writing/documents/{document_id} endpoint - Document retrieval operations - Document editor initialization
object
Document metadata model for writing documents.
Comprehensive metadata model for all writing documents including creative writing, lore entries, worldbuilding documents, and general notes. Uses IshvanaBaseModel for automatic snake_case → camelCase JSON conversion.
Fields:
document_id: Unique document identifier
project_id: Owning project ID (empty string for unscoped documents)
title: Document title
document_type: Type classification (lore, character, location, general)
tags: Categorization and search tags
created_at: Creation timestamp (auto-generated)
updated_at: Last modification timestamp (auto-generated)
version: Current version number (increments on each update)
word_count: Total word count for writing metrics
custom_fields: User-defined custom metadata
folder_id: Containing folder ID, None for top-level
is_fork_branch: Whether this document is a fork branch off a root
Used By: - DocumentListResponse for document listings - DocumentResponse for single document retrieval - AdvancedSearchResponse for search results - Document browser and editor UI - Version history tracking
object
Document creation timestamp
Last update timestamp
object
Validation Error