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

ParameterTypeDescription
template_idstringThe unique identifier of the template to update

Request Body

The request must be sent as multipart/form-data with the following fields:

FieldTypeDescription
namestringThe name of the template file (must end with .docx)
filefileThe Word document template file (max 10MB)

Response

On success, the endpoint returns the updated template metadata.
See the GET Template endpoint response description for more information on the TemplateMetadata type.

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"
      }
    ]
  }
}