Table of Contents

How to add/update different field types in Airtable (POST, PATCH & PUT)

Pau Sanchez Updated by Pau Sanchez

Airtable is a great tool where you can store the collected information. Below you will find the different steps to set up a Request with our Webhook block and a list of types of fields that can be updated (and how) via API with the POST, PATCH, and PUT methods.

In case you want to know how to pull information from Airtable (GET) please check this article

Basics

Here we will explain step by step, how to set up the Webhook block

0. How to get URL (Airtable's App ID) and the Authorization (API Key)

We will get the information from the Airtable API Documentation, and set it in the Webhook according to the steps we will show in this article.

Note: Watch out for typos, spelling mistakes, and lower/upper case! The information in the Airtable API Documentation and the Webhook block must be identical.

In Airtable, first we need to go to the API documentation option in the Help section:

Then, once in the API documentation, click on the Authentication option:

1. Webhooks URL and Method

You must get the App ID in Airtable to build the Webhook's URL. It should look like the following:

https://api.airtable.com/v0/<app_id>/<nameofthebase>

In the examples below we used the following URL:

https://api.airtable.com/v0/appzYrKqRzqbYCGi9/Furniture

This is how it will look in your Webhook:

It consists of 2 parts:

  • The Base we are using is called Furniture, so the end of our URL is Furniture

  • The Base App Id is appzYrKqRzqbYCGi9

2. Webhook's Header (Authorization)

To set up the Webhook's Header (Authorization), you must get the API Key in Airtable.

To get an Airtable API Key, repeat the same process to get to the API Documentation, but this time click on this option:

Then, under the line where you located the APP ID, you will see the API KEY just after "Authorization":

Please copy from "Bearer" until the end of the text:

Please make sure you copy the whole code, but not the quotation marks.

This is how it should look in the Webhook block:

3. How to set up the body of the request (build the JSON)

Make sure is a valid JSON, you can use tools like https://jsonformatter.curiousconcept.com/

Fields need to be previously set up in Airtable and format and names must be consistent with the ones in such setup. Spelling mistakes, capitals, and lowercases or special formats must be equal in the JSON body and in Airtable. Any change will make the request invalid and stop working

Create a record (POST)

We use the POST method to create a new record.

Sample POST body:

{
"records": [
{
"fields": {
"email_field": "an@email.is",
"number_field": "@number",
"checkbox_field": "@trueorfalse"
}
}
],"typecast": true
}
Update a record (PATCH and PUT)

As Airtable explains:

- "PATCHย request will only update the fields you specify"

So it will change or add all the values you use in the body

- "Aย PUTย request will perform a destructive update and clear all unspecified cell values."

So it will update the fields that you add and delete all the fields not present in the body

Sample PATCH or PUT body:

It is important that if you are planning to update first, you need to know which recorded you are planning to. So the first thing to do is to find out the record id of such record.

{
"records": [
{
"id":"<recordid>"
"fields": {
"email_field": "an@email.is",
"number_field": "@number",
"checkbox_field": "@trueorfalse"
}
}
],"typecast": true
}
Force format: "typecast":true

Airtable forces us to use the correct type of formats (string, number, array, boolean...) otherwise the request will fail. However, if we use the "typecast": true method, even if we send the wrong type of format like a string when Airtable is expecting a number or a boolean value, will still accept it.

To do so here is an example of the body that has the typecast method:

{
"records": [
{
"fields": {
"email_field": "an@email.is",
"number_field": "@number",
"checkbox_field": "@trueorfalse"
}
}
],"typecast": true
}

With this setup, even if @number and @trueorfalse, are sent as Strings, Airtable will accept them and transform them to the correct format.

Be aware of the location of the "typecast" key, that is after the records array.

Setup by Field type (via API)

Required type of value: Array

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"link_to_another_record_field": [ "recFwClGZhOA34PrP" ]

Note: In this case, the value "recFwClGZhOA34PrP" is the record id of the record that is in the other table. You must have such value before in Landbot, by getting the record id previously via API request or as a static value.

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

There are 2 ways:

1. If the variable (@record_id) is a variable type String with the value of the record id:

"link_to_another_record_field": ["@record_id"]

Example of a Request Body to create a record (POST):

Example of a Request Body to update a specific record (PUT or PATCH):

2. If the variable (@record_ids) is a variable type Array that already contains the string (or strings) with the record id:

"link_to_another_record_field": "@record_ids"

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Note that the length of the array depend on the field set up if it allows multiple records or not.

Single line of text

Required type of value: String

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"single_line_text_field": "single line text"

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@singlelinevariable) is a variable type String with a value:

"single_line_text_field": "@singlelinevariable"

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Long text

Required type of value: String

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"long_text_field": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, q..."

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@long_text) is a variable type String with a value:

