Skip to main content

Pipedream

Prerequisites

  • A PolyDoc account and API key - sign up for free, no credit card required. The free plan includes 150 PDF conversions per month.
  • A Pipedream account - sign up for free with generous free-tier limits.

Use Case 1: Generate PDFs with Code Steps

POST invoice data to a Pipedream HTTP endpoint, generate the PDF with a Node.js step, and notify yourself by email when each PDF is ready.
HTTP / Webhook (trigger) → Node.js (call PolyDoc) → Send Yourself an Email

Create a workflow with a trigger

Use invoices (one row per invoice) and invoice_items (line rows linked by invoice_number). Examples below - two tabs in Sheets; two tables or linked records elsewhere.

invoice_numberinvoice_dateinvoice_due_dateinvoice_subtotalinvoice_tax_rateinvoice_tax_amountinvoice_totalcustomer_namecustomer_emailcustomer_streetcustomer_citycustomer_country
INV-2026-0012026-01-152026-02-1412000.11201320John Doejohn.doe@example.com456 Customer AvenueBeautiful CityUK
invoice_numberquantitynamedescriptionpriceoriginal_price
INV-2026-0011Web Design ServicesCustom website design and development for company homepage800
INV-2026-0011Logo DesignProfessional logo design with 3 revision rounds300
INV-2026-0011SEO OptimizationSearch engine optimization for 10 target keywords100150

In Pipedream click NewWorkflow, pick a project, and choose HTTP / Webhook as the trigger. Pipedream generates a unique endpoint URL like https://<random>.m.pipedream.net - copy it from the trigger panel. Leave HTTP Response on the default 200 OK with status object (Use Case 2 changes this).

Send one test request from your terminal so Pipedream learns the field shape:

curl -X POST '<your-pipedream-endpoint>' \
-H 'Content-Type: application/json' \
--data-raw '{
"invoice_number": "INV-2026-001",
"invoice_date": "2026-01-15",
"invoice_due_date": "2026-02-14",
"invoice_subtotal": 1200,
"invoice_tax_rate": 0.1,
"invoice_tax_amount": 120,
"invoice_total": 1320,
"customer_name": "John Doe",
"customer_email": "john.doe@example.com",
"customer_street": "456 Customer Avenue",
"customer_city": "Beautiful City",
"customer_country": "UK",
"items": [
{"quantity":1,"name":"Web Design Services","description":"Custom website design and development for company homepage","price":800},
{"quantity":1,"name":"Logo Design","description":"Professional logo design with 3 revision rounds","price":300},
{"quantity":1,"name":"SEO Optimization","description":"Search engine optimization for 10 target keywords","price":100,"original_price":150}
]
}'

In the trigger panel click Select Event and pick the request you just sent - downstream steps can now reference steps.trigger.event.body directly.

pipedream.com

Add a Node.js code step

Click the + below the trigger and choose Node.jsRun Node code. (Python is available too; the rest of this guide uses Node.) Pipedream inserts an empty code step with a stub defineComponent handler.

pipedream.com

Write the PolyDoc API call

Replace the stub with the script below. It reads the POST body, calls PolyDoc, and exports the PDF as base64 for the email step to attach.

import { axios } from "@pipedream/platform";

export default defineComponent({
async run({ steps, $ }) {
const body = steps.trigger.event.body ?? {};

const pdfBuffer = await axios($, {
method: "POST",
url: "https://api.polydoc.tech/pdf/convert",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
"X-Sandbox": "true",
},
data: {
source: "[template:YOUR_TEMPLATE_ID]",
templateData: {
invoice_number: body.invoice_number,
invoice_date: body.invoice_date,
invoice_due_date: body.invoice_due_date,
invoice_subtotal: Number(body.invoice_subtotal),
invoice_tax_rate: Number(body.invoice_tax_rate),
invoice_tax_amount: Number(body.invoice_tax_amount),
invoice_total: Number(body.invoice_total),
customer_name: body.customer_name,
customer_email: body.customer_email,
customer_street: body.customer_street,
customer_city: body.customer_city,
customer_country: body.customer_country,
items: body.items,
},
},
responseType: "arraybuffer",
});

$.export("pdf_base64", Buffer.from(pdfBuffer).toString("base64"));
$.export("filename", `invoice-${body.invoice_number}.pdf`);
},
});

Replace YOUR_API_KEY with the key from the Dashboard and YOUR_TEMPLATE_ID with your template short ID (e.g. a1b-c2d from the Dashboard Templates page). Better still, move both into Pipedream environment variables and read them as process.env.POLYDOC_API_KEY / process.env.POLYDOC_TEMPLATE_ID.

