Generate Document
Generates a document from a template and a set of merge parameters and stores it in a destination
Endpoint URL | SDK Method |
---|---|
https://api.inkit.com/v1/generate (POST) | Render.create() |
Request properties
Property | Type | Required | Description |
---|---|---|---|
template_id | String | Yes | The ID of the template that you'll use when generating the document. |
name | String | No | The name of the document object. |
description | String | No | The description of the document object. |
merge_paremeters | Object | Yes | The key-value pairs that you'll use when generating your document. The data you supply here will replace the fields you have embedded in your document template. |
destinations | Object | No | Details about where and how you want to store the generated document. |
Response properties
Property | Type | Description |
---|---|---|
amazon_s3_piece_id | String | The Amazon S3 document ID if the generation includes a Amazon S3 destination. |
box_piece_id | String | The Box document ID if the generation includes a Box destination. |
document_id | String | The Inkit Storage document ID. |
docusign_piece_id | String | The DocuSign document ID if the generation includes a DocuSign destination. |
dropbox_piece_id | String | The Dropbox document ID if the generation includes a Dropbox destination. |
google_drive_piece_id | String | The Google Drive document ID if the generation includes a Google Drive destination. |
id | String | The render ID of the generated document. |
magic_link_piece_id | String | The Magic Link document ID if the generation includes a Magic Link destination. |
mail_piece_id | String | The Sepire document ID if the generation includes a Sepire destination. |
salesforce_piece_id | String | The Salesforce document ID if the generation includes a Salesforce destination. |
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 a PDF document from a template
resp = inkit.Render.create(
# Specify the ID of the template
template_id = "ENTER YOUR TEMPLATE ID",
# Specify the data for the Name field
merge_parameters = {"Name": "John"},
# Specify the name of the PDF file
destinations = {"inkit_storage": {"name": "Mail Merge Python SDK"}}
)
# Print the JSON repsonse 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 the PDF renderer
createRender();
// Create a PDF document from a template
async function createRender() {
try {
const result = await Inkit.Render.create({
// Specify the ID of the template
templateId: 'ENTER YOUR TEMPLATE ID',
// Specify the data for the Name field
mergeParameters: {"Name": "John"},
// Specify the name of the PDF file
destinations: {"inkit_storage": {"name": "Mail Merge Node.js SDK"}}
});
// 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);
}
}
curl --request POST \
--url https://api.inkit.com/v1/generate \
--header 'Content-Type: application/json' \
--header 'X-Inkit-API-Token: ENTER YOUR API KEY' \
--header 'accept: application/json' \
--data '
{
"merge_parameters": {
"Name": "John"
},
"destinations": {
"inkit_storage": {
"name": "Mail Merge cURL"
}
},
"template_id": "ENTER YOUR TEMPLATE ID"
}
'
{
"document_id": "doc_IAjDpXZR1PKPXmkWttJFE",
"id": "rend_5oGScGXBnDpKJbXnm4u6J7"
}
Updated 9 months ago