Enterprise License Manager API: Developer's Guide

This document describes how account-level and reseller administrators can use the Enterprise License Manager API to manage users license assignments. Once your account's product SKU licenses have been enabled and your users have been created, use the Enterprise License Manager API to assign, update, retrieve, and delete licenses for your account's users.

In this version, the Enterprise License Manager API is used by account and reseller administrators. Delegatedadministrators with theLicense Management privilege can also use the Enterprise License Manager API.

Note: The Enterprise License Manager API is used by a Google customer. For information about how Google third-party application developers manage licenses, see theGoogle Workspace Marketplace API.

The Enterprise License Manager API is based on theRepresentational State Transfer (RESTful) design approach to web services.

Managing Licenses

Assign a license

Previous to this operation, the customer or reseller has ordered Google product licenses and has created the user. To assign one of these product licenses to this user, use the followingPOST HTTP request. Include theAuthorization header as described inAuthorizing requests. For product and SKU IDs, see the API's availableProducts and SKUs:

POST https://www.googleapis.com/apps/licensing/v1/product/productId/sku/skuId/user

Note: A user can be assigned licenses for a wide range of different Google products. But a user is assigned only one SKU license per product at a time. By using the API, a user's SKU license can be reassigned to a different SKU license within the product.

This example assigns the Google-Drive-storage-20GB SKU to the user whose primary email address is alex@example.com:

POST https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-20GB/user

The JSON request body:

{"userId":"alex@example.com",}

A successful response returns a200HTTP status code. For possible error codes, see the API'sError codes. If successful, the response returns the licensing assignment status in JSON data format.

JSON Response

{"kind":"licensing#licenseAssignment","etags":"etag value","selfLink":"https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-20GB/user/alex@example.com","userId":"alex@example.com","productId":"Google-Drive-storage","skuId":"Google-Drive-storage-20GB","skuName":"Google Drive storage 20 GB","productName":"Google Drive storage"}

For more information, see the licenseAssignmentsinsert method reference page.

Reassign a user's product SKU with a different SKU in the same product

To reassign a user's license to a new license SKU within the same product, use the followingPUT HTTP request. The API also supports thepatch syntax. Include theAuthorization header as described inAuthorizing requests. For product and SKU IDs, see the API's availableProducts and SKUs:

PUT https://www.googleapis.com/apps/licensing/v1/product/productId/sku/the current skuId/user/user's email

This example updates the present Google-Drive-storage-20GB SKU with the Google-Drive-storage-50GB. The present license SKU is in the request's URI and the new license SKU is in the request's body:

PUT https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-20GB/user/alex@example.com

The JSON request body has :

{"kind":"licensing#licenseAssignment","etags":"etag value","selfLink":"https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com","userId":"alex@example.com","productId":"Google-Drive-storage","skuId":"Google-Drive-storage-50GB","skuName":"Google Drive storage 50 GB","productName":"Google Drive storage"}

A successful response returns a200HTTP status code. For possible error codes, see the API'sError codes. If successful, the response returns the license assignment status in JSON data format.

JSON Response

{"kind":"licensing#licenseAssignment","etags":"etag value","selfLink":"https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com","userId":"alex@example.com","productId":"Google-Drive-storage","skuId":"Google-Drive-storage-50GB","skuName":"Google Drive storage 50 GB","productName":"Google Drive storage"}

For more information, see the licenseAssignmentsupdate method andpatch method reference pages.

Retrieve all users assigned licenses for a specific product

To get all user licenses for a specific product, use the followingGET HTTP request. Include theAuthorization header as described inAuthorizing requests. ThecustomerId query string is the customer's primary domain name. ThemaxResults query string determines how many user license entries are returned in the API's response:

GET https://www.googleapis.com/apps/licensing/v1/product/productId/users?customerId=primary domain name&maxResults=max results per page

For product and SKU IDs, see the API's availableProducts and SKUs.

This example lists the first page of results for all users in the example.com domain assigned licenses for the Google-Drive-storage product:

GET https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/users?customerId=example.com&maxResults=2

A successful response returns a200HTTP status code. For possible error codes, see the API'sError codes. If successful, the response returns the licensing list in JSON format.

JSON Response

