The Admin SDK Google Workspace Reseller service lets
you use the [Admin SDK Reseller API](https://developers.google.com/admin-sdk/reseller) in
Google Apps Script. This API allows authorized reseller admins to place
customer orders and manage Google Workspace monthly post-pay
subscriptions.

This is an advanced service that must be
[enabled before use](https://developers.google.com/apps-script/guides/services/advanced).

## Reference

For detailed information on this service, see the
[reference documentation](https://developers.google.com/admin-sdk/reseller/v1/reference) for the Admin SDK
Google Workspace Reseller API. Like all advanced services in
Apps Script, the Admin SDK Google Workspace Reseller
service uses the same objects, methods, and parameters as the public API. For
more information, see
[How method signatures are determined](https://developers.google.com/apps-script/guides/services/advanced#how_method_signatures_are_determined).

To report issues and find other support, see the
[Admin SDK Reseller support guide](https://developers.google.com/admin-sdk/reseller/support).

## Sample code

The following sample code uses [version 1](https://developers.google.com/admin-sdk/reseller/v1/reference) of
the API.

### Get a list of subscriptions

This sample logs the list of subscriptions, including the customer ID,
date created, plan name, and the SKU ID.
Notice the use of page tokens to access the full list of results.
advanced/adminSDK.gs [View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/adminSDK.gs)

```javascript
/**
 * Logs the list of subscriptions, including the customer ID, date created, plan
 * name, and the sku ID. Notice the use of page tokens to access the full list
 * of results.
 * @see https://developers.google.com/admin-sdk/reseller/reference/rest/v1/subscriptions/list
 */
function getSubscriptions() {
  let result;
  let pageToken;
  do {
    result = AdminReseller.Subscriptions.list({
      pageToken: pageToken,
    });
    for (const sub of result.subscriptions) {
      const creationDate = new Date();
      creationDate.setUTCSeconds(sub.creationTime);
      console.log(
        "customer ID: %s, date created: %s, plan name: %s, sku id: %s",
        sub.customerId,
        creationDate.toDateString(),
        sub.plan.planName,
        sub.skuId,
      );
    }
    pageToken = result.nextPageToken;
  } while (pageToken);
}
```