DataMagik Docs icon

DataMagik Docs

Generate documents from templates using DataMagik API

Generate Document

AI-generated

Summary

Generate a document from a specified template using provided data and configuration options, returning either a download URL or the document content directly.

Inputs

  • Template ID (required) — The ID of the template to use for document generation.
  • Format (required) — Choose the output format of the generated document, either PDF or HTML.
  • Return Type (required) — Select how to receive the generated document: as a download URL (recommended for large files) or binary data directly embedded in the output.
  • Priority — Set the processing priority for queued requests when returning a URL; options include Urgent, High, Normal, and Low.
  • Template Data (required) — A JSON object containing key-value pairs to populate fields within the document template.
  • Custom Filename — Optional custom filename for the generated document.
  • Template Branch — Specify the template branch to use; defaults to 'main'.
  • Template Version — Optionally specify a template version; if omitted, the latest version is used.
  • Force Regenerate — Boolean flag to force regeneration of the document even if a cached version exists.
  • Document Settings — Configuration collection for document layout and styling including page size, orientation, margins, page numbering, and background printing options.

Output shape

A list with one item per input, each containing JSON metadata about the generated document and optionally binary data of the document file if 'Binary' return type is selected.

When 'Return Type' is set to 'URL', the output JSON includes a download URL for the document. When set to 'Binary', the document content is fetched and returned as binary data under the 'data' field with appropriate MIME type and filename. The node waits up to 120 seconds for document generation completion, polling the document status. If generation fails or times out, an error is thrown unless 'Continue On Fail' is enabled.

Discussion