Re-Upload Template
The re-upload template endpoint allows you to upload a new version of an existing template.
Request
PUT /v1/templates/{template_id}/content
Path Parameters
Parameter | Type | Description |
---|---|---|
template_id | string | The unique identifier of the template to update |
Request Body
The request must be sent as multipart/form-data
with the following fields:
Field | Type | Description |
---|---|---|
name | string | The name of the template file (must end with .docx) |
file | file | The Word document template file (max 10MB) |
The template will be validated for proper tag format and content before being accepted.
Response
The endpoint returns a 200 status code and an empty JSON object if the template is successfully updated.
{}
Examples
import { readFileSync } from 'fs';
const apiKey = "Your_API_Key";
const templateId = "your_template_id";
const file = readFileSync('template.docx');
const blob = new Blob([file]);
const formData = new FormData();
formData.append('name', 'template.docx');
formData.append('file', blob);
const response = await fetch(`https://templatedocs.io/api/v1/templates/${templateId}/content`, {
method: 'PUT',
headers: {
"Authorization": `Bearer ${apiKey}`
},
body: formData
});
Error Responses
The endpoint returns errors in the standard error format with optional details:
{
error: {
status: number,
message: string,
details?: {
type: "Message",
message: string
}[]
}
}
Example Error Response
{
"error": {
"status": 400,
"message": "Template validation errors",
"details": [
{
"type": "Message",
"message": "Template contains no tags"
}
]
}
}