To give form creators more control over who can respond, we're introducing granular controls for responders. Forms created with the API after January 31, 2026 will have an unpublished state by default. To learn more, see API changes to Google Forms.
Stay organized with collections
Save and categorize content based on your preferences.
This page provides an overview of the Apps Script web app example for the
Google Forms API.
Prerequisites
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.
Overview
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:
Get a scoped and authenticated OAuth access token.
ScriptApp.getOAuthToken();
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.
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.
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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],["This content details using Apps Script with the Google Forms API. Key actions include enabling the Forms API and setting up an Apps Script project. It demonstrates obtaining an OAuth access token via `ScriptApp.getOAuthToken()` and making REST calls with `UrlFetchApp.fetch()`. A web app example allows users to create forms, view them by ID, and interact with API methods. Additionally, it highlights the use of Forms API watches with Cloud Pub/Sub for creating, listing, deleting, and renewing watches. The app can be customized to suit specific needs.\n"],null,["# Apps Script sample web app\n\nThis page provides an overview of the Apps Script web app example for the\nGoogle Forms API.\n\nPrerequisites\n-------------\n\n- Enable the Forms API in your Google Cloud project.\n- Set up a new Apps Script project as described in the [GitHub README file](https://github.com/googleworkspace/apps-script-samples/blob/main/forms-api/demos/AppsScriptFormsAPIWebApp/README.md) for the sample web app.\n\nOverview\n--------\n\nThe Forms API allows any authenticated client to access the API\ndirectly using [REST](https://www.codecademy.com/article/what-is-rest).\n\nBecause Apps Script provides an easy way to obtain both a valid\n[OAuth Access Token](https://oauth.net/2/access-tokens/) and make REST calls,\nit's straightforward to integrate Apps Script directly with the Forms API.\nApps Script already provides an existing\n[Forms Service](/apps-script/reference/forms), which allows scripts to create,\naccess, and modify Google Forms. However, if you prefer to use the\nForms API directly from Apps Script, set up OAuth access as follows:\n\n1. Get a scoped and authenticated OAuth access token.\n\n `ScriptApp.getOAuthToken();`\n2. Include the OAuth token in the *options* argument provided in any REST\n calls to the API.\n\n `UrlFetchApp.fetch(Url, options);`\n\nSee\n[Set up an Apps Script project](/workspace/forms/api/guides/forms-apps-script)\nfor an example of this in action. The setup guide details the basic plumbing\nneeded to call the API---however, to provide intuitive access to the API for\nend users, you can also try out and modify our sample web app.\n\nWeb app example usage\n---------------------\n\nA complete example web app that calls all of the Forms API methods directly\nis available on\n[GitHub](https://github.com/googleworkspace/apps-script-samples/tree/main/forms-api/demos/AppsScriptFormsAPIWebApp)\nfor demonstration purposes.\n\n### Running the web app\n\nOnce you've set up your project and deployed it as a Web app, you can try some\nbasic operations.\n\n1. Create a new form by clicking the **Create Form** button.\n\n The new form is now visible in the **Form id:** field and you can open it by\n clicking **Open in Forms**.\n2. After opening the new form in a separate window, try adding a few questions\n manually, then click **Get Form by Id** and you'll see your new questions\n in the JSON output on the right.\n\nFeel free to explore the other methods available in the app and observe the\noutput on the right for each operation.\n\n### Working with Forms watches\n\nNotice also the buttons for forms\n[watches](/workspace/forms/api/reference/rest/v1/forms.watches). These use the\nForms API watches feature and perform basic operations to\ncreate, list, delete and renew watches. You need to set up a project with\n[Cloud Pub/Sub](https://cloud.google.com/pubsub) topics to use them.\n\nFor more information on Forms API watches and Cloud Pub/Sub, see\n[Set up and receive push notifications](/workspace/forms/api/guides/push-notifications).\n\nNext steps\n----------\n\nTry customizing the example app to suit your needs. Here are a few examples:\n\n- Create a *question bank* in a Google sheet, and then use the Apps Script [SpreadsheetApp](/apps-script/reference/spreadsheet/spreadsheet-app) service to fetch questions from a sheet to populate new forms.\n- Alternatively, your question bank can reside in a SQL database where you can use the Apps Script [JDBC Service](/apps-script/reference/jdbc) to populate forms with questions from the database.\n- Generate a quiz and save the scores in a Google sheet grade book.\n- Set up your project with Cloud Pub/Sub and use the [watches](/workspace/forms/api/guides/push-notifications) feature to generate a real-time student leaderboard to display quiz results."]]