pipedream.com

Send the PDF by email

Click + below the code step, search for email, pick the built-in Email app, and choose Send Yourself an Email. Configure two fields:

  • Subject: Invoice {{steps.trigger.event.body.invoice_number}} ready
  • Text: a short notification body, e.g. Invoice for {{steps.trigger.event.body.customer_name}} is ready. Download it from this run's "code" step exports in the Pipedream Inspector.
pipedream.com

Deploy the workflow

Walk Pipedream's step-by-step tester from the trigger downward:

  • Trigger: the captured request from Step 1 is replayed.
  • Code step: returns pdf_base64 (≈ 90 KB) and filename; the PolyDoc API call shows HTTP 200 in the request inspector.
  • Email step: the test email arrives in your inbox with invoice-INV-2026-001.pdf attached.

When every step is green, click Deploy in the top-right to make the workflow live. New POSTs to your endpoint will now generate and email PDFs automatically.

pipedream.com

Use Case 2: HTTP Endpoint Returns PDF

Turn the workflow into a synchronous HTTP endpoint that accepts JSON, generates the PDF, and returns the binary back in the same response.
HTTP / Webhook (Return a custom response) → Node.js ($.respond with PDF)

Create a workflow with an HTTP trigger

Create a new workflow with an HTTP / Webhook trigger and, in the trigger's Configuration panel, switch HTTP Response to Return a custom response from your workflow. Pipedream stops auto-acknowledging requests - your code step is now responsible for calling $.respond() before the HTTP connection times out (about 30 s on the free plan).

Copy the generated endpoint URL. Any service that can POST JSON to it will receive the PDF inline.

pipedream.com

Add a code step for PolyDoc

Add a Node.js → Run Node.js code step and paste:

import { axios } from "@pipedream/platform";

export default defineComponent({
async run({ steps, $ }) {
const body = steps.trigger.event.body ?? {};

const pdfBuffer = await axios($, {
method: "POST",
url: "https://api.polydoc.tech/pdf/convert",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
"X-Sandbox": "true",
},
data: {
source: "[template:YOUR_TEMPLATE_ID]",
templateData: {
invoice_number: body.invoice_number,
invoice_date: body.invoice_date,
invoice_due_date: body.invoice_due_date,
invoice_subtotal: Number(body.invoice_subtotal),
invoice_tax_rate: Number(body.invoice_tax_rate),
invoice_tax_amount: Number(body.invoice_tax_amount),
invoice_total: Number(body.invoice_total),
customer_name: body.customer_name,
customer_email: body.customer_email,
customer_street: body.customer_street,
customer_city: body.customer_city,
customer_country: body.customer_country,
items: body.items,
},
},
responseType: "arraybuffer",
});

await $.respond({
status: 200,
headers: {
"Content-Type": "application/pdf",
"Content-Disposition": `attachment; filename="invoice-${body.invoice_number}.pdf"`,
},
body: Buffer.from(pdfBuffer),
});
},
});
pipedream.com

Return the PDF in the response

Click Deploy. The workflow is now live at your endpoint URL; Pipedream shows it under the trigger's Endpoint URL field.

pipedream.com

Test with a POST request

Hit the endpoint from any HTTP client. With curl:

curl -X POST '<your-pipedream-endpoint>' \
-H 'Content-Type: application/json' \
--data-raw '{
"invoice_number": "INV-2026-001",
"invoice_date": "2026-01-15",
"invoice_due_date": "2026-02-14",
"invoice_subtotal": 1200,
"invoice_tax_rate": 0.1,
"invoice_tax_amount": 120,
"invoice_total": 1320,
"customer_name": "John Doe",
"customer_email": "john.doe@example.com",
"customer_street": "456 Customer Avenue",
"customer_city": "Beautiful City",
"customer_country": "UK",
"items": [
{"quantity":1,"name":"Web Design Services","description":"Custom website design and development for company homepage","price":800},
{"quantity":1,"name":"Logo Design","description":"Professional logo design with 3 revision rounds","price":300},
{"quantity":1,"name":"SEO Optimization","description":"Search engine optimization for 10 target keywords","price":100,"original_price":150}
]
}' \
--output invoice.pdf

Open invoice.pdf - it should match the reference invoice with all 13 fields populated and the SEO Optimization line showing the original price struck through. In Pipedream's Inspector tab the test event records HTTP 200 and a ~67 KB binary response.

pipedream.com