Docagen icon

Docagen

Generate PDF from templates

Overview

The Docagen node for n8n enables users to generate PDF documents from templates using the Docagen API. Specifically, with the "Export" resource and "Post" operation, this node allows you to create a new PDF export by specifying a template, a file name, and a JSON payload containing the data to populate the template.

Common scenarios:

  • Automating the generation of invoices, reports, or certificates as PDFs based on dynamic data.
  • Integrating document creation into workflows where data is collected, processed, and then output as a formatted PDF.
  • Batch-generating personalized documents for clients or employees.

Practical example:
A company collects order details via an online form, processes them in n8n, and uses this node to generate a custom invoice PDF for each order using a pre-defined template.


Properties

Name Type Meaning
Template ID String The identifier of the template to use for generating the PDF.
File Name String The desired name for the exported PDF file (without the ".pdf" extension).
Payload (JSON) JSON The data object used to fill in the template fields; must be valid JSON.

Output

The node returns a JSON object representing the result of the export operation. While the exact structure depends on the Docagen API response, it typically includes information such as:

{
  "id": "string",          // Unique identifier for the export
  "fileName": "string",    // Name of the generated PDF file
  "url": "string",         // Download URL for the PDF
  "status": "string",      // Status of the export (e.g., 'completed')
  // ...other metadata fields
}

If the API supports binary output (such as direct PDF content), the node may also provide a binary field containing the PDF file.


Dependencies

  • External Service: Requires access to the Docagen API.
  • API Key: You must configure Docagen API credentials in n8n under the name docagenApi.
  • n8n Configuration: Ensure that the credentials are set up and accessible to the workflow.

Troubleshooting

Common issues:

  • Invalid JSON in Payload: If the "Payload (JSON)" property contains invalid JSON, the node will fail to parse it.
    Resolution: Validate your JSON before submitting.
  • Missing Required Fields: Omitting required properties like "Template ID" or "File Name" will cause errors.
    Resolution: Ensure all required fields are filled.
  • Authentication Errors: Incorrect or missing API credentials will result in authentication failures.
    Resolution: Double-check your Docagen API key configuration in n8n.
  • API Errors: If the template ID does not exist or the API service is down, you may receive error messages from Docagen.
    Resolution: Verify the template ID and check the status of the Docagen service.

Common error messages:

  • Invalid JSON: Indicates a problem parsing the "Payload (JSON)" input.
  • 401 Unauthorized: Authentication failed; check your API key.
  • 404 Not Found: The specified template does not exist.

Links and References

Discussion