Google Apps Script quickstart Stay organized with collections Save and categorize content based on your preferences.
Create aGoogle Apps Scriptthat makes requests to the Reseller API.
Quickstarts explain how to set up and run an app that calls aGoogle Workspace API. This quickstart uses asimplified authentication approach that is appropriate for a testingenvironment. For a production environment, we recommend learning aboutauthentication and authorizationbeforechoosing the access credentialsthat are appropriate for your app.
In Apps Script, Google Workspacequickstarts useAdvanced Google services to callGoogle Workspace APIs and handle some details of the authenticationand authorization flow.
Objectives
- Configure the environment.
- Create and configure the script.
- Run the script.
Prerequisites
- A Google Reseller domain instance.
- A fully executed Google Workspace partner agreement.
- Access to Google Drive
Create the script
- Create a new script in the Apps Script editor by going toscript.google.com/create.
- Replace the contents of the script editor with the following code:
/** * List Admin SDK reseller. * @see https://developers.google.com/admin-sdk/reseller/reference/rest/v1/subscriptions/list */functionlistSubscriptions(){constoptionalArgs={maxResults:10,};if(!AdminReseller||!AdminReseller.Subscriptions){thrownewError("Enable the AdminReseller Advanced Service.");}constresponse=AdminReseller.Subscriptions.list(optionalArgs);constsubscriptions=response.subscriptions;if(!subscriptions||subscriptions.length===0){console.log("No subscriptions found.");return;}console.log("Subscriptions:");for(constsubscriptionofsubscriptions){if(subscription.customerId &&subscription.skuId){if(subscription.plan?.planName){console.log("%s (%s, %s)",subscription.customerId,subscription.skuId,subscription.plan.planName,);}else{console.log("%s (%s)",subscription.customerId,subscription.skuId);}}}}
- Click Save
.
- ClickUntitled project, typeQuickstart, and clickRename.
Configure the script
Enable the Reseller API
Open the Apps Script project.
- ClickEditor.
- Next toServices, click Add a service .
- Select Google Workspace Reseller APIand clickAdd.
Run the sample
In the Apps Script editor, clickRun.
The first time you run the sample, it prompts you to authorize access:
- ClickReview permissions.
- Choose an account.
- ClickAllow.
The script's execution log appears at the bottom of the window.
Next steps
- Google Apps Script Advanced Services documentation
- Try the Google Workspace APIs in the APIs explorer
- Google Workspace Reseller API codelab
- Google Workspace Reseller API reference documentation
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-30 UTC.