Create Template
Creates a document template
Endpoint URL | SDK Method |
---|---|
N/A | Template.create() |
Request properties
Property | Type | Required | Description |
---|---|---|---|
name | String | Yes | The name of the template. |
description | String | No | The description of the template. |
source | String | Yes | The source format of the template. Valid values are docx , html and pdf . |
file | String | Yes | The template data. |
data | Object | No | Document settings for HTML templates. |
destinations | Object | No | Details about where and how to store documents generated from the template. |
data
data
Property | Type | Required | Description |
---|---|---|---|
width | Float | Yes | The width of documents generated by the template. |
height | Float | Yes | The height of documents generated by the template. |
unit | String | Yes | The unit of measurement for documents generated by the template. Valid values are in and cm . |
Response properties
Property | Type | Description |
---|---|---|
created_at | String | The date and time the template was created. |
destinations | Object | Details about where and how to store documents generated from the template. |
id | String | The ID of the template. |
merge_variables | Object | The key-value pairs used when generating documents from the template. |
name | String | The name of the template. |
source | String | The source format of the template. |
updated_at | String | The date and time the template was updated. |
version | Integer | The 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
}
Updated 12 months ago