DataMagik icon

DataMagik

DataMagik Manufacturing & Document Automation API

Document → Generate Document

AI-generated

Summary

Generate a document from a DataMagik template.

Inputs

  • templateId (required) — Select a template from the gallery or enter a template ID manually. If 'MANUAL' is selected, the templateIdManual field is required.
  • format — Output format for the generated document. Options: PDF, HTML, CSV, Tab-Delimited, Excel (XLSX), XML, JSON Export, Custom Text (Oracle ASNB). Default: PDF.
  • returnType — How to return the generated document. URL (recommended for large documents) or Binary (returns content directly). Default: URL.
  • priority — Processing priority for queued requests. Only shown when returnType is URL. Options: Urgent, High, Normal, Low. Default: Normal.
  • templateData — JSON object containing data to populate the template. Default: {}.
  • fileName — Custom filename for the generated document. Optional.
  • branch — Template branch to use. Default: main.
  • version — Specific template version. Optional, defaults to latest.
  • forceRegenerate — Whether to force regeneration even if a cached version exists. Default: false.
  • documentSettings — Document layout and printing settings (page size, orientation, margins, page numbers, background printing).
  • csvOptions — CSV-specific options (include header row, BOM for Excel, quote all fields). Shown when format is CSV or Tab-Delimited.
  • excelOptions — Excel-specific options (sheet name, auto-filter, freeze header, header style). Shown when format is Excel.
  • xmlOptions — XML-specific options (root element, row element, XML declaration, pretty print). Shown when format is XML.
  • jsonOptions — JSON-specific options (pretty print, root property, include null values). Shown when format is JSON.
  • customTextOptions — Custom text-specific options (output format, line ending). Shown when format is Custom Text (Oracle ASNB).

Output shape

Depends on returnType selected.

If returnType is URL: The node polls the DataMagik status endpoint for up to 2 minutes until the document generation completes, then returns the response object containing a download_url. If the request times out, an error is thrown. Recommended for large documents as it avoids holding binary data in the workflow execution. If returnType is Binary: The node polls the status endpoint for up to 2 minutes, then fetches the document via a basic-auth GET request. Returns the document content as binary data with the appropriate MIME type and filename. The binary output includes data (arraybuffer) and filename. Errors for template not found (404) or authentication failures (401) are surfaced with descriptive messages.

Examples

Example 1: Generate a PDF document from a selected template with data, returning a download URL.

templateId: selected from dropdown; format: PDF; returnType: URL; templateData: { customerName: 'Acme Corp' }; priority: Normal

Example 2: Generate an Excel file from a template with custom filename and settings.

templateId: manual ID '1097823044285431810'; format: Excel; returnType: Binary; fileName: 'report-2024.xlsx'; excelOptions: { sheetName: 'Data', headerStyle: 'bold' }; templateData: { parts: [...] }

Discussion