Assign Licenses Using the API
Admins can use the API to assign or revoke licenses for any managed package installed in their org.
Required Editions
| Available in: Salesforce Classic (not available in all orgs) |
| Available in: Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions |
| User Permissions Needed | |
|---|---|
| To manage licenses for an AppExchange app: | Manage Package Licenses |
License information for a package is stored in two objects, PackageLicense and UserPackageLicense, which are also accessible from the Manage Licenses page under Setup. These objects are also accessible as standard objects, so an admin can assign licenses to specific users via API calls. This makes managing package licenses in a subscriber org faster and easier, especially for large-scale deployments.
For example, suppose an admin installs an app for use by all 200 salespeople in the company. Assigning a license to each salesperson from the UI is inefficient and time-consuming. Using the API, the administrator can assign licenses to all salespeople, based on their profile, in one step.
Here are some common licensing tasks that administrators can use the API to do.
- Determine the number of package licenses in use and available.
- Verify if a specific user has a license for the package.
- Get a list of all users who have a license for the package.
- Assign a package license to a user or group of users.
- Revoke a package license that was previously assigned to a user.
For details of the PackageLicense and UserPackageLicense objects and a code sample, see the Object Reference for Salesforce and Lightning Platform.

