Formstack (OAuthV2 & REST Hooks)#

Note: This guide is for Zapier's legacy web builder. For new integrations, use our Visual Builder Quick Start guide to learn how to build Zapier integrations.

This example will walk you through creating a developer app that uses REST Hooks for a trigger that subscribes and unsubscribes a callback and waits for the data to come in. To make the example real, we'll be implementing the actual Formstack API. Let's get started!

Quick Preparation Checklist#

If you plan to follow along, it is recommended you set up everything beforehand and keep these resources open and ready for quick access.

Getting Started#

To get started, go to the Developer Platform and click the "Create App" button. You'll be asked to give a title and a brief description. After you submit, you should find yourself with a fresh app:

Next, you'll need to complete all the required steps to authenticate with OAuthV2! You can read a more detailed OAuth V2 guide here, but we'll cover the basics here. First, you'll need to create your developer app in Formstack:

To get your redirect URI, don't forget to set up your authentication settings, if you click the below button you can start an automated walkthrough that will help you get the basics set up:

And at the very end of that walkthrough, you will be able to input the information given to you from Formstack for your specific developer app:

First Trigger and Test Trigger#

Next up we'll want to create our triggers. For this Formstack example, we're going to create two triggers which will be closely intertwined!

  • New Form, will poll a JSON API to return a list of forms. We'll reuse this as the test trigger as well.
  • New Entry, will subscribe/unsubscribe a webhook to get notifications of new entries for a form.

The first trigger will test our authentication mechanism. The first trigger you create will be a test by default, we have a handy button to get started:

Which will bring you to the basic details form about the trigger you are creating. Let's create the Form trigger, it is worth reviewing the Formstack Developer Documentation on the GET /forms endpoint which we'll be using to power the trigger.

Since we don't need any other information to make this trigger tick, we can skip trigger fields. Trigger fields just add extra information for the trigger which you can use in the URL or in scripting. Our next trigger will use Trigger fields, so just skip for now!

Since we know the URL to retrieve the list of Forms from the Formstack Documentation, it is as simple as pasting directly into the Polling URL. You can skip the custom fields here, they are very rare for triggers!

You have everything you need to actually use your app, so now is a great time to test your app! Since all developer apps are available immediately on your account you can just visit your editor and use your app just like any other app Zapier supports!

REST Hook Trigger#

Now it's time for the main attraction! This is what this example is building up to, but first we need to collect a little information about the REST Hook or webhook subscription we can create. For that we'll turn to the general Formstack documentation for webhooks and Formstack's documented webhook endpoints.

Here are the pieces we'll need in this step:

  • The subscribe URL which looks something like{{form_id}}/webhook.json
  • The unsubscribe URL which looks something like{{webhook_id}}.json

First thing is first, we'll we'll need to set those subscription URLs up at the app level, you should see a button to manage your trigger settings.

Go ahead and paste the above URLs into the form and save the settings:

Next up is the big event: let's create the trigger that will use those subscription URLs! Click your add trigger button and fill out the basic information like so:

Now comes trigger fields, as you recall, in order to make set up the webhook subscription we need a form_id, luckily Zapier has some tools that makes it easy to make dynamic dropdown's that are powered by other triggers. It just so happens we've already made a trigger for this called "New Form". Let's just show you and recap after!

There are a few things going on, but the two most important are "Key" and "Dynamic Dropdown"

  • Make sure to reuse the Key form_id from the subscribe URL when making the trigger field. This pattern is fairly common and Zapier will stitch them together for you.
  • For the Dynamic Dropdown, there are three parts separated by a .:
    • trigger_key which references which trigger by key you'd like to us.
    • field_id which key from each object is the one we're interested (in this case it is the form_id we want).
    • field_name which key from object is the nice human readable version (in this case it is just name).

Both field_id and field_name are plucked from the JSON response that we get, for example, in this screenshot for the editor:

The left values are the name and the right values are the id. When a user selects an item, we'll display the name but store the id as well for use later in URLs!

Next up is actually telling this trigger to use REST Hooks and our subscription URLs as the way it grabs data, you can do this on the next step after saving your Trigger Field:

You can provide an optional polling URL or sample data with REST Hooks, but Zapier will handle the subscription process for you when the user needs some sample data. If either of those two options are available, we'll try and use them.

Next up is making sure that the request we send to Formstack for subscribe and unsubscribe are correct. That means we'll need to use our scripting feature to write some custom code to modify the requests before we send them. Just use the "Edit Code" button to start!

The three methods we'll need to use are:

  • pre_subscribe - ensure the request to subscribe matches what Formstack expects.
  • post_subscribe - ensure Zapier can store the data to identify the webhook.
  • pre_unsubscribe - ensure Zapier can unsubscribe from the identified webhook.

Again, we are going to reference the Formstack documentation for creating and removing webhooks to understand the format needed for both pre_ calls. Check out the code snippet below for a better understanding:

var Zap = {
    pre_subscribe: function(bundle) {
        bundle.request.method = 'POST';
        bundle.request.headers['Content-Type'] = 'application/x-www-form-urlencoded'; = $.param({
            url: bundle.subscription_url,
            append_data: 1
        return bundle.request;
    post_subscribe: function(bundle) {
        // must return a json serializable object for use in pre_unsubscribe
        data = z.JSON.parse(bundle.response.content);
        // we need this in order to build the {{webhook_id}}
        // in the rest hook unsubscribe url
        return {webhook_id:};
    pre_unsubscribe: function(bundle) {
        bundle.request.method = 'DELETE'; = null;
        return bundle.request;

Now, you are ready to hop back to the Editor and test the trigger properly! If you check out the "Test this Step" section and click the continue button, you should see a spinner that appears as we perform the subscribe step:

subscribing a webhook

If you click out of the "Test this Step" section (say on "Edit Options"), we'll perform the unsubscribe step for you. Now you can go back to your developer app, check out the request logs and see the POST and DELETE requests corresponding to the popup.

Note! This is the exact same process that will happen when a zap is turned on or off!

Now that you've gotten the subscription process down, we need to actually catch some data from the webhook! The process is very simple:

  1. Go back to the Editor.
  2. Get the spinner going again on Test this Step.
  3. Submit the chosen form in Formstack.
  4. Wait. Don't click away

You should see something like this once we catch the data:

successfully catching webhook

And if you click the resulting example you should see the data that we caught!

example data

You can use the catch_hook scripting method to further cleanup data (like the name and address fields that are lumped together), but that is outside the scope of this tutorial. Also, you can view your HTTP logs in your developer app for more logs on hooks in addition to normal HTTP.

Congratulations! You have a working Formstack application that:

  • Uses OAuth V2.
  • One polling trigger (reused for testing).
  • One REST Hooks trigger.
  • Scripting or custom code around subscribe/unsubscribe calls.

Be sure to check out our other examples for more details on doing other interesting things with Zapier's developer platform!

↑ Was this documentation useful? Yes No