Deploying an Apps Script in Google Sheets means turning your custom script (like a macro, a custom function, or a menu item) into something you can run automatically, share with others, or access as a web app. This guide walks you through the two most common deployment types: web app (for accessing via URL) and execution API (for calling from external apps). You’ll also learn how to set up triggers so your script runs on its own. Before you start, make sure your script is saved and working in the Apps Script editor. You’ll need a Google account and the Google Sheet you want to attach the script to.
What You’ll Need
- A Google account (free or Workspace)
- A Google Sheet with an Apps Script project attached (open via Extensions > Apps Script)
- Basic familiarity with the Apps Script editor (where you write code)
- For web app deployment: a script that uses
doGet()ordoPost()to serve content
Step-by-Step
- Open your script. In Google Sheets, go to Extensions > Apps Script. This opens the editor in a new tab. If you have multiple scripts, select the one you want to deploy.
- Write and test your code. Make sure your script runs without errors. For a web app, include a
doGet(e)function that returns an HTML output, likereturn HtmlService.createHtmlOutput('Hello'). For an API, your functions can be anything you want to call externally. - Save your project. Click the floppy disk icon or press Ctrl+S (Windows) / Cmd+S (Mac). Give your project a name if prompted.
- Click the “Deploy” button. In the top-right corner of the Apps Script editor, click Deploy > New deployment. (If you’ve deployed before, you’ll see “Manage deployments” instead; choose “New deployment” from the dropdown.)
- Select deployment type. Click the gear icon next to “Select type” and choose either Web app or Execution API. For most users, “Web app” is what you want if you need a URL to open in a browser. “Execution API” is for calling functions from other programs (like a Python script or an external website).
- Configure the deployment.
- Description: Give it a name (e.g., “My Sheet Tool”).
- Execute as: Choose “Me” (the script owner) or “User accessing the web app”. For most cases, “Me” is safer because it runs with your permissions.
- Who has access: For a web app, choose “Anyone”, “Anyone with Google account”, or “Only myself”. For an API, choose “Anyone” or “Only myself”. If you choose “Anyone”, anyone with the link can use it—be careful with sensitive data.
- Click “Deploy”. Google will ask you to authorize the script. Click Review permissions, choose your Google account, and click Allow on the consent screen. If you see a warning about an unverified app, click Advanced > Go to [project name] (unsafe) only if you trust the script.
- Copy your deployment URL. After deployment, you’ll see a popup with a URL (for web apps) or an ID (for API). Copy it and save it somewhere—you’ll need it to access or call the script. Click Done.
- Test the deployment. For a web app, paste the URL into a new browser tab. For an API, use a tool like Postman or a script to call it. If you get an error, check the “Executions” log in the Apps Script editor (left sidebar) to see what went wrong.
- Set up a trigger (optional). To run your script automatically (e.g., on edit or time-based), go to the Apps Script editor, click the clock icon (Triggers) in the left menu, then Add Trigger. Choose the function, event source (e.g., “From spreadsheet”), and event type (e.g., “On edit”). Save it. Triggers are separate from deployments—they run your script without needing a URL.
- Update a deployment. When you change your script, you must create a new version. Go to Deploy > Manage deployments, click the pencil icon next to your deployment, then click Version > New version. Add a description and click Deploy. The URL stays the same, but the code updates.
- Test as a user (if shared). If you gave access to “Anyone”, test the URL from an incognito window or a different account to confirm it works for others. For API, test with a different OAuth token if applicable.
Common Mistakes
- Not using
doGet()for web apps. If your script doesn’t have adoGet()function, the web app will return a blank page or an error. - Forgetting to authorize. If you skip the permission screen, the script won’t run. Always click “Allow” after deploying.
- Choosing “User accessing the web app” when you don’t need it. This can cause permission errors if the user doesn’t have access to the underlying Sheet. Stick with “Me” unless you have a reason.
- Sharing a web app with “Anyone” while the script accesses private data. Anyone with the link can trigger the script, so it might expose data. Use “Anyone with Google account” or restrict access.
- Not creating a new version when updating. If you just edit the code and don’t redeploy, the old version remains active. Always create a new version.
- Using the wrong deployment type. If you need a URL, use “Web app”. If you need to call functions from another app, use “Execution API”. They are not interchangeable.
Tips
- Use versioning. Before deploying, go to Project Settings and enable “Show ‘appsscript.json’ manifest file” if you need to adjust OAuth scopes. But for simple deployments, versioning is enough.
- Test in a copy of your Sheet. Before deploying a script that modifies data, duplicate the Sheet and test there first.
- Use
Logger.log()orconsole.log()to debug. View logs under Executions in the editor. - Set timezone and locale in Project Settings to avoid date/time issues in your script.
- For API deployments, use the “Execution API” type and then call it with the
script.runmethod from a client (like Google Apps Script’sgoogle.script.run). But for external apps, you’ll need to use OAuth2 or an API key—check Google’s documentation for the exact setup. - Keep your script simple. If you’re just automating a repetitive task, consider using a macro (Tools > Macros) instead of a full deployment. Deployments are for sharing or web access.
Troubleshooting
- Web app returns “404 Not Found”. Your script likely lacks a
doGet()function. Add one and redeploy. - “You need permission” error. Re-authorize by going to Deploy > Manage deployments > Edit > Authorize. Or check that the script’s OAuth scopes match the services you use (e.g., if you access Sheets, you need the Sheets scope).
- Script runs but does nothing. Check the Executions log for errors. Also verify that the function you’re calling is spelled correctly and is not private (use
function myFunction(), notfunction _private()). - Deployment URL changes after update. That’s normal if you create a new deployment. If you want a stable URL, use “Manage deployments” and edit the existing one, not “New deployment”.
- API call returns “Script function not found”. The function you’re trying to call might not be in the project, or it’s not a global function (e.g., it’s inside a class). Make it a top-level function.
- Trigger doesn’t fire. Check that the trigger is saved and that the function name is correct. Also ensure the trigger’s event type matches what you want (e.g., “On edit” vs. “On change”).
Frequently Asked Questions
- Can I deploy a script without a Google Sheet? Yes, you can create a standalone script at script.google.com, but to attach it to a Sheet, you must open it from the Sheet’s Extensions menu.
- What’s the difference between a web app and an execution API? A web app returns HTML that you can view in a browser. An execution API lets you call specific functions from external code and get JSON responses. Choose based on your need.
- How do I share a deployed script with someone? For a web app, share the URL. For an API, share the script ID and set up OAuth credentials. For a script that runs inside a Sheet, share the Sheet itself—the script will be available to editors.
- Can I undeploy a script? Yes. Go to Deploy > Manage deployments, click the three-dot menu, and choose “Delete deployment”. This revokes the URL/API access.
- Do deployments cost money? No, Apps Script is free for personal and most business use, but there are daily quotas (e.g., 20,000 URL fetches per day). Check Google’s quotas page for details.
- Why does my web app show a blank page? Your
doGet()might not return an HTML service output. Ensure you usereturn HtmlService.createHtmlOutput('...')orreturn ContentService.createTextOutput('...')for plain text.
Related
- Run App Script from Google Sheet: Steps & Fixes
- Google Sheets: Is It a Microsoft App?
- Apps Script in Google Sheets: Where to Find It
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Out of Office in Outlook on Windows 11: Quick SetupTo set an out-of-office reply in Outlook on Windows 11, open Automatic replies for the account you’ll be…
- Insert and Delete Rows in Excel: Keyboard ShortcutsIn Excel for Microsoft 365 on Windows, select the row you want to work around and press Ctrl+Shift+=…
- Annual Loan Amortization Excel Template: Build a ScheduleAn annual loan amortization Excel template lists each year’s opening balance, payment, interest, principal repaid, and closing balance.…
- Excel Column Selection: Select One or More ColumnsIn Excel for Microsoft 365 on Windows, click a column letter to select that entire column, or click…
- How to Add a Blank Cover Page in WordTo add a blank cover page before an existing document in Microsoft Word, place the cursor at the…
- Microsoft Excel Text to Columns: Split Data ClearlyTo convert text to columns in Microsoft Excel for Microsoft 365 on Windows, select the cells, go to…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.