Automate PDFs from Google Sheets

Generate a PDF for ready spreadsheet rows, save it to Drive, and write the file link back to the sheet

This recipe processes rows whose pdf_status is ready, sends each row to SheetsToLabels, saves the returned PDF in Google Drive, and changes the status to generated.

Prepare the sheet

Use one header row. Variable column names should match the variables shown by GET /api/v1/templates/{templateId}.

name | code | qrUrl | copies | pdf_status | pdf_url
Alex Morgan | ag193 | https://example.com/ag193 | 1 | ready |

The pdf_status and pdf_url columns are required by the example. copies is optional. All other non-empty headers are sent as template variables.

Install the script

  1. Open the sheet and select Extensions → Apps Script.
  2. Replace the editor content with the SheetsToLabels Apps Script.
  3. Run configureSheetsToLabels once.
  4. Enter the API key, cloud Template ID, destination Drive folder ID, and layout JSON.
  5. Run generateReadyLabels manually and approve the Google permissions.
  6. Confirm that the PDF opens from pdf_url before adding a time-driven trigger.

For a card, badge, or one-label-per-page workflow, use:

{ "type": "single" }

For a compatible Avery 5160 sheet, use:

{ "type": "preset", "presetId": "avery-5160-compatible" }

The script stores configuration in Apps Script Properties, not spreadsheet cells. Restrict access to both the spreadsheet and Apps Script project because project editors can inspect those properties.

Add scheduled processing

After the manual test succeeds, open Triggers, add a trigger for generateReadyLabels, select Time-driven, and choose a suitable interval. The script includes a stable request hash in Idempotency-Key, so platform retries do not consume Credits twice for the same unchanged row request.

If the row data changes after a PDF was generated, set pdf_status back to ready. Because the request body changes, the script creates a new idempotency key and generates a newly charged PDF.

Batch label sheets

The downloadable script creates one PDF per ready row. That is appropriate for individual cards, badges, and independent files. When several rows should fill one label sheet, use Make or n8n to collect the rows into one records array before calling the API.

Start the API trial after the public Playground works.