Generating documents that expire

When you generate documents into Inkit's cloud storage, by default they exist forever. But you also can have documents expire after a specific number of views or a certain amount of time. We call these "disappearing documents," and they can enhance the security of your information by limiting access of sensitive data.

You can set up document expiration either in the document template or when you generate a document in the Inkit API.

Setting document expiration in a template

By setting document expiration in a template, all documents generated from that template will have the same expiration settings unless you override them when generating a document using the Inkit API. To set up document expiration in a template, do 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, to have documents expire after certain amount of time, turn the switch beside Expire Document after on and specify the Amount of Time and the Unit of time. You can choose from the following units:

    • Minutes
    • Hours
    • Days
    • Months
    • Years

    To have documents expire after specific number of views, turn the switch beside Expire after an Amount of Views on and enter the number of Views before the document expires.

    Note: You can apply both expiration options at the same time. Whichever option that happens first will trigger the expiration.

    Finally, click Apply.

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

Setting document expiration in the API

To set the document expiration options when you generate the document in the Inkit API, place them in your destinations object.

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

# 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 expirations options of the PDF file
      destinations = {"inkit_storage": {"name": "Mail Merge Python SDK",
                                        "expire_after_n_views": 1,
                                        "retain_for": {"hours": 1}}
   )
   # Print the JSON repsonse of the API call
   print(json.dumps(dict(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 expirations options of the PDF file
            destinations: {"inkit_storage": {"name": "Mail Merge Node.js SDK",
                                            "expire_after_n_views": 1,
                                            "retain_for": {"hours": 1}}}
        });
        // 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 '
{
  "destinations": {
    "inkit_storage": {
      "retain_for": {
        "hours": 1
      },
      "expire_after_n_views": 1,
      "name": "Mail Merge cURL"
    }
  },
  "template_id": "ENTER YOUR TEMPLATE ID"
}
'

📘

Note: If your template specifies a set of expiration options and your API request specifies a different set, the API request takes precedence.