Records in, PDFs back — inside Airtable.
A 20-line automation script turns any record into a PDF and writes it straight back into an attachment field. No third-party connector in the middle.
Prerequisites
- An ASHDOCS account — the free tier includes 100 monthly credits, no card required.
- An API key from the dashboard (Keys page). Sandbox keys (prefix ash_test_) run everything without consuming credits.
- An Airtable base with automations available — script steps and run volumes vary by Airtable plan, so check your plan's automation limits.
Test the key before building anything:
curl https://www.ashdocs.com/api/v1/me -H "X-API-Key: ash_live_..."
Setup, step by step
- 1
Create the automation
Automations → New automation. Trigger: “When record matches conditions” (for example Status is “Approved”).
- 2
Add a script action
Add action → “Run a script”. In the left panel add input variables from the triggering record: recordId, invoiceNo, client, amount.
- 3
Paste the script
The script calls the API with output set to “url”, then writes the returned link into an attachment field — Airtable ingests attachments from URLs automatically.
const { recordId, invoiceNo, client, amount } = input.config(); const res = await fetch("https://www.ashdocs.com/api/v1/tools/html-to-pdf", { method: "POST", headers: { "X-API-Key": "ash_live_...", "Content-Type": "application/json" }, body: JSON.stringify({ html: `<h1>Invoice ${invoiceNo}</h1><p>${client} — $${amount}</p>`, options: { format: "A4", output: "url" } }) }); if (!res.ok) throw new Error(await res.text()); const { file_url } = await res.json(); const table = base.getTable("Invoices"); await table.updateRecordAsync(recordId, { "PDF": [{ url: file_url, filename: `invoice-${invoiceNo}.pdf` }] }); - 4
Test and turn on
Run a test with a real record — the PDF appears in the attachment field within seconds. Turn the automation on.
Files in
PDFs already attached to records are inputs too: pass the attachment's URL as “file_url” in a JSON body to any file tool (pdf-to-data, merge, compress). Airtable attachment URLs expire, so process them promptly inside the same automation run.
Files out
Always request "output": "url". Airtable ingests attachment fields from URLs — which is exactly why URL output is the right pattern here: automation scripts cannot hold binary responses and have a ~30-second execution limit.
Three ready-made recipes
Status → “Approved” → invoice PDF in the record
- Trigger: “When record matches conditions” — Status is Approved.
- Run a script: the setup script above (html-to-pdf with record fields, output: “url”).
- The returned file_url is written into the “PDF” attachment field on the same record.
Attached PDF → extracted fields in columns
- Trigger: “When record matches conditions” — the attachment field is not empty.
- Run a script: POST https://www.ashdocs.com/api/v1/tools/pdf-to-data with {"file_url": attachmentUrl, "schema": {"invoice_number": "string", "total": "number"}}.
- Write the extracted values into columns with table.updateRecordAsync.
Async-style weekly merge of the week's PDFsasync / webhook
- Trigger: “At a scheduled time” — weekly.
- Run a script: query the week's records, collect their attachment URLs.
- POST https://www.ashdocs.com/api/v1/tools/merge with {"file_urls": [url1, url2, ...], "options": {"output": "url"}}.
- Create an archive record with the merged PDF in its attachment field. For long-running jobs, register a job.completed webhook pointing at a Make or n8n inbound hook instead — Airtable scripts cannot wait past ~30 seconds.
Troubleshooting
| Symptom | Fix |
|---|---|
| The attachment field stays empty | Airtable must fetch the URL before it expires (60 minutes) — write file_url into the attachment field immediately in the same script run. |
| Script timeout | Automation scripts stop at ~30 seconds. Stick to fast synchronous tools here, or hand long jobs to the webhook pattern via Make or n8n. |
| Using an Airtable attachment URL as input fails later | Airtable attachment URLs work as file_url inputs but they expire — fetch and process them promptly, inside the same automation run that read them. |
| 402 Payment Required | Free-plan credits are exhausted for the month. Check usage on the dashboard or upgrade the plan. |
Frequently asked questions
Does this need a paid Airtable plan?
It needs automations with script steps available on your base. Airtable's automation and scripting limits vary by plan — check your plan's automation limits in Airtable's own pricing rather than assuming.
Why URL output instead of the file itself?
Two Airtable constraints: automation scripts cannot hold binary responses, and attachment fields are populated by giving Airtable a URL to fetch. A signed 60-minute file_url satisfies both — the script stays tiny and Airtable does the download.
Can I extract data from PDFs already attached to records?
Yes. Pass the attachment's URL as file_url to pdf-to-data with a schema describing the fields you want, then write the returned values into columns — recipe 2 on this page is exactly that flow.
Do failed calls cost credits?
No. Credits are charged only on successful operations — a validation error, a fetch failure or a tool error costs nothing.