Extract Template Placeholders and Generate Preview
The Extract Template Placeholders and Generate Preview endpoint parses an uploaded DOCX or PPTX file and returns every {placeholder} variable and font it found, without creating a template. By default it also renders a PDF preview of the file and returns it inline. This lets you show a user exactly what variables a file contains, and what it looks like, before they commit to uploading it as a template.
When to use it
Use this endpoint to build an "upload and preview" step ahead of Upload Template with Optional Default Values: show the detected placeholders so the user can confirm or rename them, and show the rendered PDF so they can confirm it's the right file. Pass skipFile=true if you only need the extracted variables and fonts and want to skip the (slower) PDF render.
Example request
curl -X POST "https://api.turbodocx.com/template/file?skipFile=true" \
-H "Authorization: Bearer $TURBODOCX_API_KEY" \
-H "x-rapiddocx-org-id: $TURBODOCX_ORG_ID" \
-F "file=@./sow-template.docx"
Example response
With skipFile=true:
{
"data": {
"results": {
"filetype": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"vars": [
{
"placeholder": "{CustomerName}",
"name": "CustomerName",
"mimeType": "text",
"order": 0,
"count": 1,
"allowRichTextInjection": false
}
],
"fonts": [{ "name": "Calibri" }]
}
}
}
Without skipFile, the response also includes templatePdf, the rendered PDF of the uploaded file. It is a JSON-serialized Node.js Buffer, not a base64 string: an object of the form {"type": "Buffer", "data": [37, 80, 68, 70, ...]}, where data is an array of the PDF's raw bytes. To use it, reconstruct the binary from the byte array, for example Buffer.from(templatePdf.data) in Node.js or new Uint8Array(templatePdf.data) in the browser. Pass the vars array as the variables field (JSON-stringified) when you subsequently call Upload Template with Optional Default Values.
Common errors
| Status | When | Response body |
|---|---|---|
| 401 | Missing or invalid API key/token, or the organization cannot be resolved | Empty (status only) |
| 403 | The key's role is not administrator, contributor, or user | Empty (status only) |
| 400 | No file was attached, or the file could not be uploaded ("Improper File Upload") | { "message", "error", "data": { "explanation", "context" } } |
| 400 | The file type is not supported (not DOCX, PPTX, or HTML) | { "message": "Unsupported File Type", "error", "data": { "explanation", "context" } } |
| 400 | Your plan's template or storage limit is reached | { "message", "type", "data": { "explanation", "context" } } |
| 503 | The storage service is temporarily unavailable | { "message", "error", "data": { "explanation", "context" } } |
Related endpoints
-
Upload Template with Optional Default Values to create the template from the same file
-
Get Templates and Folders to browse existing templates
POST/template/file