# n8n (/docs/guides/n8n)

> Render Druckling documents in n8n workflows and start workflows when a document is rendered, fails or expires.

The `n8n-nodes-druckling` community package adds two nodes to [n8n](https://n8n.io): **Druckling**, which renders documents and reads documents and templates, and **Druckling Trigger**, which starts a workflow when a document is rendered, fails or expires. Use them to turn orders, form submissions or spreadsheet rows into invoices, certificates and tickets, and to send the PDF on.

## Install the package [#install-the-package]

<Callout type="info" title="Not on npm yet">

`n8n-nodes-druckling` isn't published to npm yet, so installing it by name under **Settings › Community Nodes** doesn't work yet. Install it from the Druckling source repository on a self-hosted n8n, as below. On n8n Cloud, which only offers verified community nodes, connect through the [MCP Client Tool](/docs/guides/mcp) instead.

</Callout>

<Steps>
<Step>

### Build the package [#build-the-package]

```bash
git clone https://github.com/vulpery/druckling.git
cd druckling/src/integrations/n8n-nodes-druckling
npm install
npm run build
npm pack
```

`npm pack` writes `n8n-nodes-druckling-0.1.0.tgz`.

</Step>
<Step>

### Install it into n8n [#install-it-into-n8n]

Install the tarball into n8n's nodes folder:

```bash
mkdir -p ~/.n8n/nodes
cd ~/.n8n/nodes
npm install /path/to/n8n-nodes-druckling-0.1.0.tgz
```

If n8n runs in Docker, copy the tarball into the container and install it there, in the `.n8n/nodes` folder on n8n's persistent volume:

```bash
docker cp n8n-nodes-druckling-0.1.0.tgz n8n:/tmp/
docker exec -it n8n sh -c "mkdir -p ~/.n8n/nodes && cd ~/.n8n/nodes && npm install /tmp/n8n-nodes-druckling-0.1.0.tgz"
```

</Step>
<Step>

### Restart n8n [#restart-n8n]

After a restart, **Druckling** and **Druckling Trigger** appear in the nodes panel.

</Step>
</Steps>

The package is built and tested against n8n 2.x (`n8n-workflow` 2.43, Node.js 24). It uses resource locators, resource mappers and AI tool support, which older n8n 1.x releases may lack.

## Add your credentials [#add-your-credentials]

Create a **Druckling API** credential:

| Field | Value |
| --- | --- |
| **API Key** | A key from **Developers › API keys**: `dr_test_…` while you build, `dr_live_…` in production. |
| **Base URL** | `https://druckling-nine.vercel.app` (the default). A trailing `/v1` is fine. |

The key is sent as `Authorization: Bearer <key>`. The credential test calls `GET /v1/templates`.

Use a **full-access** key. The credential test, the template list, **Map Template Fields** and the language list all read your templates, and the trigger manages webhook endpoints; render-only keys can do neither. With a render-only key the credential test fails, and only the **Document** operations work, with the template entered **By Slug** and the data as JSON. See [Authentication](/docs/authentication).

Test keys render documents that never count toward your plan's usage. Webhook endpoints, documents and events belong to the mode of the key, so a workflow with a test key sees only test documents. See [Test mode](/docs/concepts/test-mode).

## Druckling node [#druckling-node]

The Druckling node has two resources, **Document** and **Template**. It can also be used as a tool by n8n's **AI Agent**, for example to look up a template's schema and render a document from data the agent collected.

### Document › Render [#document--render]

Renders a published template, like [`POST /v1/documents`](/docs/api-reference/documents/create).

| Parameter | Description |
| --- | --- |
| **Template** | **From List** (drafts are marked: only published templates render) or **By Slug**, e.g. `invoice-standard`. |
| **Data Mode** | **JSON**: one object that matches the template's schema, e.g. the expression `{{ $json }}`. **Map Template Fields**: n8n loads the template's variables and you fill each from a value or expression; arrays such as `line_items` take a JSON array. |
| **Download PDF** | Downloads the rendered file into a binary field. See [Binary output](#binary-output). |
| **Put Output File in Field** | Name of that binary field. Default `data`. |
| **Options › Async** | Queues the render and returns right away with status `queued`. Nothing is downloaded; pick up the result with the trigger or **Get**. |
| **Options › Filename** | File name of the document, e.g. `INV-2042.pdf`. |
| **Options › Language** | One of the template's languages, from a list or an expression such as `{{ $json.customer.language }}`. Default: the template's default language. See [Languages](/docs/guides/languages). |
| **Options › Version** | A published version to render instead of the latest. |

The node doesn't offer PNG output or batches. For those, call the API with an **HTTP Request** node (see [PNG output](/docs/guides/png-output) and [Batches](/docs/guides/batches)).

### Document › Get [#document--get]

Gets a document by **Document ID** (e.g. `pdf_WvSdGvCMqjllJNqy`, or `{{ $json.data.id }}` after the trigger), with a fresh signed URL. Turn on **Download PDF** to fetch the file. See [Get a document](/docs/api-reference/documents/get).

### Document › Get Many [#document--get-many]

Lists documents, newest first, one item per document. Use **Return All** or **Limit** (default 50), and filter by **Status** (`queued`, `rendering`, `rendered`, `failed`, `expired`) or **Template Slug**. See [List documents](/docs/api-reference/documents/list).

### Template › Get and Get Many [#template--get-and-get-many]

**Get** returns one template with its `json_schema`, `sample_data`, `required_fields`, default `language` and `languages`; it's the quickest way to see which data a template needs. **Get Many** returns the workspace's templates (all, or up to **Limit**) with their status, latest version and languages. See [Get a template](/docs/api-reference/templates/get).

### Binary output [#binary-output]

With **Download PDF** on, **Render** and **Get** put the file into the binary field you named (`data` by default), ready to attach to an email or upload to cloud storage:

- The file name is the document's `filename`, and the MIME type its `content_type`. XRechnung and Peppol BIS e-invoice templates produce XML (`application/xml`) rather than PDF.
- The file is fetched from the document's short-lived signed URL. Your API key isn't sent with that request.
- A document that isn't `rendered` yet (an async render, or one that failed) has no file. The node fails with its status, and with the render error for a failed document.

### Errors [#errors]

When the data doesn't match the template's schema, Druckling answers `422` and the node fails with the first wrong field, for example:

```txt
Invalid data for field "customer.name": Required field customer.name was missing from the request payload
```

The error details list every invalid field. Turn on **Continue On Fail** to route such items onward with an `error` property instead of stopping the workflow. For `429` responses, use the node's **Retry On Fail** setting; if the code is `quota_exceeded`, your workspace has used its monthly documents. See [Errors](/docs/concepts/errors).

## Druckling Trigger [#druckling-trigger]

The trigger starts a workflow for the document events you pick:

| Event | Sent when |
| --- | --- |
| `document.rendered` | A document finished rendering, synchronously or async. |
| `document.failed` | Payload validation or rendering failed. |
| `document.expired` | A stored file passed its retention period and was deleted. |

The API's `batch.completed` event isn't available in the trigger. See [Webhooks](/docs/guides/webhooks) for every event.

### How it subscribes [#how-it-subscribes]

- **Activating** the workflow, or **Listen for test event**, creates a webhook endpoint in Druckling for the node's URL and events ([`POST /v1/webhook_endpoints`](/docs/api-reference/webhooks/create)). It shows up in **Developers › Webhooks** as `n8n: <workflow name>`. The endpoint id and its signing secret stay in the workflow's static data.
- **Changing the events** replaces the endpoint the next time the workflow is activated.
- **Deactivating** the workflow deletes the endpoint again.

Each active trigger uses one of the workspace's 20 webhook endpoints.

### Signature verification [#signature-verification]

Every delivery is checked with the [Standard Webhooks](https://www.standardwebhooks.com) scheme before the workflow starts: the HMAC-SHA256 of `webhook-id`, `webhook-timestamp` and the raw body must match one of the `v1,…` signatures in `webhook-signature` (there can be several while a secret is rotated), and the timestamp must be within 5 minutes. Anything else gets `401` and starts nothing.

Deliveries for events you didn't select, and the dashboard's **Send test event** (`webhook.ping`), are acknowledged without starting the workflow. To try the trigger, render a document with a test key.

### What the workflow receives [#what-the-workflow-receives]

One item with the event:

```json
{
  "id": "evt_…",
  "object": "event",
  "type": "document.rendered",
  "created_at": "2026-10-27T10:00:04.000Z",
  "test_mode": true,
  "data": {
    "id": "pdf_WvSdGvCMqjllJNqy",
    "object": "document",
    "status": "rendered",
    "template": "invoice-standard",
    "filename": "INV-2042.pdf",
    "pages": 1,
    "url": "https://…"
  }
}
```

`data` is the document, shortened here; see [Webhooks](/docs/guides/webhooks) for the full payload. To get the file, add **Druckling › Document › Get** with **Download PDF** and the Document ID `{{ $json.data.id }}`.

### Requirements [#requirements]

- **A public `https://` URL.** Druckling only delivers to public HTTPS addresses, and the trigger refuses to activate otherwise. A self-hosted n8n must be reachable from the internet over HTTPS with [`WEBHOOK_URL`](https://docs.n8n.io/hosting/configuration/configuration-examples/webhook-url/) set; `http://localhost:5678` won't work, so use a tunnel while developing.
- **A full-access key**, to manage the endpoint.
- **The key's mode.** A trigger with a test key only receives test-mode events, one with a live key only live events. Every event carries `test_mode`. To go live, deactivate the workflow (which removes its test endpoint), switch the credential to a live key and activate it again.

Druckling expects an answer within 10 seconds. The trigger answers as soon as it has verified the delivery, however long the workflow then runs.

## Example: email an invoice for each new spreadsheet row [#example-email-an-invoice-for-each-new-spreadsheet-row]

This workflow renders the `invoice-standard` starter for every row added to a Google Sheet and emails it to the customer. The sheet has the columns `invoice_number`, `due_date` (as `2026-11-22`), `customer_name`, `customer_address`, `customer_email`, `description`, `qty` and `rate`.

<Steps>
<Step>

### Start on new rows [#start-on-new-rows]

Add a **Google Sheets Trigger** node that fires on **Row Added** for your sheet.

</Step>
<Step>

### Shape the invoice data [#shape-the-invoice-data]

Add a **Code** node in **Run Once for Each Item** mode. Spreadsheet cells arrive as text, and the template's schema expects numbers for quantities and amounts, so convert them here:

```js title="Code"
const qty = Number($json.qty);
const rate = Number($json.rate);
const subtotal = qty * rate;
const tax = Math.round(subtotal * 8) / 100;

return {
  json: {
    invoice: { number: $json.invoice_number, due_date: $json.due_date },
    customer: { name: $json.customer_name, address: $json.customer_address },
    line_items: [{ description: $json.description, qty, rate, amount: subtotal }],
    totals: { subtotal, tax, amount: subtotal + tax },
  },
};
```

</Step>
<Step>

### Render the invoice [#render-the-invoice]

Add a **Druckling** node:

- **Resource:** Document. **Operation:** Render.
- **Template:** `invoice-standard`.
- **Data Mode:** JSON, with **Data** set to the expression `{{ $json }}`.
- **Download PDF:** on, into the field `data`.
- **Options › Filename:** `{{ $json.invoice.number }}.pdf`.

</Step>
<Step>

### Email it [#email-it]

Add your email node (Gmail, Microsoft Outlook or Send Email), send it to `{{ $('Google Sheets Trigger').item.json.customer_email }}`, and attach the binary field `data`.

</Step>
</Steps>

Run it once with a test key; the invoices show up in **Documents** in test mode and don't count toward your usage. Then switch the credential to a live key.

## Next steps [#next-steps]

<Cards>
  <Card title="Variables" href="/docs/concepts/variables">
    How a template's variables turn into the JSON Schema your data must match.
  </Card>
  <Card title="Webhooks" href="/docs/guides/webhooks">
    Events, retries and signatures behind the trigger.
  </Card>
  <Card title="MCP server" href="/docs/guides/mcp">
    Let an n8n AI Agent build templates and render documents.
  </Card>
</Cards>
