Skip to main content
Version: 2.3.0

Create document template

Updated date: 18/08/2026
Updated by: VNPT eContract's team


Purpose​

The function performs the creation of a new document template with input data in .docx format.

  • Request URL: /api/document-templates/create
  • HTTP method: POST
  • HTTP content-type: multipart/form-data
  • Authorize: Bearer token
  • Parameter:
KeyTypeDescription
filefile[Required] Document template file
namestring[Required] Document template name
descriptionstringDocument template description
IsLaborContractTemplatebooleanWhether this is a labor contract template (true: Yes, false: No)

Sample response body​

{
"data": {
"id": 1149,
"name": "Batch import template",
"createdDate": "2022-11-22T14:18:25.3990136",
"fillableFields": [
{
"key": "{{day}}",
"name": "day",
"description": "Day"
},
{
"key": "{{month}}",
"name": "month"
},
{
"key": "{{year}}",
"name": "year"
}
],
"fileName": "dochub-template.docx",
"downloadUrl": "{HOST}/Api/Download?token=...",
"pdfDownloadUrl": "{HOST}/Api/Download?token=...",
"isDisabled": false,
"isLaborContractTemplate": false
},
"success": true,
"code": 0,
"messages": [
"Create file template success"
]
}

Response Body Description​

KeyTypeDescription
successbooleanResponse status (true: Success, false: Failure)
codeintResponse code from the system
messagesarrayList of messages or errors returned by the system (see details below)
dataobjectObject containing detailed information about the newly created document template (see details below)

Details of data:​

KeyTypeDescription
idintID of the newly created document template
namestringDocument template name
createdDatestringDocument template creation time (ISO 8601 format)
fileNamestringName of the original uploaded file
downloadUrlstringURL to download the original template file (.docx)
pdfDownloadUrlstringURL to download the file in PDF format
isDisabledbooleanTemplate status (true: Disabled, false: Active)
isLaborContractTemplatebooleanWhether this is a labor contract template (true: Yes, false: No)

Details of fillableFields:​

The list contains the dynamic data fields in the document template, with the following properties for each element:

KeyTypeDescription
keystringIdentifier key of the data field in the template (e.g., {{day}}, {{month}})
namestringData field name
descriptionstringDetailed description of the meaning of the data field

Message List​

MessageDescription
"Create file template success"Document created successfully
"Can not find any placeholder"Missing {{*}} dinamic field(s) in file
"Extension (.*) is not allowed!"Invalid file format