{"kind":"licensing#licenseAssignmentList","etag":"etag value","nextPageToken":"the next page token value","items":[{"kind":"licensing#licenseAssignment","etags":"etag value","selfLink":"https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com","userId":"alex@example.com","productId":"Google-Drive-storage","skuId":"Google-Drive-storage-50GB","skuName":"Google Drive storage 50 GB","productName":"Google Drive storage"},{"kind":"licensing#licenseAssignment","etags":"etag value","selfLink":"https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-200GB/user/keshav@example.com","userId":"keshav@example.com","productId":"Google-Drive-storage","skuId":"Google-Drive-storage-200GB","skuName":"Google Drive storage 200 GB","productName":"Google Drive storage"},...}

For more information, see the licenseAssignmentslistForProduct method reference page.

Retrieve all users assigned licenses for a specific product SKU

To get a list of all users with licenses for a specific product SKU, use the followingGET HTTP request. Include theAuthorization header as described inAuthorizing requests. ThecustomerId query string is the customer's primary domain name. ThemaxResults query string determines how many user entries are returned in the API's response:

GET https://www.googleapis.com/apps/licensing/v1/product/productId/sku/skuId/users?customerId=primary domain name&maxResults=max results per response page

For product and SKU IDs, see the API's availableProducts and SKUs

This example returns the first page of all users in the example.com domain assigned a license for the Google-Drive-storage-200GB SKU. The response lists two user entries per page:

GET https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-200GB/users?customerId=example.com&maxResults=2

A successful response returns a200HTTP status code. For possible error codes, see the API'sError codes. If successful, response returns the licensing list in JSON format.

JSON Response

{"kind":"licensing#licenseAssignmentList","etag":"etag value","nextPageToken":"next page token's value","items":[{"kind":"licensing#licenseAssignment","etags":"etag value","selfLink":"https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-200GB/user/alex@example.com","userId":"alex@example.com","productId":"Google-Drive-storage","skuId":"Google-Drive-storage-200GB","skuName":"Google Drive storage 200 GB","productName":"Google Drive storage"},{"kind":"licensing#licenseAssignment","etags":"etag value","selfLink":"https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-200GB/user/mary@example.com","userId":"mary@example.com","productId":"Google-Drive-storage","skuId":"Google-Drive-storage-200GB","skuName":"Google Drive storage 200 GB","productName":"Google Drive storage"},...}

For more information, see the licenseAssignmentslistForProductAndSku method reference page.

Retrieve a specific user's license by product SKU

To get a specific user's license by product SKU, use the followingGET HTTP request. Include theAuthorization header as described inAuthorizing requests. For product and SKU IDs, see the API's availableProducts and SKUs:

GET https://www.googleapis.com/apps/licensing/v1/product/productId/sku/skuId/user/userId

This example gets the Google Drive storage 50GB product SKU for the user whoseuserId is alex@example.com:

GET https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com

If the user has this license, it is a successful response and a200HTTP status code. For possible error codes, see the API'sError codes. If successful, the response returns the user's license in JSON format.

JSON Response

{"kind":"licensing#licenseAssignment","etag":"etag value","selfLink":"https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com","userId":"keshav@example.com","productId":"Google-Drive-storage","skuId":"Google-Drive-storage-50GB","skuName":"Google Drive storage 50 GB","productName":"Google Drive storage"}

For more information, see the licenseAssignmentsget method reference page.

Delete a license

To unassign a license from a user, use the followingDELETE HTTP request. Include theAuthorization header as described inAuthorizing requests. For product and SKU IDs, see the API's availableProducts and SKUs:

DELETE https://www.googleapis.com/apps/licensing/v1/product/productId/sku/skuId/user/userId

This example the Google-Drive-storage-50GB license is unassigned from the user whoseuserId is alex@example.com:

DELETE https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com

A successful response returns a200HTTP status code. For possible error codes, see the API'sError codes.

For more information, see the licenseAssignmentsdelete method reference page.

Error codes

If the request is unsuccessful, the response has a brief explanation of the error:

Error CodeDescription
400Bad Request - User email not valid.
400Bad Request - SKU/product does not exist.
401Actor doesn't have credentials to call this API.
404If the user does not have this license, the response has a 'not found' error code.
412A precondition has not been met. For details on this error, check themessage field. For example:
  • Auto License switching is not allowed.
  • Auto License un-assignment is not allowed.
  • For reassign operations, the new SKU should be different from the old SKU:sku
  • Reassign operation can't be performed on different products:product1, product2
  • Reassign operation can't be performed on different users:user1, user2
  • There aren't enough available licenses for the specified product-SKU pair
  • User already has a license for the specified product and SKU
  • User already has a license of the product, but with a different SKU. To reassign a new SKU for this product, use the 'update' operation.
503The License Manager service is not available.