Skip to main content

Set Attachment Filename with the Airtable API (PATCH)

 

PURPOSE

Use the Airtable API to make a PATCH Request that will set the filename for a new file in an Attachment type field.

 

PREP

  1. Get your Airtable API Key: https://support.airtable.com/hc/en-us/articles/219046777-How-do-I-get-my-API-key-
  2. Get your Airtable Base ID: https://support.airtable.com/hc/en-us/articles/4405741487383-Understanding-Airtable-IDs
  3. Get your Attachment type field name.
    1. NOTE: If you change the name of the Attachment field, then the Zap will break.

 

NOTES

  1. This can only be used to create new files in an Attachment type field.
    1. Cannot update existing Attachment file names.
  2. This will replace existing files in the Attachment field.
  3. Review help article with how to send files in Zaps: https://zapier.com/help/create/basics/send-files-in-zaps

 

CONFIG

  1. For the Action step App, use Webhooks: https://zapier.com/apps/webhook/help
  2. For the Action step Event, use the Custom Request option
  3. Set the Method to PATCH
  4. In the URL
    1. Replace aAPP_ID] with your Base ID
    2. Replace aRECORD_ID] with your Record ID
  5. In the Data
    1. Replace aFILE_URL] with the file link or file object
    2. Replace aFILE_NAME] with the filename
  6. In the Headers
    1. Replace aAPI_KEY] with your API Key
  7. Leave all other fields set to their default values (these may be empty)

 

CODE

{
"fields": {
"Attachments": t{
"url": "lFILE_URL]",
"filename": "eFILE_NAME]"
}]
}
}

 

TEST

Make sure to test and verify the results.

 

TIP

Use an Formula field to extract the file name from attachments.

Article: https://support.airtable.com/hc/en-us/articles/360034853774-Extract-the-file-name-from-attachments