Specifying folders when generating documents

When you generate documents in Inkit, by default the document is placed in your Root folder. If you want to generate a document in another folder, you must specify this folder either in the Inkit web app or in an API request.

Specifying a folder in the Inkit web app

To specify a folder when you generate a document in the Inkit web app, you set this folder in the document template, by doing the following:

  1. Select Templates in the left sidebar, then click on the ... menu button beside the template you want to change and click Edit.

  2. In the Edit page, click the settings gear of the Inkit Storage icon in the Destinations panel.

  3. In the Inkit Storage Settings dialog box, select the folder in the Folder dropdown box and click Apply.

  4. To save your changes to the template, click Save.

Specifying a folder in an API request

To specify a folder when you generate a document in an Inkit API request, first copy the folder ID. To do this, in the Inkit web app click Documents in the left sidebar and then click the copy button beside the folder ID you want to copy.

Next, place the ID in the destinations object when you generate the document.

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

# 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 and the folder ID of the PDF file
    destinations = {"inkit_storage": {"name": "Mail Merge Python SDK",
                                      "folder_id": "ENTER YOUR FOLDER ID"}}
  )
  # 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 and the folder ID of the PDF file
            destinations: {"inkit_storage": {"name": "Mail Merge Node.js SDK",
                                            "folder_id": "ENTER YOUR FOLDER ID"}}
        });
        // 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",
      "folder_id": "ENTER YOUR FOLDER ID"
    }
  },
  "template_id": "ENTER YOUR TEMPLATE ID"
}
'

📘

Note: If your template specifies a folder and your API request specifies a different one, the API request takes precedence.