Skip to content

Create Document Template

POST
/api/writing/templates

📄 Create a new document template

Creates a reusable document template with predefined structure, content, and variables for consistent document creation. Templates support variable substitution for dynamic content generation.

Request Body:

  • request: TemplateCreateRequest with name, description, content, and variables

Dependencies:

  • writing_service: Injected IshvanaWritingModule instance

Returns:

  • Created DocumentTemplate object with generated ID

Raises:

  • HTTPException 500: If template creation fails

Example Response:

{
    "template_id": "template_1703001234.567",
    "name": "Character Profile",
    "description": "Standard character profile template",
    "category": "character",
    "content": "Name: {{character_name}}...",
    "variables": ["character_name", "age", "background"]
}
TemplateCreateRequest

Document template creation request model.

Request model for creating new document templates with variable placeholders for reusable document patterns.

Fields: name: Template name description: Template purpose description category: Template category for organization content: Template content with {{variable}} placeholders variables: List of variable names used in template

Used By: - POST /api/writing/templates endpoint - Template creation UI - Template import functionality

object
name
required
Name
string
description
required
Description
string
category
required
Category
string
content
required
Content
string
variables
required
Variables
Array<string>

Successful Response

DocumentTemplate

Document template model with variable substitution.

Represents a reusable document template with placeholders for variable substitution, enabling rapid document creation with consistent structure.

Fields: template_id: Unique template identifier name: Template name description: Template purpose and usage description category: Template category for organization content: Template content with variable placeholders variables: List of variable names for substitution

Variable Format: Content: “The {{character_name}} wielded the {{weapon_name}}” Variables: [“character_name”, “weapon_name”]

Used By: - TemplateResponse for template retrieval - DocumentFromTemplateRequest for instantiation - Template browser and selection UI - Rapid document creation workflows

object
templateId
required
Templateid
string
name
required
Name
string
description
required
Description
string
category
required
Category
string
content
required
Content
string
variables
required
Variables
Array<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