Overview
DigiDoc is a document generation API that takes DOCX templates with variables and renders them into finalized PDF or DOCX documents.
Creating Templates
Templates are standard .docx files created in Word, Google Docs, or LibreOffice. Insert placeholders using docxtpl (Jinja2) syntax. See the docxtpl documentation for advanced features.
Basic Variables
Wrap variable names in double curly braces:
{# In your DOCX, type: #}
{{ customer_name }}
{{ invoice_date }}
{{ total_amount }}
Example data:
{
"customer_name": "Acme Corp",
"invoice_date": "June 17, 2026",
"total_amount": "$1,250.00"
}
Loops (Tables & Lists)
Use {% for %} to repeat sections — great for invoice line items:
{# Select the table row and wrap it: #}
{% for item in items %}
{{ item.name }} {{ item.quantity }} {{ item.price }}
{% endfor %}
Example data:
{
"items": [
{ "name": "Widget", "qty": "2", "price": "$10" },
{ "name": "Gadget", "qty": "1", "price": "$25" }
]
}
{% for item in items %} and {% endfor %}.Conditionals
{% if show_discount %}
Discount: {{ discount_amount }}
{% endif %}
Images in Templates
Images can be injected dynamically. Three ways to reference them:
Storage Images (Recommended)
Upload an image in the admin panel, then reference it by name or ID:
{
"company_logo": "storage::MyLogoName"
}
The storage:: prefix tells DigiDoc to look up the image from your library.
Base64 with Custom Size
{
"photo": {
"data": "iVBORw0KGgoAAAANSUhEUg...",
"width": 100,
"height": 50,
"unit": "mm"
}
}
Units: mm (default), inches, pt.
Data URI
{
"photo": "data:image/png;base64,iVBORw0KGgo..."
}
Images in Loops
Nested images work inside {% for %} loops too:
{
"products": [
{ "name": "Widget", "thumb": "storage::widget_thumb" },
{ "name": "Gadget", "thumb": "storage::gadget_thumb" }
]
}
API Usage
All API endpoints require an X-API-Key header. Generate a key from API Keys.
List Templates
curl -H "X-API-Key: df_your_key_here" API_BASE_URL/api/v1/templates
Upload Template
| Param | Type | Description | |
|---|---|---|---|
file | File | required | The .docx file |
name | String | optional | Custom alias |
category_id | String | optional | Category UUID |
curl -X POST -H "X-API-Key: df_your_key_here" \ -F "file=@invoice.docx" \ -F "name=My Invoice" \ -F "category_id=YOUR_CATEGORY_UUID" \ API_BASE_URL/api/v1/templates
Render Document
| Param | Type | Description | |
|---|---|---|---|
template_id | String | opt* | Registered template ID |
template_name | String | opt* | Registered template name |
template | File | opt* | Upload file directly |
data | JSON | required | Template variables as JSON string |
output_format | String | optional | Default: docx |
* Provide exactly one of template_id, template_name, or template file.
# By template ID curl -X POST -H "X-API-Key: df_your_key_here" \ -F "template_id=abc-123-def" \ -F 'data={"customer":"Acme Corp"}' \ -F "output_format=pdf" \ API_BASE_URL/api/v1/render --output invoice.pdf # By template name curl -X POST -H "X-API-Key: df_your_key_here" \ -F "template_name=My Invoice" \ -F 'data={"customer":"Acme Corp"}' \ -F "output_format=pdf" \ API_BASE_URL/api/v1/render --output invoice.pdf # Upload template file directly curl -X POST -H "X-API-Key: df_your_key_here" \ -F "template=@invoice.docx" \ -F 'data={"customer":"Acme Corp"}' \ -F "output_format=pdf" \ API_BASE_URL/api/v1/render --output invoice.pdf
List Images
curl -H "X-API-Key: df_your_key_here" API_BASE_URL/api/v1/images
List Categories
Returns categories associated with your API key's workspace — no query params needed.
curl -H "X-API-Key: df_your_key_here" API_BASE_URL/api/v1/categories
Upload Image
| Param | Type | Description | |
|---|---|---|---|
file | File | required | The image file |
name | String | optional | Custom alias |
category_id | String | optional | Category UUID |
curl -X POST -H "X-API-Key: df_your_key_here" \ -F "file=@logo.png" \ -F "name=Company Logo" \ -F "category_id=YOUR_CATEGORY_UUID" \ API_BASE_URL/api/v1/images
Output Formats
| Format | Description |
|---|---|
docx | Word Document |
pdf | Portable Document Format |
API Keys
Keys are associated with your account and scoped to a workspace.
- Generate keys from API Keys — must select a workspace
- The key is shown once on creation, and can be revealed later via the eye icon in the keys list (encrypted storage)
- Toggle active/inactive or delete keys from the admin panel
- Keys are workspace-scoped: list endpoints only return resources in that workspace, uploads auto-assign it, and render returns 403 on workspace mismatch
- Rate limit: 10 requests per 60 seconds by default