Advanced Google services Stay organized with collections Save and categorize content based on your preferences.
Page Summary
Advanced services in Apps Script allow experienced developers to connect to certain public Google APIs with less set-up than using their HTTP interfaces.
Advanced services function similarly to built-in Apps Script services, offering features like autocomplete and automatic authorization flow, but require explicit enabling.
Developers can access Google APIs via advanced services or by making direct requests using
UrlFetch, with each method having different requirements and advantages.Using advanced services is generally easier and recommended, while the
UrlFetchmethod offers full API functionality but requires manual authorization and handling of requests and responses.Before using an advanced service, you must enable it in your script project and ensure the corresponding API is enabled in your associated Cloud Platform project.
Advanced services in Apps Script let you connect to certainpublic Google APIs with less setup than using their HTTP interfaces. Advancedservices are thin wrappers around those Google APIs. They work much likeApps Script'sbuilt-inservices—for example, they offerautocomplete, and Apps Script handles theauthorizationflow automatically. However, youmustenable an advanced service before you can useit in a script.
Enable advanced services
To use an advanced Google service, follow these instructions:
Step 1: Enable the advanced service
You can enable an advanced service using the Apps Script editoror by editing the manifest.
Method A: Using the Editor
- Open the Apps Script project.
- At the left, clickEditor.
- At the left, next toServices, clickAdd a service.
- Select an advanced Google service and clickAdd.
Method B: Using the manifest
You can enable advanced services by editing themanifestfile. For example, to enable theGoogle Drive advanced service, add theenabledAdvancedServices field to thedependencies object:
{"timeZone":"America/Denver","dependencies":{"enabledAdvancedServices":[{"userSymbol":"Drive","version":"v3","serviceId":"drive"}]},"exceptionLogging":"STACKDRIVER","runtimeVersion":"V8"}After you enable an advanced service, it's available in autocomplete.
Step 2: Enable the Google Cloud API (Standard Google Cloud project projects only)
If you are using a default Google Cloud project (created automatically byApps Script), you can skip this step. The API is enabledautomatically when you add the service in Step 1.
If you're using astandardGoogle Cloud project,you must also manually enable the API corresponding to the advanced service. Toenable the API manually:
Open the Cloud project associated with your script in the**Google Cloud console**
At the top of the console, click into the search bar and type part of thename of the API (for example, "Calendar"), then click thename once you see it.
ClickEnable API.
Close the Google Cloud console and return to the script editor.
How method signatures are determined
Advanced services generally use the same objects, method names, and parametersas the corresponding public APIs, although method signatures are translated foruse in Apps Script. The script editorautocompletefunction usually providesenough information to get started, but the rules that follow explain howApps Script generates a method signature from a public GoogleAPI.
Requests to Google APIs can accept a variety of different types of data,including path parameters, query parameters, a request body, or a media uploadattachment. Some advanced services can also accept specific HTTP request headers(for example, theCalendar advancedservice).
The corresponding method signature in Google Apps Script has the followingarguments:
- The request body (usually a resource), as a JavaScript object.
- Path or required parameters, as individual arguments. If the method requiresmultiple path parameters, they appear in the order they are listed in theAPI endpoint URL.
- The media upload attachment, as a
Blobargument. - Optional parameters (typically query parameters), as a JavaScript objectmapping parameter names to values.
- HTTP request headers, as a JavaScript object mapping header names to headervalues.
If the method doesn't have any items in a given category, that part of thesignature is omitted.
There are some special exceptions to be aware of:
- For methods that accept a media upload, the parameter
uploadTypeis setautomatically. - Methods named
deletein the Google API are namedremoveinApps Script, sincedeleteis a reserved word in JavaScript. - If an advanced service is configured to accept HTTP request headers, and youset a request headers JavaScript object, then you must also set the optionalparameters JavaScript object (to an empty object if you aren't usingoptional parameters).
Example: Calendar.Events.insert
Suppose you want to create aCalendarevent.The Google Calendar API documentation shows the corresponding HTTP requeststructure:
- HTTP Verb:
POST - Request URL:
https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events Request Body: AnEventresource.
Query Parameters:
sendUpdates,supportsAttachments, etc.
In Apps Script, the method signature is determined by reorderingthese inputs:
- Body: The event resource (JavaScript object).
- Path: The
calendarId(string). - Optional parameters: The query parameters (JavaScript object).
The resulting method call looks like this:
constevent={summary:'Lunch',location:'Deli',start:{dateTime:'2026-01-01T12:00:00-05:00'},end:{dateTime:'2026-01-01T13:00:00-05:00'}};constcalendarId='primary';constoptionalArgs={sendUpdates:'all'};Calendar.Events.insert(event,calendarId,optionalArgs);Advanced services or HTTP?
Each of the advanced Google services is associated with a public Google API. InApps Script, you can access these APIs using advanced services orby making the API requests directly usingUrlFetch.
If you use the advanced service method, Apps Script handlestheauthorization flow and offersautocomplete support. However, you mustenable the advancedservice before you can use it.
If you use theUrlFetch method to access the API directly, you areessentially treating the Google API as anexternalAPI. With this method, all aspects ofthe API can be used. However, it requires you to handle the API authorization.
The following table compares the two methods:
| Feature | Advanced Service | UrlFetch (HTTP) |
|---|---|---|
| Authorization | Handled automatically | Manual handling required |
| Autocomplete | Available | Not available |
| Functionality Scope | May be a subset of the API | Full access to all API features |
| Complexity | Easier | More complex (requires constructing headers and parsing responses) |
Code comparison
The code samples show the difference in complexity between creating aCalendar event using the advanced service versus usingUrlFetchApp.
Advanced Service:
constevent={summary:'Lunch',location:'Deli',start:{dateTime:'2026-01-01T12:00:00-05:00'},end:{dateTime:'2026-01-01T13:00:00-05:00'}};constoptionalArgs={sendUpdates:'all'};Calendar.Events.insert(event,'primary',optionalArgs);UrlFetch (HTTP):
constevent={summary:'Lunch',location:'Deli',start:{dateTime:'2026-01-01T12:00:00-05:00'},end:{dateTime:'2026-01-01T13:00:00-05:00'}};consturl='https://www.googleapis.com/calendar/v3/calendars/primary/events?sendUpdates=all';constoptions={method:'post',contentType:'application/json',headers:{Authorization:`Bearer${ScriptApp.getOAuthToken()}`},payload:JSON.stringify(event)};UrlFetchApp.fetch(url,options);UrlFetchApp method, you must manually specify the requiredOAuth scopes in the script'smanifestfile.We recommend using an advanced service whenever possible and only use theUrlFetch method when the advanced service isn't available or doesn't providethe functionality you need.
Support for advanced services
Because advanced services are thin wrappers around Google APIs, any issueencountered while using them is usually an issue with the underlying API, notwith Apps Script.
If you encounter a problem while using an advanced service, it should bereported using the support instructions for the underlying API.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.