Stay organized with collections
Save and categorize content based on your preferences.
The Apps Script API allows you to create and modify Apps Script projects
from your app. The examples on this page illustrate how some common project
management operations can be achieved with the API.
NOTE: The Apps Script API must be enabled
before usage.
In these examples, the placeholders scriptId
is used to indicate where you would provide the script project ID. Follow the
steps below to find the script ID:
In the Apps Script project, at the top left, click Project Settingssettings.
The following projects.updateContent
request updates the content of the specified script project. This content is
stored as the HEAD version, and is used when the script is executed as an API
executable project.
PUT https://scriptmanagement.googleapis.com/v1/projects/scriptID/content
{"files":[{"name":"index","type":"HTML","source":"<html> <header><title>HTML Page</title></header> <body> My HTML </body> </html>"},{"name":"My Script","type":"SERVER_JS","source":"function hello(){\nconsole.log('Hello world');}",},{"name":"appsscript","type":"JSON","source":"{\"timeZone\":\"America/New_York\",\"exceptionLogging\":\"CLOUD\"}","lastModifyUser":{"name":"Grant","email":"grant@example.com",},"createTime":"2017-10-02T15:01:23.045123456Z","updateTime":"2017-10-02T15:01:23.045123456Z"}]}
The response consists of a Content
object such as this one:
{"scriptId":"scriptId","files":[{"name":"index","type":"HTML","source":"<html> <header><title>HTML Page</title></header> <body> My HTML </body> </html>","lastModifyUser":{"name":"Grant","email":"grant@example.com",},"createTime":"2017-10-02T15:01:23.045123456Z","updateTime":"2017-10-02T15:01:23.045123456Z"},{"name":"My Script","type":"SERVER_JS","source":"function hello(){\nconsole.log('Hello world');}","lastModifyUser":{"name":"Grant","email":"grant@example.com",},"createTime":"2017-10-02T15:01:23.045123456Z","updateTime":"2017-10-02T15:01:23.045123456Z","functionSet":{"values":["name":"helloWorld"]}},{"name":"appsscript","type":"JSON","source":"{\"timeZone\":\"America/New_York\",\"exceptionLogging\":\"CLOUD\"}","lastModifyUser":{"name":"Grant","email":"grant@example.com",},"createTime":"2017-10-02T15:01:23.045123456Z","updateTime":"2017-10-02T15:01:23.045123456Z"}]}
[[["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."],[[["\u003cp\u003eThe Apps Script API enables programmatic creation and management of Apps Script projects, including tasks like creating new projects, retrieving project metadata, and updating project files.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the Apps Script API, ensure it's enabled in your Google Account settings.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve a script project's unique ID from the Project Settings in the Apps Script editor.\u003c/p\u003e\n"],["\u003cp\u003eThe API provides methods for accessing and modifying the content of script projects, such as source code and metadata for individual files within the project.\u003c/p\u003e\n"],["\u003cp\u003eUpdating project files through the API sets the updated content as the HEAD version, which is used for API execution.\u003c/p\u003e\n"]]],[],null,["# Project Management\n\nThe Apps Script API allows you to create and modify Apps Script projects\nfrom your app. The examples on this page illustrate how some common project\nmanagement operations can be achieved with the API.\n\nNOTE: The Apps Script API must be [enabled](https://script.google.com/home/usersettings)\nbefore usage.\n\nIn these examples, the placeholders \u003cvar translate=\"no\"\u003escriptId\u003c/var\u003e\nis used to indicate where you would provide the script project ID. Follow the\nsteps below to find the script ID:\n\n1. In the Apps Script project, at the top left, click **Project Settings** settings.\n2. Next to \"Script ID,\" click **Copy**.\n\nCreate a new Apps Script project\n--------------------------------\n\nThe following [projects.create](https://developers.google.com/apps-script/api/reference/rest/v1/projects/create)\nrequest creates a new [standalone script](https://developers.google.com/apps-script/guides/standalone). \n\n```\nPOST https://scriptmanagement.googleapis.com/v1/projects/\n``` \n\n```text\n{\n \"title\": \"My Script\"\n}\n```\n\nRetrieve project metadata\n-------------------------\n\nThe following [projects.get](https://developers.google.com/apps-script/api/reference/rest/v1/projects/get)\nrequest gets the script [project's metadata](https://developers.google.com/apps-script/api/reference/rest/v1/projects#Project). \n\n```\nGET https://scriptmanagement.googleapis.com/v1/projects/scriptId\n```\n\nThe response consists of an [object](https://developers.google.com/apps-script/api/reference/rest/v1/projects#Project)\nsuch as this one: \n\n```text\n{\n \"scriptId\": \"scriptId\",\n \"title\": \"My Title\",\n \"parentId\": \"parentId\",\n \"createTime\": \"2017-10-02T15:01:23.045123456Z\",\n \"updateTime\": \"2017-10-02T15:01:23.045123456Z\",\n \"creator\": { \"name\": \"Grant\" },\n \"lastModifyUser\": { \"name\": \"Grant\" },\n}\n```\n\nRetrieve project files\n----------------------\n\nThe following [projects.getContent](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getContent)\nrequest gets the content of the script project, including the code source and\nmetadata for each script file. \n\n```\nGET https://scriptmanagement.googleapis.com/v1/projects/scriptId/content\n```\n\nThe response consists of a [Content](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getContent#response-body)\nobject such as this one: \n\n```carbon\n{\n \"scriptId\": \"scriptId\",\n \"files\": [{\n \"name\": \"My Script\",\n \"type\": \"SERVER_JS\",\n \"source\": \"function hello(){\\nconsole.log('Hello world');}\",\n \"lastModifyUser\": {\n \"name\": \"Grant\",\n \"email\": \"grant@example.com\",\n },\n \"createTime\": \"2017-10-02T15:01:23.045123456Z\",\n \"updateTime\": \"2017-10-02T15:01:23.045123456Z\",\n \"functionSet\": {\n \"values\": [\n \"name\": \"helloWorld\"\n ]\n }\n }, {\n \"name\": \"appsscript\",\n \"type\": \"JSON\",\n \"source\": \"{\\\"timeZone\\\":\\\"America/New_York\\\",\\\"exceptionLogging\\\":\\\"CLOUD\\\"}\",\n \"lastModifyUser\": {\n \"name\": \"Grant\",\n \"email\": \"grant@example.com\",\n },\n \"createTime\": \"2017-10-02T15:01:23.045123456Z\",\n \"updateTime\": \"2017-10-02T15:01:23.045123456Z\"\n }]\n}\n```\n\nUpdate project files\n--------------------\n\nThe following [projects.updateContent](https://developers.google.com/apps-script/api/reference/rest/v1/projects/updateContent)\nrequest updates the content of the specified script project. This content is\nstored as the HEAD version, and is used when the script is executed as an API\nexecutable project. \n\n```\nPUT https://scriptmanagement.googleapis.com/v1/projects/scriptID/content\n``` \n\n```carbon\n{\n \"files\": [{\n \"name\": \"index\",\n \"type\": \"HTML\",\n \"source\": \"\u003chtml\u003e \u003cheader\u003e\u003ctitle\u003eHTML Page\u003c/title\u003e\u003c/header\u003e \u003cbody\u003e My HTML \u003c/body\u003e \u003c/html\u003e\"\n }, {\n \"name\": \"My Script\",\n \"type\": \"SERVER_JS\",\n \"source\": \"function hello(){\\nconsole.log('Hello world');}\",\n }, {\n \"name\": \"appsscript\",\n \"type\": \"JSON\",\n \"source\": \"{\\\"timeZone\\\":\\\"America/New_York\\\",\\\"exceptionLogging\\\":\\\"CLOUD\\\"}\",\n \"lastModifyUser\": {\n \"name\": \"Grant\",\n \"email\": \"grant@example.com\",\n },\n \"createTime\": \"2017-10-02T15:01:23.045123456Z\",\n \"updateTime\": \"2017-10-02T15:01:23.045123456Z\"\n }]\n}\n```\n\nThe response consists of a [Content](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getContent#response-body)\nobject such as this one: \n\n```carbon\n{\n \"scriptId\": \"scriptId\",\n \"files\": [{\n \"name\": \"index\",\n \"type\": \"HTML\",\n \"source\": \"\u003chtml\u003e \u003cheader\u003e\u003ctitle\u003eHTML Page\u003c/title\u003e\u003c/header\u003e \u003cbody\u003e My HTML \u003c/body\u003e \u003c/html\u003e\",\n \"lastModifyUser\": {\n \"name\": \"Grant\",\n \"email\": \"grant@example.com\",\n },\n \"createTime\": \"2017-10-02T15:01:23.045123456Z\",\n \"updateTime\": \"2017-10-02T15:01:23.045123456Z\"\n }, {\n \"name\": \"My Script\",\n \"type\": \"SERVER_JS\",\n \"source\": \"function hello(){\\nconsole.log('Hello world');}\",\n \"lastModifyUser\": {\n \"name\": \"Grant\",\n \"email\": \"grant@example.com\",\n },\n \"createTime\": \"2017-10-02T15:01:23.045123456Z\",\n \"updateTime\": \"2017-10-02T15:01:23.045123456Z\",\n \"functionSet\": {\n \"values\": [\n \"name\": \"helloWorld\"\n ]\n }\n }, {\n \"name\": \"appsscript\",\n \"type\": \"JSON\",\n \"source\": \"{\\\"timeZone\\\":\\\"America/New_York\\\",\\\"exceptionLogging\\\":\\\"CLOUD\\\"}\",\n \"lastModifyUser\": {\n \"name\": \"Grant\",\n \"email\": \"grant@example.com\",\n },\n \"createTime\": \"2017-10-02T15:01:23.045123456Z\",\n \"updateTime\": \"2017-10-02T15:01:23.045123456Z\"\n }]\n}\n```"]]