# Set up an API POST request - Airtable

{% hint style="info" %}
[Upgrade your free account](/get-started/unlock-power-features-to-create-interactive-apps.md) to the **Bravo Solo plan** to use this feature.
{% endhint %}

The **Data Collections** allow you to create API requests to any database or tool with an available REST API.

Here is how to create a **POST request** to create data in the external database from your app.

<figure><img src="/files/kWBrWBoFGSaxE7s97qLx" alt=""><figcaption></figcaption></figure>

{% embed url="<https://www.youtube.com/watch?v=62IYPw4aIwU&list=PLzg-UiRu-a_YTj5_eTVuR1uNmAFHKBuew&index=5>" %}

{% hint style="info" %}
You can utilize other API verbs (i.e. **PUT** or **PATCH**) to create data if your API specifies otherwise. Simply change the verb type of the request URL.
{% endhint %}

**Example Figma file**

Here is the [Figma file](https://www.figma.com/file/wcw77bpYd48s83G1KEFGap/Bravo-samples%3A-Form-Scores?type=design\&node-id=0-1\&mode=design\&t=FpbVWedz7lh9feXH-0) used in the example.

**Example Database**

We'll use an Airtable base as an example. In case you're using another backend tool, **you need to read the API documentation to see how to construct the request** (both the URL and body).

Duplicate [this Airtable base](https://airtable.com/shrjetk4AeKeUuumw) as the database to send data. We will follow Airtable's API documentation to set up the POST request below. Here, we'll see an example request with the JSON body we need to use to add a new record to the table.

## How to set up a POST request

1\. In **Data Library**, click `+ New Collection` and select `Airtable Wizard`.

{% hint style="info" %}
In case you're using another backend tool, choose `Start from scratch`. You can also import your API definition (Open API, Postman or Swagger) to set up API requests.
{% endhint %}

![](/files/wqhOqye9CLCUfPHYZA7A)

2\. Follow the wizard to create a new API collection, with two sample GET requests targeting the Airtable base.

{% hint style="info" %}
A **Collection** is a group of API requests, usually for the same data source.
{% endhint %}

<div align="center"><img src="/files/DojEdLSC4DPe0pg5Nr0q" alt=""></div>

3\. After completing the tutorial, one [GET list](/connect-api/set-up-api-requests/creating-an-api-collection/airtable/set-up-an-api-get-request-for-list-page-airtable.md) and one [GET detail](/connect-api/set-up-api-requests/creating-an-api-collection/airtable/data-library-connect-to-any-api-get-request-for-detail-page.md) requests will be created. **Duplicate** the GET List request, **edit the request name** to help you identify it + change the request type to `POST`.

![](/files/GSz1CUgScXefCQDk2Ysq)

4\. **Change the POST request URL in case you need to do that.** In this example, we'll keep the same URL as in the GET list request. The URL is targeting the `Scores` table of the Airtable base.

5\. The API documentation specifies any **Headers**, **Parameters**, and/or **Body** value needed in order to make the POST request. In this example, Airtable requires an Authorization header field, as it uses the [bearer token method](https://www.oauth.com/oauth2-servers/differences-between-oauth-1-2/bearer-tokens/) to authenticate the request.

For **Header**: *\*\**`H "Authorization: Bearer YOUR_API_KEY".`

In this example, as we used the Airtable wizard and provided the API key there, this value will be already set for us. In case you're using another backend tool, **read the documentation** to see how you should authenticate your requests.

![Airtable POST request: Header input. If you used the tutorial, this value will be already set for you.](/files/6286wQDGNIxF2LPykhg2)

6\. The type of the body of the request is indicated by the **Content-Type** header.

For **Body**: Airtable indicates `H "Content-Type: application/json"`. Therefore, under `Body`, select `JSON` to indicate which data will be sent in the POST request.

&#x20; 6A. Copy one record data from the **Example Request** in the API documentation. Make sure you have the same amount of opening and closing brackets. You can use a [JSON validator](http://json-validator.com/) to make sure the JSON snippet you copied is syntactically correct, and avoid getting errors later on.

<div align="left"><img src="/files/mZBOZJXkVyXSlWELbZPq" alt=""></div>

&#x20; 6B. Now, we'll replace the values in the example request body with variables, keeping the same key names ("Name" and "Score" in this case), as these are the names of the Airtable columns.

To define a variable, we'll use this notation: <mark style="color:red;">`${input}`</mark>. In our case, we'll define the variables <mark style="color:red;">`${name}`</mark> and <mark style="color:red;">`${score}`</mark>, but you can use whatever variable name you wish. **Permitted characters:** lowercase a-z, uppercase A-Z, 0 to 9, underscore (\_) and dash (-). **No spacing**.

Later on, when binding the UI elements of our app to the API requests, we'll specify which elements are bound to which variables. For instance, if we have a [form](https://www.figma.com/community/file/981976861747536392) connected to this post request, we'll bind each input field to one of the variables we defined in the JSON body.

```
{
  "records": [
    {
      "fields": {
        "Name": "${name}",
        "Score": ${score}
      }
    }
  ]
}
```

{% hint style="warning" %}
For **text** input, include the quotation marks, like `"`<mark style="color:red;">`${input}`</mark>`".` For **number** input, do not include the quotations, like <mark style="color:red;">`${input}`</mark>
{% endhint %}

&#x20; 6C. Finally, we'll send a test request against our database, to make sure the request is built correctly. For that, we'll go to the **Test Values** section inside the API request, and indicate mock data for the variables we previously defined. **The Key name for the test value must match the name we defined for the variable** (case-sensitive).

The example content will appear in your database in the next step if the POST request is set up correctly.

![](/files/6CT4GAZlvxT7WKhX7feX)

7\. Once we've set the values, press **Send**. A new record will be created in our table, with the data we specified as test value.

If the request was sent successfully, you'll get a response message, containing the data received from the API endpoint. The received data will depend on the configuration of the backend tool. In this example, we'll receive the data corresponding to the row we just created.

On the other hand, if the request was not successful, you will get an [HTTP error](/good-to-know/troubleshoot/errors-in-api-requests.md) as a response. In this case, r**eview and double check your JSON body and URL to be correct**.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bravostudio.app/connect-api/set-up-api-requests/creating-an-api-collection/airtable/data-library-connect-to-any-api-post-request.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
