Displaying generated documents through Magic Links
If you don't have the ability to display generated documents in your own application, you can let your customers securely view documents generated in Inkit using a Magic Link. With a Magic Link, anyone can view a document for either a specific period of time or a specific number of views.
To create a Magic Link, do the following:
-
Edit a document template by clicking Template in the left sidebar and then double-clicking the template.
-
In the Edit Template page, click + Add in the Destinations panel.
In the Add Destination dialog box, click Magic Link and then click Continue.
In the Magic Link Settings dialog box, select the Authentication Type from the dropdown box. You can either choose Social, for a social login such as Google (recommended), or Email.
Then choose either Expire after to have the document expire after a specific amount of time or Expire after an Amount of Views to have it expire after a specific number of views. If you choose Expire after, set the Amount of Time and the Unit of time. You can choose from the following units:
- Minutes
- Hours
- Days
- Months
- Years
Next, select either Start expiration time when link is created or Start expiration time when link is opened. If you choose Expire after an Amount of Views, enter the number of Views before the document becomes expired.
Finally, click Save.
Save the template by clicking Save.
-
Generate the document through the API.
# 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 merge merge_parameters = {"Last": "Doe", "First": "John", "Middle": "X", "Address": "1234 Main St.", "Apt": "#1", "City": "New York", "State": "NY", "Zip": "10001", "Birth": "01/01/1980", "SSN": "123-45-6789", "Email": "[email protected]", "Phone": "(555) 555-5555", "Citizen": "X",}, # Specify the name of the PDF file destinations = {"inkit_storage": {"name": "John Doe I-9"}, "magic_link": {"retain_from_created": {"hours": 1}, "auth_email": "[email protected]", "recipient_email": "[email protected]", "expire_after_n_views": 1}} ) # 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: {"Last": "Doe", "First": "John", "Middle": "X", "Address": "1234 Main St.", "Apt": "#1", "City": "New York", "State": "NY", "Zip": "10001", "Birth": "01/01/1980", "SSN": "123-45-6789", "Email": "[email protected]", "Phone": "(555) 555-5555", "Citizen": "X",}, // Specify the name of the PDF file destinations: {"inkit_storage": {"name": "John Doe I-9"}, "magic_link": {"retain_from_created": {"hours": 1}, "auth_email": "[email protected]", "recipient_email": "[email protected]", "expire_after_n_views": 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 ' { "merge_parameters": { "Last": "Doe", "First": "John", "Middle": "X", "Address": "1234 Main St.", "Apt": "#1", "City": "New York", "State": "NY", "Zip": "10001", "Birth": "01/01/1980", "SSN": "123-45-6789", "Email": "[email protected]", "Phone": "(555) 555-5555", "Citizen": "X" }, "destinations": { "inkit_storage": { "name": "John Doe I-9" } }, "template_id": "ENTER YOUR TEMPLATE ID" } '
Updated 12 days ago