Automation Blog

How to Set an Airtable Attachment Filename Using the API PATCH Request in Zapier

Zapier's native Airtable actions upload attachments but do not let you control the filename. Here is how to use an Airtable API PATCH request from a Zapier Code step or Webhooks action to attach a file with a specific filename — including how to structure the request and authenticate with the Airtable API.

ZapierAirtableAPI

By Troy Tessalone · · 5 minutes

Automation Guide

A practical field guide from Automation Ace.

How to Set an Airtable Attachment Filename Using the API PATCH Request in Zapier

When you use Zapier's native Airtable "Update Record" action to attach a file to an attachment field, Zapier uploads the file but uses a generic or auto-generated filename — you cannot set a custom filename through the Zapier connector's UI. For workflows where the filename matters (signed contracts named after a client, invoices named by invoice number, exports labeled by date), this is a real limitation. The solution is to bypass the native Airtable action and use the Airtable REST API directly, which accepts a filename property in the attachment object. This guide covers how to do that from a Zapier Code step.

Why the Native Airtable Action Does Not Support Filenames

Zapier's Airtable integration maps attachment fields as file URLs — you provide the URL of the file to attach, and Zapier fetches and uploads it. The connector does not expose the attachment object's filename property, which is the field the Airtable API uses to set a custom name. The Airtable API does support this property — you just cannot reach it through Zapier's built-in connector.

The Airtable API Attachment Object Format

When updating an attachment field via the Airtable REST API, each attachment is an object with a url and an optional filename:

{
  "fields": {
    "Attachment Field Name": [
      {
        "url": "https://example.com/path/to/file.pdf",
        "filename": "Invoice-2025-001-ACME.pdf"
      }
    ]
  }
}

The PATCH endpoint updates only the specified fields on an existing record, leaving other fields unchanged. This is what you use to add or replace attachments with controlled filenames.

Step-by-Step: PATCH an Airtable Record with a Named Attachment

Prerequisites

  • An Airtable Personal Access Token with data.records:write scope for the target base — generate one at airtable.com/create/tokens
  • The Airtable Base ID (starts with app) — found in the API documentation for your base at airtable.com/api
  • The Table ID or table name
  • The Record ID of the record to update (starts with rec)
  • The URL of the file to attach and the desired filename

JavaScript Code Step

const baseId = inputData.base_id;           // e.g. "appXXXXXXXXXXXXXX"
const tableId = inputData.table_id;         // e.g. "tblXXXXXXXXXXXXXX" or table name
const recordId = inputData.record_id;       // e.g. "recXXXXXXXXXXXXXX"
const token = inputData.airtable_token;     // Personal Access Token
const fileUrl = inputData.file_url;         // URL of file to attach
const filename = inputData.filename;        // desired filename, e.g. "Invoice-001.pdf"
const fieldName = inputData.field_name;     // attachment field name in Airtable

const url = `https://api.airtable.com/v0/${baseId}/${tableId}/${recordId}`;

const response = await fetch(url, {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    fields: {
      [fieldName]: [
        {
          url: fileUrl,
          filename: filename
        }
      ]
    }
  })
});

const data = await response.json();

if (!response.ok) {
  throw new Error(`Airtable API error: ${JSON.stringify(data)}`);
}

output = {
  record_id: data.id,
  success: 'true',
  attachment_filename: filename
};

Configure Code Step Input Data

In the Code step's input data section, create fields for each variable above and map them from previous Zap steps:

  • base_id — static value, your Airtable Base ID
  • table_id — static value, your table ID or name
  • record_id — mapped from a previous step (the Airtable "Find Record" step or the trigger)
  • airtable_token — static value, your Personal Access Token (treat as a secret)
  • file_url — mapped from the step that generates or locates the file
  • filename — mapped from whatever field or logic produces the desired filename
  • field_name — static value, the exact name of the attachment field in Airtable

Building the Filename Dynamically

The filename value can be built from Zap fields to create meaningful names. For example, to name a contract PDF after the client and date:

  • Map the client name and today's date from earlier steps
  • Combine them in the filename field: Contract-[Client Name]-[Date].pdf
  • Use a Formatter by Zapier step before the Code step to sanitize the client name (remove special characters) if needed

PATCH vs. PUT for Attachments

Use PATCH, not PUT. The Airtable API's PATCH endpoint updates only the fields specified in the request body, leaving all other record fields unchanged. The PUT endpoint replaces the entire record — unspecified fields are cleared. For attachment operations where you are only updating one field, PATCH is almost always the correct choice.

Note that PATCH on an attachment field replaces the entire attachment array for that field — if the record already has attachments you want to keep, you must include them in the url array alongside the new attachment. To preserve existing attachments, first fetch the record (GET) to retrieve the existing attachment IDs and URLs, then include them in the PATCH body.

The filename limitation in Zapier's native Airtable connector is a common source of frustration for document-heavy workflows. The Airtable API PATCH approach solves it completely — and once the Code step is built, it is as reliable as any native action. For workflows that generate PDFs, contracts, or reports and store them in Airtable, controlling the filename is worth the extra step.

For more on using APIs in Zapier, see how to use APIs in Zapier steps and API authentication for automation. For a broader look at Airtable automation patterns, see the Airtable integrations guide. For help building a document management workflow in Airtable and Zapier, talk to Automation Ace.

ZapierAirtableAPI

Disclaimer: This article may include links to apps, products, or services. Some links may be affiliate links, which means Automation Ace may earn a commission at no extra cost to you.

Build Better Systems

Ready to automate with confidence?

Share your tools, process, and goals. Automation Ace can design the workflow, integration, AI assist, or code bridge that fits your business.

Start a Project →