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:
| Key | Type | Description |
|---|---|---|
file | file | [Required] Document template file |
name | string | [Required] Document template name |
description | string | Document template description |
IsLaborContractTemplate | boolean | Whether 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
| Key | Type | Description |
|---|---|---|
success | boolean | Response status (true: Success, false: Failure) |
code | int | Response code from the system |
messages | array | List of messages or errors returned by the system (see details below) |
data | object | Object containing detailed information about the newly created document template (see details below) |
Details of data:
| Key | Type | Description |
|---|---|---|
id | int | ID of the newly created document template |
name | string | Document template name |
createdDate | string | Document template creation time (ISO 8601 format) |
fileName | string | Name of the original uploaded file |
downloadUrl | string | URL to download the original template file (.docx) |
pdfDownloadUrl | string | URL to download the file in PDF format |
isDisabled | boolean | Template status (true: Disabled, false: Active) |
isLaborContractTemplate | boolean | Whether 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:
| Key | Type | Description |
|---|---|---|
key | string | Identifier key of the data field in the template (e.g., {{day}}, {{month}}) |
name | string | Data field name |
description | string | Detailed description of the meaning of the data field |
Message List
| Message | Description |
|---|---|
| "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 |