Converts a data frame into records and creates them in the specified table.
Automatically batches in groups of 10. Computed fields (formulas, rollups,
autoNumber, createdTime, lastModifiedTime, etc.) and attachment fields are
automatically excluded from the upload payload. When attachments is
"file" or "blob", attachment content is uploaded separately after record
creation using the dedicated upload endpoint.
Arguments
- data
A data frame of records to create. Should not contain
airtable_id(those would be ignored). Computed field columns and attachment field columns are silently dropped from the record payload.- table
Table name or ID.
- base_id
Base ID (e.g.,
"appXXXXXX"). IfNULL, uses the session default set byair_set_base()or theAIRTABLE_BASE_IDenvironment variable.- typecast
If
TRUE(default), Airtable will attempt to coerce values to match field types.- add_fields
What to do when
datacontains columns not in the table:"error"(default): error if unknown columns exist."warn": warn and drop unknown columns."yes": create missing fields before writing (assingleLineText).
- attachments
How to handle attachment fields:
"meta"(default) keeps only metadata (filename, url, size, type);"file"downloads toattachment_dir;"blob"downloads as in-memory raw vectors.- attachment_dir
Directory for downloading attachments (required when
attachments = "file"). Files are saved as{attachment_dir}/{record_id}/{filename}.- progress
Logical or
NULL. IfTRUE, shows a cli progress bar for paginated requests. IfNULL(default), uses optionairtable2.progress.baror env varAIRTABLE2_PROGRESS_BAR.- .token
Personal access token (resolved via
air_token()ifNULL).
Examples
if (FALSE) { # \dontrun{
data <- data.frame(Name = c("Alice", "Bob"), Age = c(30, 25))
ids <- air_write(data, "Contacts", "appXXXXXX")
# Write records and upload attachments from list-column
ids <- air_write(data, "Projects", "appXXXXXX",
attachments = "file",
attachment_dir = "files/"
)
# Write records and add new columns if they don't exist
ids <- air_write(data, "Contacts", "appXXXXXX", add_fields = "yes")
} # }