Create Template

Creates a document template

Endpoint URLSDK Method
N/ATemplate.create()

Request properties

PropertyTypeRequiredDescription
nameStringYesThe name of the template.
descriptionStringNoThe description of the template.
sourceStringYesThe source format of the template. Valid values are docx, html and pdf.
fileStringYesThe template data.
dataObjectNoDocument settings for HTML templates.
destinationsObjectNoDetails about where and how to store documents generated from the template.

data

PropertyTypeRequiredDescription
widthFloatYesThe width of documents generated by the template.
heightFloatYesThe height of documents generated by the template.
unitStringYesThe unit of measurement for documents generated by the template. Valid values are in and cm.

Response properties

PropertyTypeDescription
created_atStringThe date and time the template was created.
destinationsObjectDetails about where and how to store documents generated from the template.
idStringThe ID of the template.
merge_variablesObjectThe key-value pairs used when generating documents from the template.
nameStringThe name of the template.
sourceStringThe source format of the template.
updated_atStringThe date and time the template was updated.
versionIntegerThe template version number.

Example request and response

# Import the Inkit Python package
import inkit
from inkit.exceptions import InkitResponseException
# Import json package
import json

# Replace the string below with your API key
inkit.api_token = "ENTER YOUR API KEY"

try:
   # Create template
   resp = inkit.Template.create(    
                                name = 'API template',
                                source = 'html',
                                file = '<html>My awesome HTML</html>',
                                data = {
                                        'width': 8.5,
                                        'height': 11.5,
                                        'unit': 'in'
                                        },
                                )
   # Print the repsonse code of the API call
   print(json.dumps(resp.data, indent = 3))
except InkitResponseException as err:
   # Print any error
   print(err.response.data)
// Import the Inkit Node.js package
const Inkit = require("inkit");

// Replace the string below with your API key
Inkit.apiToken = "ENTER YOUR API KEY";

// Call create template
createTemplate();

// Create template
async function createTemplate() {
    try {
        const result = await Inkit.Template.create(    
                                                    name = 'API template',
                                                    source = 'html',
                                                    file = '<html>My awesome HTML</html>',
                                                    data = {
                                                            'width': 8.5,
                                                            'height': 11.5,
                                                            'unit': 'in'
                                                    },
                                                  );
        // Print the JSON response of the API call
        console.log(JSON.stringify(result.data, null, 3));
    } catch (error) {
        // Print any error
        console.error(error.response.status, error.response.statusText);
    }
}
{
   "created_at": "2023-09-06T14:38:27.449668Z",
   "destinations": [
      {
         "expire_after_n_views": null,
         "folder_id": null,
         "id": "dest_4UNZXxK3OYqBIYPPB5mu4P",
         "name": "inkit_storage",
         "required": true,
         "retain_for": null
      }
   ],
   "id": "tmpl_2Ntt3uAF4PxnY8XDJ1FXbg",
   "merge_variables": {},
   "name": "API template",
   "source": "html",
   "updated_at": "2023-09-06T14:38:27.449681Z",
   "version": 1
}