Overview
The node "DataMagik Docs" enables generating documents from predefined templates using the DataMagik API. It supports listing available document templates and generating documents in PDF or HTML format by populating templates with custom data.
This node is useful when you want to automate document creation workflows, such as generating invoices, contracts, reports, or personalized letters based on dynamic input data. For example, you can generate a PDF invoice for a customer by specifying a template ID and providing customer details as JSON data.
The "Generate Document" operation automatically waits for the document generation process to complete, handling asynchronous processing and returning either a download URL or the binary content of the generated document.
Properties
| Name | Meaning |
|---|---|
| Template ID | The ID of the template to use for document generation (required). |
| Format | Output format for the generated document. Options: PDF, HTML. |
| Return Type | How to return the generated document. Options: URL (returns a download URL, recommended for large documents), Binary (returns document content directly). |
| Priority | Processing priority for queued requests (only applicable if Return Type is URL). Options: Urgent, High, Normal, Low. |
| Template Data | JSON object containing data to populate the template. Example: {"customer_name": "John Doe", "amount": 1000}. |
| Custom Filename | Optional custom filename for the generated document. |
| Template Branch | Template branch to use, defaults to "main". |
| Template Version | Specific template version to use (optional, defaults to latest). |
| Force Regenerate | Boolean flag indicating whether to force regeneration even if a cached version exists. |
| Document Settings | Collection of settings affecting PDF generation: - Page Size: A4, Letter, Legal, Tabloid - Orientation: Portrait, Landscape - Margins (Top, Right, Bottom, Left) in inches - Show Page Number (boolean) - Print Background (boolean) |
Output
The node outputs an array of items where each item contains:
- json: The JSON response from the DataMagik API, which includes metadata about the generated document such as status, download URLs, filenames, and success indicators.
- binary.data (optional): If the "Return Type" is set to
Binary, the node downloads the document content and returns it as binary data attached under the keydata. The MIME type corresponds to the selected format (application/pdffor PDF,text/htmlfor HTML).
If the "Return Type" is URL, the output JSON will contain a direct download URL for the generated document.
Dependencies
- Requires an API key credential for authenticating with the DataMagik API.
- The node makes HTTP requests to
https://data-magik.com/api/document-designer/endpoints. - No additional environment variables are required beyond the API authentication token.
Troubleshooting
- Invalid JSON in Template Data: If the provided template data is not valid JSON, the node throws an error indicating invalid JSON format. Ensure that the JSON string is correctly formatted.
- Document Generation Timeout: The node waits up to 120 seconds for document generation to complete. If the process takes longer, it throws a timeout error. Consider increasing priority or checking template complexity.
- Document Generation Failed: Errors returned from the API during generation (e.g., missing template, invalid data) are surfaced with descriptive messages. Verify template ID, data correctness, and API credentials.
- No Download URL Found: If the document completes but no download URL is provided, the node throws an error. This may indicate an issue with the template or API response.
- Unknown Operation: If an unsupported operation is specified, the node throws an error. Use only supported operations:
listTemplatesorgenerate.
Links and References
- DataMagik Documentation (assumed official docs for API and templates)
- n8n HTTP Request Node Documentation (for understanding HTTP request usage)
- JSON formatting tools for validating template data input (e.g., https://jsonlint.com)