"long_text_field": "@long_text"

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Attachment

Required type of value: String (url where the file is hosted)

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"attachment_field": [{"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/Leonardo_da_Vinci_-_Mona_Lisa_%28Louvre%2C_Paris%29.jpg/1200px-Leonardo_da_Vinci_-_Mona_Lisa_%28Louvre%2C_Paris%29.jpg"}]

How to set up in the JSON Body using Landbot variables

The variable (@url_picture) is a variable type String with a value:

"attachment_field": [{"url": "@url_picture"}]

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Checkbox

Required type of value: Boolean (true or false), you can use String in Landbot

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"checkbox_field": true

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@url_picture) is a variable type String with a value:

"checkbox_field": "@trueorfalse"

Currently Landbot doesn't offer Boolean variables. To make sure number variables are sent properly, please add the "typecast" key. For more information please check here

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Multiple select

Required type of value: Array of string/s

It's important the the strings are written exactly as you have them in your table. Misspelling won't accept the request

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"multiple_select_field": [ "option1", "option2" ]

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@array_options) is a variable type Array with a value of string or strings inside, the value of @array_options for this example is: ["option1", "option2"]

"multiple_select_field": "@array_options"

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Single select

Required type of value: String

It's important the the strings are written exactly as you have them in your table. Misspelling won't accept the request

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"single_select_field": "in progress"

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@single_option) is a variable type String with a value:

"single_select_field": "@single_option"

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Date

Required type of value: String (ISO-8601 date)

Date type, can accept Date and Date&Time:
- If you want to send Date only you can do it like this: 2020-08-05 (YYYY-MM-DD)
- If you want to send Date&time you have to do it like this: 2020-08-05T16:28:00.000Z

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"date_field": "2020-08-05T16:28:00.000Z"

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@datetime) is a variable type String with a value:

"date_field": "@datetime"

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Phone number

Required type of value: String

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"phone_number_field": "(415) 555-9876"

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@phone) is a variable type String with a value:

"phone_number_field": "@phone"

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Email

Required type of value: String

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"email_field": "an@email.is"

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@email) is a variable type String with a value:

"email_field": "@email"

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

URL

Required type of value: String

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"url_field": "https://landbot.io/"

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@url) is a variable type String with a value:

"url_field": "@url"

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Number

Required type of value: Number

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"number_field": 12345

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@number) is a variable type Number with a value:

"number_field": "@number"
To make sure number variables are sent properly, please add the "typecast" key. For more information please check here

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Currency

Required type of value: Number

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"currency_field": 123.45

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@amount) is a variable type Number with a value:

"currency_field": "@amount"
To make sure number variables are sent properly, please add the "typecast" key. For more information please check here

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Percent

Required type of value: Number.

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"percent_field": 12.34

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@percent) is a variable type Number with a value:

"percent_field": "@percent"
To make sure number variables are sent properly, please add the "typecast" key. For more information please check here

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Duration

Required type of value: Number

Depending on the set up of the field (if is by minutes or seconds) you will need to make adjustments of the units. For example in this set up:

Duration will be the amount of seconds. So 10 minutes, will be 10*60 = 600

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"duration_field": 45240

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@duration) is a variable type Number with a value:

"duration_field": "@duration"

To make sure number variables are sent properly, please add the "typecast" key. For more information please check here

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Rating

Required type of value: Number

In the table:

In the Webhook Block (JSON Body):

The key and the value:

"rating_field": 3

Example in the JSON Body (using static values)

How to set up in the JSON Body using Landbot variables

The variable (@rating) is a variable type Number with a value:

To make sure number variables are sent properly, please add the "typecast" key. For more information please check here
"rating_field": "@rating"

Example of a Request Body to create a record (POST):

Example of a Request Body to update a record (PUT or PATCH):

Field types that CANNOT be edited via API

The following list are the type of fields that cannot be update via API:

  • Formula
  • Rollup
  • Count
  • Lookup
  • Created time
  • Last modified time
  • Created by
  • Last modified by
  • Autonumber
  • Barcode
  • Button

How to add/update different field types in the Airtable block (POST, PATCH & PUT)

Here are the options we have with the Airtable block:

To use the POST method you just need to select 'Add a record', you will then be prompted to enter the information via dropdowns, so you won't need to create any new formulas.

If you select 'Update a record', you will have the chance to filter and select the record you want to update.

One thing to keep in mind is that only the first match will be updated:

For more complex methods you can use the 'Advanced' filter, which will allow you to enter formulas.

Here's more information on that

How did we do?

20 different ways to GET and filter data from Airtable

How to Create, Update, Retrieve and Delete records in Airtable (POST, PATCH, GET & DELETE)

Contact