Apps Script sample web app

This page provides an overview of the Apps Script web app example for the Google Forms API.


  • Enable the Forms API in your Google Cloud project.
  • Set up a new Apps Script project as described in the GitHub README file for the sample web app.


The Forms API allows any authenticated client to access the API directly using REST.

Because Apps Script provides an easy way to obtain both a valid OAuth Access Token and make REST calls, it's straightforward to integrate Apps Script directly with the Forms API. Apps Script already provides an existing Forms Service, which allows scripts to create, access, and modify Google Forms. However, if you prefer to use the Forms API directly from Apps Script, set up OAuth access as follows:

  1. Get a scoped and authenticated OAuth access token.


  2. Include the OAuth token in the options argument provided in any REST calls to the API.

    UrlFetchApp.fetch(Url, options);

See Set up an Apps Script project for an example of this in action. The setup guide details the basic plumbing needed to call the API—however, to provide intuitive access to the API for end users, you can also try out and modify our sample web app.

Web app example usage

A complete example web app that calls all of the Forms API methods directly is available on GitHub for demonstration purposes.

Running the web app

Once you've set up your project and deployed it as a Web app, you can try some basic operations.

  1. Create a new form by clicking the Create Form button.

    The new form is now visible in the Form id: field and you can open it by clicking Open in Forms.

  2. After opening the new form in a separate window, try adding a few questions manually, then click Get Form by Id and you'll see your new questions in the JSON output on the right.

Feel free to explore the other methods available in the app and observe the output on the right for each operation.

Working with Forms watches

Notice also the buttons for forms watches. These use the Forms API watches feature and perform basic operations to create, list, delete and renew watches. You need to set up a project with Cloud Pub/Sub topics to use them.

For more information on Forms API watches and Cloud Pub/Sub, see Set up and receive push notifications.

Next steps

Try customizing the example app to suit your needs. Here are a few examples:

  • Create a question bank in a Google sheet, and then use the Apps Script SpreadsheetApp service to fetch questions from a sheet to populate new forms.
  • Alternatively, your question bank can reside in a SQL database where you can use the Apps Script JDBC Service to populate forms with questions from the database.
  • Generate a quiz and save the scores in a Google sheet grade book.
  • Set up your project with Cloud Pub/Sub and use the watches feature to generate a real-time student leaderboard to display quiz results.