I am doing automation on package installation, now I am able to install the package from apex using metadata service class by passing package namespace and version number,

but i need to pass the installation url and install the package from apex. How to get the package details from the packaging org by using the installation url?

there is a packaging version id in the url how to tackle that id and get the packaging details. what will be sObject for package information.

Can any one please give me some leads how i can proceed here..

Below is the method to install/upgrade the package. i am check on 1G packages as of now.

public static void upsertPackages(String password, String versionNumber, String fullName)
    MetadataService.InstalledPackage installedPackageA = new MetadataService.InstalledPackage();
    installedPackageA.password = password;
    installedPackageA.versionNumber = versionNumber;
    installedPackageA.fullName = fullName;

    MetadataService.MetadataPort service = createService();
    List<MetadataService.UpsertResult> results =
            new MetadataService.Metadata[] { installedPackageA});

1 Answer 1


You can't. There is no way to go from an 04t package version Id to the package's namespace and version number. In fact, it may not have a unique namespace and version number that identify the package: if this is a 2GP version, there may exist multiple packages with distinct 04t ids but the same namespace and version number.

If you need to install a package using an 04t id, use the Tooling API's PackageInstallRequest object instead of the Metadata API.

  • Hi David - thank you for the response. i will check the tooling api to achieve it. Actullay i am doing this POC on internal pkgs installation between the orgs, hence developer can provide the installation url instead of other required details to install the package. With the metadata api i can able to install the 3rd party packages as well by passing the namespace, version number and password. will add my code in question body. so with this existing code can able to use tooling api to get the details and pass them to the existing method? or it will be a complete new approach i need to follow? May 19, 2022 at 3:25
  • The Tooling API is completely different from the Metadata API.
    – David Reed
    May 19, 2022 at 4:49
  • ok thank you. i am completely new to tooling api concept. Reading through some documents to understand it. Could you please provide any articles to implement this using tooling api will be helpful. May 19, 2022 at 9:25
  • i can able to get the details through tooling SOQL used in REST api call May 20, 2022 at 8:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .