Stay organized with collections
Save and categorize content based on your preferences.
The Admin SDK Enterprise License Manager service allows you to use the
Admin SDK Enterprise License Manager API in
Apps Script. This API allows domain admins to assign, update, retrieve, and
delete user licenses.
Reference
For detailed information on this service, see the
reference documentation for the
Admin SDK Enterprise License Manager API. Like all advanced services in Apps
Script, the Admin SDK Enterprise License Manager service uses the same objects,
methods, and parameters as the public API. For more information, see How method signatures are determined.
This sample logs the license assignments, including the product ID and the
sku ID, for the users in the domain.
Notice the use of page tokens to access the full list of results.
/** * Logs the license assignments, including the product ID and the sku ID, for * the users in the domain. Notice the use of page tokens to access the full * list of results. */functiongetLicenseAssignments(){constproductId='Google-Apps';constcustomerId='example.com';letassignments=[];letpageToken=null;do{constresponse=AdminLicenseManager.LicenseAssignments.listForProduct(productId,customerId,{maxResults:500,pageToken:pageToken});assignments=assignments.concat(response.items);pageToken=response.nextPageToken;}while(pageToken);// Print the productId and skuIdfor(constassignmentofassignments){console.log('userId: %s, productId: %s, skuId: %s',assignment.userId,assignment.productId,assignment.skuId);}}
Insert a license assignment for a user
This sample demonstrates how to insert a license assignment for a user, for a
given product ID and sku ID combination.
/** * Insert a license assignment for a user, for a given product ID and sku ID * combination. * For more details follow the link * https://developers.google.com/admin-sdk/licensing/reference/rest/v1/licenseAssignments/insert */functioninsertLicenseAssignment(){constproductId='Google-Apps';constskuId='Google-Vault';constuserId='marty@hoverboard.net';try{constresults=AdminLicenseManager.LicenseAssignments.insert({userId:userId},productId,skuId);console.log(results);}catch(e){// TODO (developer) - Handle exception.console.log('Failed with an error %s ',e.message);}}
[[["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-18 UTC."],[[["\u003cp\u003eThe Admin SDK Enterprise License Manager service enables domain admins to manage user licenses within Apps Script using the Admin SDK Enterprise License Manager API.\u003c/p\u003e\n"],["\u003cp\u003eIt allows for assigning, updating, retrieving, and deleting user licenses for various products.\u003c/p\u003e\n"],["\u003cp\u003eThis is an advanced service that requires enabling before use and utilizes the same structure as the public API.\u003c/p\u003e\n"],["\u003cp\u003eProvided sample code demonstrates how to retrieve and assign licenses using the API.\u003c/p\u003e\n"]]],[],null,["The Admin SDK Enterprise License Manager service allows you to use the\n[Admin SDK Enterprise License Manager API](/admin-sdk/licensing) in\nApps Script. This API allows domain admins to assign, update, retrieve, and\ndelete user licenses.\n| **Note:** This is an advanced service that must be [enabled before use](/apps-script/guides/services/advanced).\n\nReference\n\nFor detailed information on this service, see the\n[reference documentation](/admin-sdk/licensing/v1/reference) for the\nAdmin SDK Enterprise License Manager API. Like all advanced services in Apps\nScript, the Admin SDK Enterprise License Manager service uses the same objects,\nmethods, and parameters as the public API. For more information, see [How method signatures are determined](/apps-script/guides/services/advanced#how_method_signatures_are_determined).\n\nTo report issues and find other support, see the\n[Admin SDK Enterprise License Manager support guide](/admin-sdk/licensing/support).\n\nSample code\n\nThe sample code below uses [version 1](/admin-sdk/groups-migration/v1/reference)\nof the API.\n\nGet a list of license assignments for the domain\n\nThis sample logs the license assignments, including the product ID and the\nsku ID, for the users in the domain.\nNotice the use of page tokens to access the full list of results. \nadvanced/adminSDK.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/adminSDK.gs) \n\n```gosu\n/**\n * Logs the license assignments, including the product ID and the sku ID, for\n * the users in the domain. Notice the use of page tokens to access the full\n * list of results.\n */\nfunction getLicenseAssignments() {\n const productId = 'Google-Apps';\n const customerId = 'example.com';\n let assignments = [];\n let pageToken = null;\n do {\n const response = AdminLicenseManager.LicenseAssignments.listForProduct(productId, customerId, {\n maxResults: 500,\n pageToken: pageToken\n });\n assignments = assignments.concat(response.items);\n pageToken = response.nextPageToken;\n } while (pageToken);\n // Print the productId and skuId\n for (const assignment of assignments) {\n console.log('userId: %s, productId: %s, skuId: %s',\n assignment.userId, assignment.productId, assignment.skuId);\n }\n}\n```\n\nInsert a license assignment for a user\n\nThis sample demonstrates how to insert a license assignment for a user, for a\ngiven product ID and sku ID combination. \nadvanced/adminSDK.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/adminSDK.gs) \n\n```gosu\n/**\n * Insert a license assignment for a user, for a given product ID and sku ID\n * combination.\n * For more details follow the link\n * https://developers.google.com/admin-sdk/licensing/reference/rest/v1/licenseAssignments/insert\n */\nfunction insertLicenseAssignment() {\n const productId = 'Google-Apps';\n const skuId = 'Google-Vault';\n const userId = 'marty@hoverboard.net';\n try {\n const results = AdminLicenseManager.LicenseAssignments\n .insert({userId: userId}, productId, skuId);\n console.log(results);\n } catch (e) {\n // TODO (developer) - Handle exception.\n console.log('Failed with an error %s ', e.message);\n }\n}\n```"]]