The Complete Developer's Guide to Airtable Part 2: Webhooks
Tags: airtable, tutorial, productivity
Published: 2021-12-06 19:08:45

Airtable continues to launch new tools for developers to build in and on Airtable. Which means it is time for a new installment of [The Complete Developer's Guide to Airtable](/the-complete-developers-guide-to-airtable).

In this *part 2* of the Complete Developer's Guide to Airtable, we'll cover how to use Airtable's [incoming webhooks for automations](https://community.airtable.com/t/incoming-webhooks-for-automations/38411/9).

## What are webhooks

Webhooks are messages an application can send when a specific event occurs. Messages are most often HTTP requests. They are a common method for integrating applications and services.

In the absence of webhooks, to know if an event has occurred in another application, you need to constantly _poll_ the other application for an update. Think of a small child incessantly asking "are we there yet?" on a road trip.

Webhooks, by contrast, are a more elegant solution. When an event happens in another application - for example a new contact is created in Salesforce - an HTTP request will be sent to your app describing the event and its details. Then, your app needs an always-on endpoint for receiving these webhook requests and taking the proper action (easier said than done).

With Airtable's new support for incoming webhooks, you get an always-on webhook endpoint that is ready to receive events from internal or third party services. You can then send webhooks to Airtable to trigger automations that take the inputs of the webhook to manipulate your airtable base or trigger other actions like emails and more.

With webhooks, you no longer need to set up a scheduled automation to poll a service for updates every couple minutes. This makes integrating Airtable into your stack much nicer.

## Who get's Airtable webhooks

Webhooks are included on all Airtable plans as a part of the *Automations* feature:

![Airtable Webhook Plans](https://blog.sequin.io/webhooks/001_who_gets.png)

Keep in mind, that webhooks can happen frequently. For example, if you trigger a webhook every time a new contact is created in Salesforce, this might happen several times each day. So you can burn through the 100 automations allotted on the free tier in a number of days.

Beyond the total number of Webhooks, there are a couple other limitations developers should consider with Airtable webhooks:

* Airtable [caps webhook payloads to 100kb](https://community.airtable.com/t/incoming-webhooks-for-automations/38411/12?u=sync_inc_test_user_2) right now.
* Airtable only works with `JSON`. No `XML` or `urlencoded` webhooks for now.

> Note: Thank you to [Bill French](https://community.airtable.com/u/Bill.French), [kuovonne](https://community.airtable.com/u/kuovonne) and [ScottWorld](https://community.airtable.com/u/ScottWorld) for investigating these limits in the Airtable community.

## Building a webhook automation

To give you a practical example of how Airtable automations work with webhooks, let's build one using a [Stripe webhook](https://stripe.com/docs/webhooks).

### The scenario

Let's say your accounting team wants to use Airtable to help manage customer subscription renewals that are processed through Stripe. The team wants to be alerted before any subscription renews so they can verify the details of the subscription.

Luckily, you can have Stripe send an `invoice-upcoming` webhook several days ahead of a subscription renewing. You can create a new record in an Airtable base with the details of the webhook so the team can create a workflow to manage this process.

### A three step process

As you'll see in [Airtable's official webhook help docs](https://support.airtable.com/hc/en-us/articles/1500003044161#h_01EZFJ2CNX8M1RFABS6VEBHJZN), creating an automation that is triggered by a webhook is a three step process:

1. Create the webhook and test it.
2. Upon a successful test of the webhook, add an automation action.
3. Turn your new automation on.

### Create and test your webhook

Starting with a blank Airtable base, click the **Automations** button and select the **Create a custom automation** option:

![Add Airtable Automation](https://blog.sequin.io/webhooks/002_add_custom_auto.png)

Name your new automation something along the lines of **Upcoming Stripe Invoice**. Then click the blue **+ Choose a trigger** button and select **When webhook received**:

![Name automation and start](https://blog.sequin.io/webhooks/003_name_and_start.png)

Airtable will now generate the URL where you want Stripe to post the webhook. Copy this URL:

![Get webhook url](https://blog.sequin.io/webhooks/004_webhook_url.png)

Now that Airtable is ready to receive a webhook, head over to [Stripe](https://dashboard.stripe.com/test/webhooks) to configure a new outbound webhook.

> Note: for this tutorial we're using Stripe, but all sorts of platforms - from [Salesforce](https://salesforce-webhook-creator.herokuapp.com/), to [Jira](https://developer.atlassian.com/server/jira/platform/webhooks/), to [Shopify](https://shopify.dev/docs/admin-api/rest/reference/events/webhook) - use webhooks. Just check their developer docs.

After you login to your Stripe account, flip the switch to **View test data** (so you can test your webhooks). Then click the **Developers** option, select **Webhooks** and click to **+ Add endpoint**:

![Create stripe endpoint](https://blog.sequin.io/webhooks/005_create_stripe_endpoint.png)

In the **Add a webhook endpoint** modal that appears, paste in the URL you copied from Airtable. Then add a description and under the **Events to send** section select **invoice.upcoming**. Finally, click **Add endpoint**:

![Configure stripe endpoint](https://blog.sequin.io/webhooks/006_configure_endpoint.png)

Stripe will create the new endpoint for you. As mentioned earlier, you first need to send a _test_ webhook to Airtable in order to build out your automation. To do so click the **Send test webhook...** button:

![Configure stripe endpoint](https://blog.sequin.io/webhooks/007_test_webhook.png)

In the modal that appears, select the **invoice.upcoming** event and then click the **Send test webhook** button:

![Configure stripe endpoint](https://blog.sequin.io/webhooks/008_test_webhook_2.png)

Stripe will now send a test webhook to Airtable. You'll see the payload that was sent, and (if everything worked correctly) a `"success": true` in the response:

![Configure stripe endpoint](https://blog.sequin.io/webhooks/009_test_webhook_3.png)

Now that you have sent the test webhook from Stripe to Airtable, head back to Airtable to complete the test of the webhook.

To do so, click the **Run test** button in your automation. Airtable will verify the webhook and then present you with the data payload:

![Add resource](https://blog.sequin.io/webhooks/010_run_test.gif)

### Build your automation

Now that Airtable has validated the webhook trigger, you can build the rest of your automation by adding actions.

You could build a custom script that takes in the payload from the webhook as inputs. But for this use case, we'll just use the no-code "Create record" action.

But before we add the action, set up the Airtable base to properly store the contents of the webhook. I find it's helpful to do this after you've tested the webhook so that you can see the structure of the data you're working with.

For instance, you can see that the Stripe webhook will deliver the data with currency formatted as cents and time formatted as a Unix timestamp:

![Webhook data types](https://blog.sequin.io/webhooks/011_formats.png)

As a result, it's best we store these values as integers in the Airtable base and then use formulas to make them more friendly to users. Taken together, this is one way you could configure your Airtable base to take in the data from this webhook:

![Configure Airtable base](https://blog.sequin.io/webhooks/012_table_setup.png)

Here, you plan to record the `event_id` from the webhook as the primary key in the table. Then you store data from the webhook in additional columns. Last, you store the status of each upcoming invoice so your accounting team can track their workflow.

With your table set up, you can now easily configure the action step of your automation to create a new record. Click the blue **+ Add action** button and select **Create Record**:

![Create action](https://blog.sequin.io/webhooks/013_add_action.png)

Now map the values in the webhook payload to the fields in your table. It just takes some clicking:

![Add resource](https://blog.sequin.io/webhooks/014_map_fields.gif)

Once you've mapped all the fields, test your automation by clicking the **Run test** button:

![Add resource](https://blog.sequin.io/webhooks/015_test.gif)

Voila - your automation works!

### Turn your automation on

To finish your webhook automation, there are two more steps.

First, you'll recall that the webhook endpoint you created in Stripe is using test data. Now that you've confirmed everything is working, go back to Stripe and flip the switch so you are now working with _real_ Stripe data. Then create a new webhook endpoint that points to your Airtable webhook trigger.

> Note: Stripe is a bit unique in that it offers "test" webhooks. Most platforms require you to work with real data from the start.

Second, turn your Airtable automation on:

![Turn Airtable automation on](https://blog.sequin.io/webhooks/016_turn_on.png)

You've completed all the steps: You created a webhook trigger in Airtable, configured Stripe to send events to that webhook, tested the integration end to end, added an action to create a new record, and turned everything on.

Now, whenever a new upcoming invoice event fires, your accounting team will see it appear in Airtable automatically.

If ever there is an error, Airtable will alert you with an email. So far, we've been running our operations at [Sequin](https://sequin.io/) on an Airtable base populated with Stripe webhooks for a month with no errors on either end.

## Conclusion

For developers, the addition of inbound webhooks to trigger automations is a nice upgrade to the Airtable tool stack. Yes, you could do this with low-code tools like Zapier - but now having this raw capability in Airtable alongside Airtable scripts makes the platform even more programmable.