Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 59 additions & 113 deletions docs/TurboDocx Templating/API Templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import ScriptLoader from '@site/src/components/ScriptLoader';

This comprehensive guide walks you through the Template Generation API integration process. Learn how to programmatically upload new templates or select existing ones, then generate beautiful documents with variable substitution using our RESTful API.

![Template Generation API Integration Overview](/img/template-generation-api/banner.gif)
![Template Generation API Integration Overview](/img/template-generation-api/banner.png)

## Overview

Expand Down Expand Up @@ -77,7 +77,6 @@ Don't want to read the novel? Here's the executive summary:
| `subvariables` | Nested variable structures | `{Employee.FirstName}` | Complex hierarchical data |
| `variableStack` | Multiple instances of content | `{Projects[0].Name}` | Repeating sections, lists |
| `richText` | HTML/formatted text content | `{Description}` | Formatted text with styling |
| `aiPrompt` | AI-generated content | `{Summary}` | Dynamic content generation |

### Complete Dual-Path Workflow

Expand All @@ -89,52 +88,31 @@ Don't want to read the novel? Here's the executive summary:

### Quick Variable Structure Example

Here's what a complex variable payload looks like:
Here's what a simple variable payload looks like:

```json
{
"templateId": "abc123-def456-ghi789",
"name": "Employee Contract Draft",
"description": "Generated contract for new hire",
"name": "Generated Document",
"description": "Simple document example",
"variables": [
{
"name": "Employee",
"placeholder": "{Employee}",
"text": "John Smith",
"subvariables": [
{
"placeholder": "{Employee.Title}",
"text": "Senior Developer"
},
{
"placeholder": "{Employee.StartDate}",
"text": "2024-01-15"
}
]
"mimeType": "text",
"name": "Company Name",
"placeholder": "{CompanyName}",
"text": "Acme Corporation"
},
{
"name": "Projects",
"placeholder": "{Projects}",
"variableStack": {
"0": {
"text": "Project Alpha - Backend Development",
"subvariables": [
{
"placeholder": "{Projects.Duration}",
"text": "6 months"
}
]
},
"1": {
"text": "Project Beta - API Integration",
"subvariables": [
{
"placeholder": "{Projects.Duration}",
"text": "3 months"
}
]
}
}
"mimeType": "text",
"name": "Employee Name",
"placeholder": "{EmployeeName}",
"text": "John Smith"
},
{
"mimeType": "text",
"name": "Date",
"placeholder": "{Date}",
"text": "January 15, 2024"
}
]
}
Expand Down Expand Up @@ -201,8 +179,6 @@ User-Agent: TurboDocx API Client
"templateFile": [DOCX_OR_PPTX_FILE_BINARY],
"name": "Employee Contract Template",
"description": "Standard employee contract with variable placeholders",
"variables": "[]", // Optional: Pre-defined variables (usually extracted automatically)
"tags": "[]" // Optional: Categorization tags
}
```

Expand Down Expand Up @@ -499,84 +475,25 @@ User-Agent: TurboDocx API Client
```json
{
"templateId": "0b1099cf-d7b9-41a4-822b-51b68fd4885a",
"name": "Employee Contract - John Smith",
"description": "Employment contract for new senior developer",
"name": "Contract - John Smith",
"description": "Simple contract example",
"variables": [
{
"mimeType": "text",
"name": "Company Name",
"placeholder": "{CompanyName}",
"text": "Acme Corporation"
},
{
"name": "Employee Name",
"placeholder": "{EmployeeName}",
"text": "John Smith",
"allowRichTextInjection": 0,
"autogenerated": false,
"count": 1,
"order": 1,
"subvariables": [
{
"placeholder": "{Employee.Title}",
"text": "Senior Software Developer"
},
{
"placeholder": "{Employee.StartDate}",
"text": "January 15, 2024"
}
],
"aiPrompt": "Generate a professional job description for a senior developer role"
"text": "John Smith"
},
{
"mimeType": "text",
"name": "Department",
"placeholder": "{Department}",
"text": "Engineering",
"allowRichTextInjection": 1,
"autogenerated": false,
"count": 3,
"order": 2,
"subvariables": [
{
"placeholder": "{Department.Manager}",
"text": "Sarah Johnson"
}
],
"variableStack": {
"0": {
"text": "Frontend Development Team",
"subvariables": [
{
"placeholder": "{Team.Focus}",
"text": "React and TypeScript development"
}
]
},
"1": {
"text": "Backend Development Team",
"subvariables": [
{
"placeholder": "{Team.Focus}",
"text": "Node.js and database optimization"
}
]
}
},
"metadata": {
"customField": "Engineering Department"
},
"aiPrompt": "Describe the key responsibilities of the engineering department"
"name": "Date",
"placeholder": "{Date}",
"text": "January 15, 2024"
}
],
"tags": ["hr-template", "contract", "full-time"],
"fonts": "[{\"name\":\"Arial\",\"usage\":269}]",
"defaultFont": "Arial",
"replaceFonts": true,
"metadata": {
"sessions": [
{
"id": "session-abc123",
"starttime": "2024-01-15T14:12:10.721Z",
"endtime": "2024-01-15T14:13:45.724Z"
}
]
}
]
}
```

Expand Down Expand Up @@ -736,6 +653,35 @@ Content-Length: 287456
label="Final Step: Generate Deliverable Examples"
/>

## Advanced File Attachment Examples

For advanced workflows that combine template upload with data file processing, explore these comprehensive examples that demonstrate Excel file attachment, sheet selection, and AI variable generation integration.

### File Attachment with Sheet Selection

These examples show how to upload templates alongside Excel data files, with specific sheet selection and data range configuration for AI-powered variable generation:

<ScriptLoader
scriptPath="templates/api/file-attachment-examples"
id="file-attachment-examples"
label="Advanced File Attachment Examples"
/>

### Key Features Demonstrated

- **📊 Excel File Attachment**: Upload spreadsheet data alongside template files
- **📋 Sheet Selection**: Choose specific sheets from multi-sheet workbooks
- **📐 Data Range Configuration**: Define cell ranges for targeted data analysis
- **🤖 AI Variable Integration**: Pre-configure AI variables that reference attached data
- **🔗 Multi-Sheet Support**: Handle complex workbooks with multiple data sources

### Use Cases

- **Financial Reports**: Upload templates with Q4 financial data and auto-generate summaries
- **Business Analysis**: Combine report templates with multi-sheet business data
- **Data-Driven Documents**: Create documents that pull insights from attached spreadsheets
- **Dynamic Content**: Generate variables based on real-time data uploads

## Best Practices

### Security
Expand Down
Loading