Budibase
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 Budibase account - sign up for free, no credit card required.
Use Case 1: Generate PDFs from App Data
Let users generate an invoice PDF from a Budibase invoice row and its related line items via a custom REST API connection.Button click → REST query (PolyDoc API) → Download PDF
Add a REST API data source
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_number | invoice_date | invoice_due_date | invoice_subtotal | invoice_tax_rate | invoice_tax_amount | invoice_total | customer_name | customer_email | customer_street | customer_city | customer_country |
|---|---|---|---|---|---|---|---|---|---|---|---|
| INV-2026-001 | 2026-01-15 | 2026-02-14 | 1200 | 0.1 | 120 | 1320 | John Doe | john.doe@example.com | 456 Customer Avenue | Beautiful City | UK |
| invoice_number | quantity | name | description | price | original_price |
|---|---|---|---|---|---|
| INV-2026-001 | 1 | Web Design Services | Custom website design and development for company homepage | 800 | |
| INV-2026-001 | 1 | Logo Design | Professional logo design with 3 revision rounds | 300 | |
| INV-2026-001 | 1 | SEO Optimization | Search engine optimization for 10 target keywords | 100 | 150 |
In Budibase, open Data tables from the workspace sidebar and create two tables that match the columns above - invoices for the header fields and invoice_items linked back to invoices via an invoice_number relationship. Seed one sample invoice row with three line items so you have data to render when you test in Step 4.
Then open Settings (gear icon) → Connections → APIs → Create custom and configure a workspace-level REST connection that Step 2 reads from:
- Display name:
PolyDoc - Base URL:
https://api.polydoc.tech - Authentication → Add authentication → Bearer Token. Name:
PolyDoc Bearer. Token: your PolyDoc API key (get one from the Dashboard). Budibase auto-builds theAuthorization: Bearer …header at request time - don't add it manually.
Click Save, then Open in API Editor to land in Step 2.
Configure the PolyDoc endpoint
In the API Editor (opened from Step 1), configure a new query:
- Name:
Convert Invoice to PDF - Connection:
PolyDoc - PolyDoc Bearer(the connection from Step 1) - Method: POST
- URL:
https://api.polydoc.tech/pdf/convert - Headers tab → Add header:
X-Sandbox=true - Body tab → select raw (JSON) and paste the template below.
Replace YOUR_TEMPLATE_ID with your own template's short ID - find it in the Dashboard under Templates (e.g. a1b-c2d). The bindings use Budibase's Handlebars syntax - when the query runs from a screen (Step 3) or an automation (Use Case 2), each {{ invoiceRow.field }} reads from the row passed in as a binding. See Templates for how the invoice template consumes the templateData fields.
{
"source": "[template:YOUR_TEMPLATE_ID]",
"templateData": {
"invoice_number": "{{ invoiceRow.invoice_number }}",
"invoice_date": "{{ invoiceRow.invoice_date }}",
"invoice_due_date": "{{ invoiceRow.invoice_due_date }}",
"invoice_subtotal": {{ invoiceRow.invoice_subtotal }},
"invoice_tax_rate": {{ invoiceRow.invoice_tax_rate }},
"invoice_tax_amount": {{ invoiceRow.invoice_tax_amount }},
"invoice_total": {{ invoiceRow.invoice_total }},
"customer_name": "{{ invoiceRow.customer_name }}",
"customer_email": "{{ invoiceRow.customer_email }}",
"customer_street": "{{ invoiceRow.customer_street }}",
"customer_city": "{{ invoiceRow.customer_city }}",
"customer_country": "{{ invoiceRow.customer_country }}",
"items": {{ lineItemsQuery.data }}
}
}
Create a screen with a generate button
Back in your app's Design view, open the home screen and add a Table component bound to the invoices data table you created in Step 1. With the table selected, drop a Button component into the row template and set its text to Generate PDF.
Open the button's right-panel On click setting and chain two actions in order:
- Execute Query → Datasource =
PolyDoc, Query =Convert Invoice to PDF(the one from Step 2). Bind itsinvoiceRowinput to Current row (the row the button was rendered in) and itslineItemsQueryinput to a sibling Execute Query againstinvoice_itemsfiltered byinvoice_number = Current row's invoice_number. - Navigate To → URL =
{{ Execute Query – Convert Invoice to PDF.data }}(the base64data:application/pdf;base64,…URI that Step 4's Transformer produces). Tick Open in new tab - the browser opens the data URI as a PDF preview where the user can save it.
Click Preview in the top bar, navigate to the invoice list, and click Generate PDF on a row.
Handle the PDF response
The PolyDoc endpoint returns a binary PDF, but the Navigate To action from Step 3 expects a string URL and the browser only opens PDFs from http(s):// or data: URIs. Bridge the two with the query's Transformer tab:
// Return the binary PDF as a base64 data URI so
// Step 3's Navigate To action can open it in a new tab.
return "data:application/pdf;base64," + data;
Re-test the button from Step 3 - the PDF should now download with every field populated: customer address, both dates, subtotal/tax/total all rendered as numbers, and every line item visible (including the strikethrough original_price on items that have one).
Use Case 2: Automated PDF on Row Creation
Automatically generate and email a PDF whenever a new row is added to the invoices table, using a workspace Automation.Row created → Execute query (PolyDoc) → Send Email
Create an automation with a Row Created trigger
From the workspace Home, click + Create → Automation. Give it a name (e.g. Email PDF on new invoice) and pick the Row created trigger card, then Save.
Budibase opens the automation editor with a single Row created node on the canvas. Click the node and, in the right-side panel, set Table to the invoices table from Use Case 1 Step 1. The trigger automatically exposes a steps.trigger.row object that Step 2 reads from.
Add an External REST API action
Click + after the trigger node and add an Execute query step. Pick the Convert Invoice to PDF query from Use Case 1 Step 2 - both use cases share that single query definition; no re-configuration needed.
Bind the query's inputs to the trigger payload:
invoiceRow={{ steps.trigger.row }}- the row that just fired the trigger.lineItemsQuery= the result of a sibling Execute query step against yourinvoice_itemstable that filters byinvoice_number = {{ steps.trigger.row.invoice_number }}. Add the line-items query as the first step after the trigger so its result is available when the convert step runs.
Add a Send Email action
Click + after the Execute query step and pick Send Email (SMTP) from the Email category of the step picker. Configure:
- To:
{{ steps.trigger.row.customer_email }} - Subject:
Your invoice {{ steps.trigger.row.invoice_number }} - Attachments: Add attachment → URL =
{{ steps[<convert-query-step-id>].response }}- the binary PDF returned from Step 2's Execute query. Set the filename toinvoice-{{ steps.trigger.row.invoice_number }}.pdf.
Test the automation
Click Run test in the top bar and supply a sample row that mirrors your seeded invoice. Confirm the email arrives with the PDF attached and every field populated. When it looks right, click Set live to activate the automation - from then on, every new row inserted into the invoices table fires the whole pipeline.