Create a Target Project for the Apps Script Execution API

Before you can begin any of the quickstarts, you will need a target Apps Script for the API to call. Follow these steps to create a simple script and enable it for API access.

Step 1: Create the script

  1. Open the Apps Script editor and create a blank project.
  2. Click on the "Untitled Project" title to rename the script. Name the script "Apps Script Execution API Quickstart Target" and click OK.
  3. Replace the contents of the file with the following:

     * The function in this script will be called by the Apps Script Execution API.
     * Return the set of folder names contained in the user's root folder as an
     * object (with folder IDs as keys).
     * @return {Object} A set of folder names keyed by folder ID.
    function getFoldersUnderRoot() {
      var root = DriveApp.getRootFolder();
      var folders = root.getFolders();
      var folderSet = {};
      while (folders.hasNext()) {
        var folder =;
        folderSet[folder.getId()] = folder.getName();
      return folderSet;

  4. Save the project by selecting File > Save.

Step 2: Publish the script for execution

  1. In the code editor, select Publish > Deploy as API executable.
  2. In the dialog that opens, leave the Version as "New" and enter "Target-v1" into the text box. Click Deploy.

Step 3: Choose a quickstart

Each of these quickstarts use the Apps Script Execution API to call the script you just created:


Apps Script
Apps Script