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
- Get your Airtable API Key: https://support.airtable.com/hc/en-us/articles/219046777-How-do-I-get-my-API-key-
- Get your Airtable Base ID: https://support.airtable.com/hc/en-us/articles/4405741487383-Understanding-Airtable-IDs
- Get your Attachment type field name.
- NOTE: If you change the name of the Attachment field, then the Zap will break.
NOTES
- This can only be used to create new files in an Attachment type field.
- Cannot update existing Attachment file names.
- This will replace existing files in the Attachment field.
- Review help article with how to send files in Zaps: https://zapier.com/help/create/basics/send-files-in-zaps
CONFIG
- For the Action step App, use Webhooks: https://zapier.com/apps/webhook/help
- For the Action step Event, use the Custom Request option
- Set the Method to PATCH
- In the URL
- Replace aAPP_ID] with your Base ID
- Replace aRECORD_ID] with your Record ID
- In the Data
- Replace aFILE_URL] with the file link or file object
- Replace aFILE_NAME] with the filename
- In the Headers
- Replace aAPI_KEY] with your API Key
- 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